-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
130 lines (111 loc) · 2.84 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
const electron = require('electron');
const app = electron.app;
const Menu = electron.Menu;
const BrowserWindow = electron.BrowserWindow;
const path = require('path');
const url = require('url');
let mainWindow;
let settingsWindow;
const openDevTools = () => mainWindow.webContents.openDevTools();
const createSettingsWindow = () => {
settingsWindow = new BrowserWindow({
parent: mainWindow,
modal: true,
show: false,
width: 500,
height: 340,
resizable: false,
});
settingsWindow.loadURL(url.format({
pathname: path.join(__dirname, 'src/settings.html'),
protocol: 'file:',
slashes: true,
}));
settingsWindow.once('ready-to-show', () => {
settingsWindow.show();
});
settingsWindow.on('closed', () => {
settingsWindow = null;
mainWindow.webContents.reload();
});
};
global.createSettingsWindow = createSettingsWindow;
const createGameWindow = () => {
const template = [
{
label: app.getName(),
submenu: [
{
label: 'Instellingen',
click: createSettingsWindow,
},
{ type: 'separator' },
{ role: 'hide', label: 'Verberg' },
{ role: 'unhide', label: 'Toon' },
{ type: 'separator' },
{ role: 'quit', label: 'Sluit' },
],
},
{
label: 'Wijzig',
submenu: [
{ role: 'undo', label: 'Herstel' },
{ role: 'redo', label: 'Opnieuw' },
{ type: 'separator' },
{ role: 'cut', label: 'Knip' },
{ role: 'copy', label: 'Kopieer' },
{ role: 'paste', labe: 'Plak' },
{ role: 'pasteandmatchstyle', label: 'Plak en pas stijl aan' },
{ role: 'delete', label: 'Verwijder' },
{ role: 'selectall', label: 'Selecteer alles' },
],
},
{
label: 'Weergave',
submenu: [
{ role: 'reload', label: 'Herlaad' },
{ role: 'forcereload', label: 'Forceer Herlaad' },
{ type: 'separator' },
{
label: 'Open Console',
click: openDevTools,
},
],
},
{
role: 'Help',
submenu: [
{
label: 'Learn More',
click() {
require('electron').shell.openExternal('https://electron.atom.io');
},
},
],
},
];
const menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);
mainWindow = new BrowserWindow({ width: 1920, height: 1080 });
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'src/index.html'),
protocol: 'file:',
slashes: true,
}));
// mainWindow.webContents.openDevTools()
mainWindow.on('closed', () => {
mainWindow = null;
});
};
app.on('ready', () => {
app.setName('ChopChop');
createGameWindow();
});
app.on('window-all-closed', () => {
app.quit();
});
app.on('activate', () => {
if (mainWindow === null) {
createGameWindow();
}
});