59 lines
1.6 KiB
JavaScript
59 lines
1.6 KiB
JavaScript
const { app, BrowserWindow, ipcMain } = require('electron');
|
|
const path = require('path');
|
|
|
|
function createWindow() {
|
|
const mainWindow = new BrowserWindow({
|
|
webPreferences: {
|
|
nodeIntegration: true,
|
|
contextIsolation: false,
|
|
enableRemoteModule: true
|
|
},
|
|
width: 1920,
|
|
height: 1080,
|
|
transparent: true,
|
|
frame: false,
|
|
alwaysOnTop: true,
|
|
skipTaskbar: false,
|
|
autoHideMenuBar: true,
|
|
title: 'Instant Replay Viewer',
|
|
fullscreenable: true,
|
|
focusable: false // Prevent stealing focus from games
|
|
});
|
|
|
|
mainWindow.loadFile('renderer.html');
|
|
|
|
mainWindow.webContents.on('did-finish-load', () => {
|
|
console.log('Electron renderer loaded and connected.');
|
|
// mainWindow.webContents.openDevTools(); // Always open DevTools for debugging
|
|
});
|
|
|
|
// Listen for log messages from renderer
|
|
ipcMain.on('ui-log', (event, { level, args }) => {
|
|
if (Array.isArray(args)) {
|
|
console[level]('[UI]', ...args);
|
|
} else {
|
|
console[level]('[UI]', args);
|
|
}
|
|
});
|
|
|
|
// Make window click-through by default
|
|
mainWindow.setIgnoreMouseEvents(true, { forward: true });
|
|
|
|
// Ensure window stays above fullscreen games (like Valorant)
|
|
mainWindow.setAlwaysOnTop(true, 'screen-saver');
|
|
}
|
|
|
|
app.whenReady().then(createWindow);
|
|
|
|
app.on('window-all-closed', () => {
|
|
if (process.platform !== 'darwin') {
|
|
app.quit();
|
|
}
|
|
});
|
|
|
|
app.on('activate', () => {
|
|
if (BrowserWindow.getAllWindows().length === 0) {
|
|
createWindow();
|
|
}
|
|
});
|