-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
47 lines (42 loc) · 1.52 KB
/
Copy pathmain.js
File metadata and controls
47 lines (42 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const { app, BrowserWindow, ipcMain } = require("electron");
const Store = require("electron-store");
const store = new Store();
function createWindow () {
let screenSettings = { w: 1024, h: 896, fullscreen: false, zoom: 1 };
const lastScreenSettings = store.get("screenSettings", null);
if(lastScreenSettings !== null) {
screenSettings = lastScreenSettings;
}
const mainWindow = new BrowserWindow({
width: screenSettings.width,
height: screenSettings.height,
setFullScreen: screenSettings.fullscreen,
zoomFactor: screenSettings.zoom,
icon: "ff.png", // TODO: won't work on macs
autoHideMenuBar: true,
useContentSize: true,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
allowRunningInsecureContent: false
}
});
mainWindow.loadFile("indexapp.html");
//mainWindow.webContents.openDevTools();
ipcMain.on("resize-window", (e, args) => {
mainWindow.setFullScreen(args.fullscreen);
mainWindow.setContentSize(args.width, args.height);
mainWindow.webContents.zoomFactor = args.zoom;
store.set("screenSettings", args);
});
ipcMain.on("quit-game", () => { app.quit(); });
}
app.whenReady().then(() => {
createWindow();
app.on("activate", function () {
if(BrowserWindow.getAllWindows().length === 0) { createWindow(); }
});
});
app.on("window-all-closed", function () {
if(process.platform !== "darwin") { app.quit(); }
});