-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
109 lines (88 loc) · 2.91 KB
/
index.js
File metadata and controls
109 lines (88 loc) · 2.91 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
104
105
106
107
108
109
const {app, BrowserWindow, ipcMain, dialog} = require('electron');
const path = require('path');
var pjson = require('./package.json');
function createWindow() {
ipcMain.handle('getUserDataPath', (event) => {
const userDataPath = app.getPath('userData');
console.log(userDataPath)
return userDataPath;
});
ipcMain.on('open-folder-dialog', (event) => {
dialog
.showOpenDialog({properties: ['openDirectory']})
.then((result) => {
const selectedDirectory = result.filePaths[0];
event.sender.send('selected-folder', selectedDirectory);
})
.catch((err) => {
console.error(err);
});
});
const updateWindow = new BrowserWindow({
width: 300,
height: 400,
resizable: false,
fullscreenable: false,
frame: false,
movable: true,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
enableRemoteModule: true,
},
});
updateWindow.setIcon(path.join(__dirname, 'assets/game_logo/codlite_logo.png'));
updateWindow.setTitle('COD Launcher - Update');
updateWindow.loadFile(path.join(__dirname, 'templates/update.html'));
updateWindow.setMenu(null);
ipcMain.handle('startUpdatedGame', (event) => {
updateWindow.close();
launchMainWindow();
});
}
function launchMainWindow() {
const mainWindow = new BrowserWindow({
width: 1400,
height: 900,
resizable: false,
fullscreenable: false,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
enableRemoteModule: true,
},
});
mainWindow.setIcon(path.join(__dirname, 'assets/game_logo/codlite_logo.png'));
mainWindow.loadFile(path.join(__dirname, 'templates/index.html'));
mainWindow.setTitle('CODLite Launcher - v' + pjson.version);
/*mainWindow.setMenu(null);*/
}
app.whenReady().then(() => {
createWindow()
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
})
// Fonction pour ouvrir une nouvelle fenêtre
ipcMain.on('open-login-window', (event, arg) => {
const newWindow = new BrowserWindow({
width: 400,
height: 600,
resizable: false,
fullscreenable: false,
frame: false,
movable: true,
webPreferences: {
nodeIntegration: true
},
});
newWindow.setIcon(path.join(__dirname, 'assets/game_logo/codlite_logo.png'));
newWindow.loadFile('templates/login.html');
});
app.on('window-all-closed', async function () {
if (process.platform !== 'darwin') app.quit()
})
try {
require('electron-reloader')(module)
} catch (_) {
}