Repository navigation
Expand file tree
/
Copy pathPolyTypes.js
More file actions
164 lines (161 loc) · 5.19 KB
/
Copy pathPolyTypes.js
File metadata and controls
164 lines (161 loc) · 5.19 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*
This file is part of PolyModLoader
Copyright (C) 2026 the polytrackmods team
PolyModLoader is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
PolyModLoader is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with PolyModLoader. If not, see https://www.gnu.org/licenses/.
*/
;
/**
* Base class for all polytrack mods. Mods should export an instance of their mod class named `polyMod` in their main file.
*/
export class PolyMod {
constructor() {
this.loaded = false;
/**
* Function to run during initialization of mods. Note that this is called *before* polytrack itself is loaded,
* but *after* everything has been declared.
*
* @param pmlInstance - The instance of {@link PolyModLoader}.
*/
this.init = (pmlInstance) => { };
/**
* Function to run after all mods and polytrack have been initialized and loaded.
*/
this.postInit = () => { };
/**
* Function to run once game finishses loading.
*/
this.onGameLoad = () => { };
/**
* Gets ran when the error bundle is loaded
*/
this.errorInit = (pml) => { };
/**
* Function to run just after import, before anything else.
*
* @param pmlInstance - The instance of {@link PolyModLoader}.
*/
this.preInit = (pmlInstance) => { };
/**
* Whether the mod
*/
this.offlineMode = false;
}
/**
* The the mod's icon file URL.
*/
get iconSrc() {
return this.IconSrc;
}
set iconSrc(src) {
this.IconSrc = src;
}
set setLoaded(status) {
this.loaded = status;
}
/**
* The mod's loaded state.
*/
get isLoaded() {
return this.loaded;
}
/**
* The mod's base URL.
*/
get baseUrl() {
return this.modBaseUrl;
}
set baseUrl(url) {
this.modBaseUrl = url;
}
/**
* Whether the mod is saved as to always fetch latest version (`true`)
* or to fetch a specific version (`false`, with version defined by {@link PolyMod.modVersion}).
*/
get savedLatest() {
return this.latestSaved;
}
set savedLatest(latest) {
this.latestSaved = latest;
}
get initialized() {
return this.modInitialized;
}
set initialized(initState) {
this.modInitialized = initState;
}
}
/**
* This class is used in {@link PolyModLoader}'s register mixin functions to set where functions should be injected into the target function.
*/
export var MixinType;
(function (MixinType) {
/**
* Inject at the start of the target function.
*/
MixinType[MixinType["HEAD"] = 0] = "HEAD";
/**
* Inject at the end of the target function.
*/
MixinType[MixinType["TAIL"] = 1] = "TAIL";
/**
* Override the target function with the new function.
*/
MixinType[MixinType["OVERRIDE"] = 2] = "OVERRIDE";
/**
* Insert code after a given token.
*/
MixinType[MixinType["INSERT"] = 3] = "INSERT";
/**
* Replace code between 2 given tokens. Inclusive.
*/
MixinType[MixinType["REPLACEBETWEEN"] = 5] = "REPLACEBETWEEN";
/**
* Remove code between 2 given tokens. Inclusive.
*/
MixinType[MixinType["REMOVEBETWEEN"] = 6] = "REMOVEBETWEEN";
/**
* Inserts code after a given token, but class wide.
*/
MixinType[MixinType["CLASSINSERT"] = 8] = "CLASSINSERT";
/**
* Replace code between 2 given tokens, but class wide. Inclusive.
*/
MixinType[MixinType["CLASSREMOVE"] = 4] = "CLASSREMOVE";
/**
* Remove code between 2 given tokens, but class wide. Inclusive.
*/
MixinType[MixinType["CLASSREPLACE"] = 7] = "CLASSREPLACE";
})(MixinType || (MixinType = {}));
/**
* Selects how a {@link PhysicsMixinArgs} patch interprets and overwrites a
* constant in the physics WASM binary.
*/
export var PhysicsMixinType;
(function (PhysicsMixinType) {
/**
* Overwrite a 32-bit float (`f32.const`, opcode `0x43`) constant.
* The 4-byte IEEE-754 operand following the opcode is replaced in place.
*/
PhysicsMixinType[PhysicsMixinType["PATCH_F32"] = 0] = "PATCH_F32";
/**
* Overwrite a 32-bit signed integer (`i32.const`, opcode `0x41`) constant.
* The operand is signed-LEB128 encoded; the new value must encode to the
* same number of bytes as the original, otherwise the patch is rejected.
*/
PhysicsMixinType[PhysicsMixinType["PATCH_I32"] = 1] = "PATCH_I32";
})(PhysicsMixinType || (PhysicsMixinType = {}));
export var SettingType;
(function (SettingType) {
SettingType["BOOL"] = "boolean";
SettingType["SLIDER"] = "slider";
SettingType["CUSTOM"] = "custom";
})(SettingType || (SettingType = {}));