-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmain.js
More file actions
64 lines (49 loc) · 1.35 KB
/
main.js
File metadata and controls
64 lines (49 loc) · 1.35 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const electron = require('electron');
const { app } = electron;
if (require('electron-squirrel-startup')) (() => app.quit())();
const { BrowserWindow } = electron;
const launchWindows = require('./src/loading/windows.js');
const launchMain = launchWindows.mainWindow;
const launchLoading = launchWindows.loadingWindow;
const { openServer } = launchWindows;
let loadingRef = null;
/**
* Keep a reference to the main window
*/
let mainWindow;
const { ipcMain } = electron;
/**
* Set up the IPC manager
*/
require('./ipc.js')(ipcMain, BrowserWindow);
ipcMain.on('open-machinima-studio', () => {
launchMain(mainWindow, electron);
});
ipcMain.on('open-dev-tools', (event) => {
console.log('Opening dev tools');
loadingRef.webContents.openDevTools();
});
ipcMain.on('open-machinima-studio-server', (event) => {
openServer((err) => {
if (err) {
return event.sender.send('open-machinima-studio-server-error', err.message);
}
return event.sender.send('open-machinima-studio-server');
});
});
/**
* Launch the app when electron
* is ready to render and launch windows
*/
app.on('ready', () => {
loadingRef = launchLoading(mainWindow, electron);
});
/**
* Relaunch the app in case is needed
*/
app.on('activate', () => {
if (mainWindow === null) {
launchLoading(mainWindow, electron);
}
});
app.on('window-all-closed', app.quit);