forked from PhoenicisOrg/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
53 lines (46 loc) · 1.61 KB
/
script.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
const Wine = include("engines.wine.engine.object");
include("engines.wine.plugins.regedit");
/**
* setting to set always offscreen
*/
// eslint-disable-next-line no-unused-vars
module.default = class AlwaysOffscreenSetting {
constructor() {
this.options = [tr("Default"), tr("Disabled"), tr("Enabled")];
// values which are written into the registry, do not translate!
this.registryValues = ["", "disabled", "enabled"];
}
getText() {
return tr("Always offscreen");
}
getOptions() {
return this.options;
}
getCurrentOption(container) {
const currentValue = new Wine()
.prefix(container)
.regedit()
.fetchValue(["HKEY_CURRENT_USER", "Software", "Wine", "Direct3D", "AlwaysOffscreen"]);
// find matching option (use default if not found)
const index = Math.max(this.registryValues.indexOf(currentValue), 0);
return this.options[index];
}
setOption(container, optionIndex) {
if (0 == optionIndex) {
new Wine()
.prefix(container)
.regedit()
.deleteValue("HKEY_CURRENT_USER\\Software\\Wine\\Direct3D", "AlwaysOffscreen");
} else {
const regeditFileContent =
"REGEDIT4\n" +
"\n" +
"[HKEY_CURRENT_USER\\Software\\Wine\\Direct3D]\n" +
"\"AlwaysOffscreen\"=\"" + this.registryValues[optionIndex] + "\"\n";
new Wine()
.prefix(container)
.regedit()
.patch(regeditFileContent);
}
}
}