1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-06-13 13:04:03 +00:00

Fix loading order

This commit is contained in:
Exund 2020-09-12 00:49:36 +02:00
parent b87b642627
commit 7261bddf4c
3 changed files with 27 additions and 14 deletions

View File

@ -160,12 +160,16 @@ export async function initMods() {
}
for (const url of external_mods) {
let temp = await fetch(url);
const text = await temp.text();
const mod = /** @type {Mod} */ (eval(text));
try {
let temp = await fetch(url);
const text = await temp.text();
const mod = /** @type {Mod} */ (eval(text));
if (mod.name) {
Mods.push(mod);
if (mod.name) {
Mods.push(mod);
}
} catch {
logger.log(`🛑 Failed to load mod at : ${url}`)
}
}

View File

@ -55,13 +55,4 @@ function bootApp() {
app.boot();
}
(async () => {
await initMods();
initDrawUtils();
initComponentRegistry();
initItemRegistry();
initMetaBuildingRegistry();
initGameSpeedRegistry();
})();
window.addEventListener("load", bootApp);

View File

@ -8,6 +8,12 @@ import { HUDModalDialogs } from "../game/hud/parts/modal_dialogs";
import { CHANGELOG } from "../changelog";
import { globalConfig } from "../core/config";
import { initComponentRegistry } from "../game/component_registry";
import { initDrawUtils } from "../core/draw_utils";
import { initItemRegistry } from "../game/item_registry";
import { initMetaBuildingRegistry } from "../game/meta_building_registry";
import { initGameSpeedRegistry } from "../game/game_speed_registry";
const logger = createLogger("state/preload");
export class PreloadState extends GameState {
@ -108,6 +114,18 @@ export class PreloadState extends GameState {
return this.app.settings.initialize();
})
.then(() => this.setStatus("Loading GeoZ mods"))
.then(() => require("../GeoZ/main").initMods())
.then(() => this.setStatus("Initializing registeries"))
.then(() => {
initDrawUtils();
initComponentRegistry();
initItemRegistry();
initMetaBuildingRegistry();
initGameSpeedRegistry();
})
.then(() => {
// Initialize fullscreen
if (this.app.platformWrapper.getSupportsFullscreen()) {