forked from boltgolt/boltobserv
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindow.js
More file actions
128 lines (104 loc) · 3.02 KB
/
window.js
File metadata and controls
128 lines (104 loc) · 3.02 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
const path = require("path")
const config = require("./loadconfig")()
const detectcfg = require("./detectcfg")
if (config.game.installCfg && !config.debug.terminalOnly) detectcfg.search()
module.exports = {
electron: false,
app: false,
gsi: false,
http: false,
socket: false,
win: false,
build: () => {
module.exports.electron = require("electron")
module.exports.app = module.exports.electron.app
if (config.window.disableGpu) {
console.info("GPU disabled by config option")
module.exports.app.disableHardwareAcceleration()
module.exports.app.commandLine.appendSwitch("disable-gpu")
}
module.exports.app.on("ready", module.exports.create)
},
create: () => {
let winConfig = {
width: config.window.defaultSize.width,
height: config.window.defaultSize.height,
fullscreen: config.window.fullscreen,
minHeight: 200,
minWidth: 200,
frame: false,
resizable: true,
hasShadow: false,
enableLargerThanScreen: true,
darkTheme: true,
title: "Boltobserv",
icon: path.join(__dirname, "img/icon-64x64.png"),
webPreferences: {
nodeIntegration: true,
webaudio: false,
webgl: false,
backgroundThrottling: false,
allowEval: false
}
}
if (config.window.defaultSize.top >= 0 || config.window.defaultSize.left >= 0) {
winConfig.x = Math.max(0, config.window.defaultSize.left)
winConfig.y = Math.max(0, config.window.defaultSize.top)
}
if (config.window.transparent) {
winConfig.transparent = true
}
else {
winConfig.backgroundColor = "#000"
}
if (config.window.disable) {
winConfig.width = 450
winConfig.height = 200
winConfig.fullscreen = false
winConfig.resizable = false
}
win = new module.exports.electron.BrowserWindow(winConfig)
module.exports.win = win
if (config.window.alwaysOnTop) {
win.setAlwaysOnTop(true, "screen")
}
if (config.window.mousePassthrough) {
win.setIgnoreMouseEvents(true)
}
if (config.window.fullscreen) {
win.setFullScreen(true)
}
win.on("closed", () => {
module.exports.gsi.kill()
module.exports.http.kill()
module.exports.socket.kill()
module.exports.app.quit()
})
if (config.window.disable) {
win.loadFile("html/status.html")
}
else {
win.loadFile("html/waiting.html")
}
module.exports.electron.ipcMain.on("reqInstall", (event) => {
event.sender.send("cfgInstall", detectcfg.found)
})
module.exports.electron.ipcMain.on("install", (event, path) => {
detectcfg.install(path)
})
// Capture file requests and redirect them to on-disk paths
module.exports.electron.protocol.interceptFileProtocol("file", (request, callback) => {
let loc = request.url.substr(5)
// Remove drive letter on windows
loc = loc.replace(/\w:\//, "")
if (request.url.match(/^.*?\/html\/\w*?.html/)) {
loc = request.url.replace(/^.*?\/html\/(\w*?).html/, "html/$1.html")
}
callback({
path: path.normalize(path.join(__dirname, loc))
})
})
// Load key-binds and start listening
require("./keybinds")(module.exports.socket, module.exports.win)
}
}