diff --git a/src/js/GeoZ/main.js b/src/js/GeoZ/main.js index 754e1007..8e4069e2 100644 --- a/src/js/GeoZ/main.js +++ b/src/js/GeoZ/main.js @@ -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}`) } } diff --git a/src/js/main.js b/src/js/main.js index f30ce8b8..fd15f090 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -55,13 +55,4 @@ function bootApp() { app.boot(); } -(async () => { - await initMods(); - initDrawUtils(); - initComponentRegistry(); - initItemRegistry(); - initMetaBuildingRegistry(); - initGameSpeedRegistry(); -})(); - window.addEventListener("load", bootApp); \ No newline at end of file diff --git a/src/js/states/preload.js b/src/js/states/preload.js index 0f47e8d6..317c3bfd 100644 --- a/src/js/states/preload.js +++ b/src/js/states/preload.js @@ -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()) {