-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
82 lines (71 loc) · 1.96 KB
/
main.js
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
const { app, BrowserWindow, Menu } = require('electron');
if (require('electron-squirrel-startup')) return app.quit();
const path = require('path');
const template = [
{
label: app.name,
submenu: [
{
label: 'New Game',
submenu: [
{
label: 'No agent',
click: _ => createWindow('[false, false]'),
accelerator: process.platform === 'darwin' ? 'Cmd+Shift+H' : 'Alt+Shift+H',
type: 'radio',
checked: true
},
{
label: 'Human first',
click: _ => createWindow('[false, true]'),
accelerator: process.platform === 'darwin' ? 'Cmd+H' : 'Alt+H',
type: 'radio',
},
{
label: 'Agent first',
click: _ => createWindow('[true, false]'),
accelerator: process.platform === 'darwin' ? 'Cmd+A' : 'Alt+A',
type: 'radio',
},
{
label: 'No human',
click: _ => createWindow('[true, true]'),
accelerator: process.platform === 'darwin' ? 'Cmd+Shift+A' : 'Alt+Shift+A',
type: 'radio',
},
]
},
{ role: 'quit' },
]
}
];
const menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);
var lastWin = null;
function createWindow(isAgent) {
const win = new BrowserWindow({
resizable: false,
fullscreenable: false,
width: 600,
height: 600,
useContentSize: true,
backgroundColor: 'burlywood',
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
additionalArguments: [isAgent],
nodeIntegrationInWorker: true
}
});
// win.webContents.openDevTools();
win.loadFile('index.html');
if (lastWin !== null) {
lastWin.close();
}
lastWin = win;
}
app.whenReady().then(() => {
createWindow('[false, false]');
})
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit();
})