This repository has been archived by the owner on Aug 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
106 lines (89 loc) · 2.32 KB
/
app.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
const { shell, ipcMain, electron, dialog, app, BrowserWindow, globalShortcut } = require('electron');
let mainWindow
let revealWindow
function createMainWindows() {
mainWindow = new BrowserWindow({
width: 800,
height: 600,
//frame: false,
draggable: true,
show: false,
webPreferences: {
nodeIntegration: true,
plugins: true
}
});
mainWindow.loadFile('gamemaster.html');
mainWindow.on('closed', () => {
mainWindow = null;
app.quit();
});
mainWindow.once('ready-to-show', () => {
mainWindow.show()
});
revealWindow = new BrowserWindow({
width: 800,
height: 600,
//frame: false,
//fullscreen: true,
show: false,
draggable: true,
webPreferences: {
nodeIntegration: true,
plugins: true,
parent: mainWindow,
}
})
revealWindow.loadFile('players.html');
revealWindow.on('closed', () => {
revealWindow = null;
app.quit();
});
revealWindow.on('ready-to-show', () => {
revealWindow.show();
});
}
function openFile() {
var result = dialog.showOpenDialog(mainWindow, {
properties: ['openFile'],
title: 'Open Map',
filters: [
{ name: 'Images', extensions: ['jpg', 'jpeg', 'png', 'gif'] },
//{ name: 'PDF', extensions: ['pdf'] }
]
});
if(result) {
mainWindow.webContents.send('OPEN_MAP', result);
revealWindow.webContents.send('OPEN_MAP', result);
}
}
function prepareApp() {
app.on('ready', createMainWindows);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit()
});
app.on('activate', () => {
if (win === null) {
createMainWindows()
}
});
ipcMain.on('OPEN_FILE_BTN_CLICK', (event) => {
openFile();
});
ipcMain.on('SCALE_PLAYER_IMAGE', (event, resolution) => {
revealWindow.webContents.send('SCALE_PLAYER_IMAGE', resolution);
});
ipcMain.on('OPEN_MAP', (event, filePath) => {
revealWindow.webContents.send('OPEN_MAP', filePath);
});
app.on('ready', () => {
globalShortcut.register('CommandOrControl+Shift+R', () => {
revealWindow.reload();
mainWindow.reload();
})
})
}
(async () => {
await prepareApp();
app.emit('start');
})();