forked from dpwhittaker/RoC-Launcher
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
61 lines (51 loc) · 1.97 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
const {app, BrowserWindow, ipcMain, dialog} = require('electron');
const log = require('electron-log');
const {autoUpdater} = require('electron-updater');
const path = require('path');
const url = require('url');
log.transports.file.file = require('os').homedir() + '/Aftermath-Launcher-log.txt';
autoUpdater.logger = log;
autoUpdater.logger.transports.file.level = 'info';
log.info('App starting...');
let mainWindow;
function createWindow () {
mainWindow = new BrowserWindow({width: 1024, minWidth: 1024, height: 800, minHeight: 600, show: false, autoHideMenuBar: true, frame: false});
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
}));
if (require('electron-is-dev')) mainWindow.webContents.openDevTools();
mainWindow.once('ready-to-show', () => mainWindow.show());
mainWindow.once('closed', () => mainWindow = null);
}
app.on('ready', createWindow);
app.on('window-all-closed', () => app.quit());
ipcMain.on('open-directory-dialog', function (event, response) {
dialog.showOpenDialog({
properties: ['openDirectory']
}, function (files) {
if (files) event.sender.send(response, files[0])
});
});
ipcMain.on('open-profcalc', function() {
window = new BrowserWindow({width: 1296, height: 839, autoHideMenuBar: true});
window.loadURL(url.format({
pathname: path.join(__dirname, 'profcalc', 'index.html'),
protocol: 'file:',
slashes: true
}));
if (require('electron-is-dev')) window.webContents.openDevTools();
});
autoUpdater.on('update-downloaded', (info) => {
autoUpdater.quitAndInstall();
});
autoUpdater.on('download-progress', (progress) => {
mainWindow.webContents.send('download-progress', progress);
})
autoUpdater.on('update-available', info => {
mainWindow.webContents.send('downloading-update', 'Downloading version ' + info.version);
})
app.on('ready', function() {
autoUpdater.checkForUpdates();
});