forked from nommiin/builder
-
Notifications
You must be signed in to change notification settings - Fork 6
/
BuilderProjectProperties.js
82 lines (74 loc) · 2.31 KB
/
BuilderProjectProperties.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
class BuilderProjectProperties {
static build(project, target) {
const Preferences = $gmedit["ui.Preferences"];
let group = Preferences.addGroup(target, "builder Settings");
const defaultVersion = "<default>";
//
let ensureJSON = (isDefault) => {
let properties = project.properties;
let json = properties.builderSettings;
if (isDefault && json == null) return null;
if (json == null) json = properties.builderSettings = {};
return json;
};
let json = project.properties.builderSettings;
const ProjectProperties = $gmedit["ui.project.ProjectProperties"];
//
let versions = [defaultVersion];
for (let [_, set] of Object.entries(BuilderPreferences.current.runtimeSettings)) {
versions = versions.concat(set.runtimeList);
}
Preferences.addDropdown(group,
"Version override",
json?.runtimeVersion ?? defaultVersion,
versions,
(v) => {
if (v == defaultVersion) v = null;
let json = ensureJSON(v == null);
if (json == null) return;
json.runtimeVersion = v;
ProjectProperties.save(project, project.properties);
});
//
let extraArgsField = Preferences.addInput(group,
"Additional runner arguments",
json?.forkArguments ?? "",
(v) => {
if (v == "") v = null;
let json = ensureJSON(v == null);
if (json == null) return;
json.extraArguments = v;
ProjectProperties.save(project, project.properties);
}).querySelector("input");
//
let forkArgsField = Preferences.addInput(group,
"Fork arguments override",
json?.forkArguments ?? "",
(v) => {
if (v == "") v = null;
let json = ensureJSON(v == null);
if (json == null) return;
json.forkArguments = v;
ProjectProperties.save(project, project.properties);
}).querySelector("input");
forkArgsField.placeholder = BuilderPreferences.current.forkArguments;
//
let steamAppIdEl = Preferences.addInput(group,
"Steam App ID override",
json?.steamAppID ?? "",
(v) => {
v = parseInt(v);
if (isNaN(v)) v = null;
let json = ensureJSON(v == null);
if (json == null) return;
json.steamAppID = v;
ProjectProperties.save(project, project.properties);
});
steamAppIdEl.querySelector("input").placeholder = "0 to disable, blank to auto-detect";
}
static ready() {
GMEdit.on("projectPropertiesBuilt", (e) => {
this.build(e.project, e.target);
});
}
}