-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
103 lines (81 loc) · 2.44 KB
/
Copy pathmain.js
File metadata and controls
103 lines (81 loc) · 2.44 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
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
const electron = require('electron');
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
const exePath = app.getPath('exe');
let devExeFileIndex = exePath.indexOf('electron.exe');
let buildedExeFileIndex = exePath.indexOf('SmokerStopper.exe');
let exeDir = '';
if (buildedExeFileIndex !== -1) {
/* run in builded mode */
exeDir = exePath.slice(0,buildedExeFileIndex);
} else {
/* run in dev mode */
exeDir = exePath.slice(0,devExeFileIndex);
}
const windowStateKeeper = require('electron-window-state');
const path = require('path');
const fse = require('fs-extra');
let mainWindow;
function createWindow () {
let mainWindowState = windowStateKeeper({
defaultWidth: 600,
defaultHeight: 600
});
mainWindow = new BrowserWindow({
'x': mainWindowState.x,
'y': mainWindowState.y,
'width': mainWindowState.width,
'height': mainWindowState.height,
title: 'SmokerStopper',
icon: __dirname + '/build/icons/smokerstopper.png',
webPreferences: {
plugins: true
}
});
mainWindowState.manage(mainWindow);
mainWindow.loadURL('file://' + __dirname + '/app/index.html');
mainWindow.setMenu(null);
mainWindow.setMinimumSize(599, 599);
// Open the DevTools.
/* mainWindow.webContents.openDevTools(); */
mainWindow.on('closed', function () {
mainWindowState.saveState(mainWindow);
mainWindow = null;
});
}
app.on('ready', createWindow);
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', function () {
if (mainWindow === null) {
createWindow();
}
});
const checkExistsFunc = (src, dest) => {
// it will be copied if return true
return !fse.pathExistsSync(dest);
};
fse.copySync(
path.join(__dirname, 'app/assets/flashgames/pepflashplayer.dll'),
path.join(exeDir, 'pepflashplayer.dll'),
{ filter: checkExistsFunc }
);
// Specify flash path, supposing it is placed in the same directory with main.js.
let pluginPath;
switch (process.platform) {
case 'win32':
pluginPath = path.join(exeDir, 'pepflashplayer.dll');
break
case 'darwin':
pluginPath = path.join(exeDir, 'PepperFlashPlayer.plugin');
break
case 'linux':
pluginPath = path.join(exeDir, 'libpepflashplayer.so');
break
}
app.commandLine.appendSwitch('ppapi-flash-path', pluginPath);
// Optional: Specify flash version, for example, v17.0.0.169
app.commandLine.appendSwitch('ppapi-flash-version', '32.0.0.101');