mirror of
https://github.com/eaglerforge/EaglerForgeInjector
synced 2025-07-23 06:01:38 -09:00
Finish patches registry
This commit is contained in:
parent
0321c07978
commit
134967456c
@ -175,6 +175,7 @@
|
||||
`;
|
||||
var freezeCallstack = `if(ModAPI.hooks.freezeCallstack){return false};`;
|
||||
</script>
|
||||
<script src="patches.js"></script>
|
||||
<script src="injector.minify.js"></script>
|
||||
<script src="injector.js"></script>
|
||||
|
||||
|
@ -276,6 +276,7 @@ var main;(function(){`
|
||||
patchedFile = patchedFile.replace(
|
||||
` id="game_frame">`,
|
||||
` id="game_frame">
|
||||
\<script id="modapi_patchesreg_events"\>${PatchesRegistry.getEventInjectorCode()}\`;\<\/script\>
|
||||
\<script id="modapi_postinit"\>${globalThis.modapi_postinit}\<\/script\>
|
||||
\<script id="modapi_postinitasync"\>${globalThis.modapi_postinitasync}\<\/script\>
|
||||
\<script id="modapi_modloader"\>${globalThis.modapi_modloader}\<\/script\>
|
||||
@ -286,6 +287,11 @@ var main;(function(){`
|
||||
patchedFile = patchedFile.replaceAll(/main\(\);\s*?}/gm, (match) => {
|
||||
return match.replace("main();", "main();ModAPI.hooks._postInit();");
|
||||
});
|
||||
|
||||
_status("Applying bonus patches from patch registry...");
|
||||
await wait(50);
|
||||
patchedFile = PatchesRegistry.patchFile(patchedFile);
|
||||
|
||||
_status("Done, awaiting input...");
|
||||
await wait(50);
|
||||
return patchedFile;
|
||||
|
@ -4,6 +4,13 @@ class PatchesRegistry {
|
||||
static getEventInjectorCode() {
|
||||
return "globalThis.modapi_specialevents = [" + PatchesRegistry.patchedEventNames.flatMap(x=>`\`${x}\``).join(",") + "]"
|
||||
}
|
||||
static patchFile(x) {
|
||||
var current = x;
|
||||
PatchesRegistry.patchFns.forEach(fn => {
|
||||
current = fn(current);
|
||||
});
|
||||
return current;
|
||||
}
|
||||
static addPatch(fn) {
|
||||
PatchesRegistry.patchFns.push(fn);
|
||||
}
|
||||
|
@ -859,4 +859,10 @@ globalThis.modapi_postinit = "(" + (() => {
|
||||
return originalMainMethod.apply(this, args);
|
||||
}
|
||||
}
|
||||
|
||||
if (globalThis.modapi_specialevents && Array.isArray(globalThis.modapi_specialevents)) {
|
||||
globalThis.modapi_specialevents.forEach(eventName => {
|
||||
ModAPI.events.newEvent(eventName, "patcher");
|
||||
});
|
||||
}
|
||||
}).toString() + ")();";
|
||||
|
Loading…
x
Reference in New Issue
Block a user