diff --git a/src/js/main.js b/src/js/main.js index 5e9e1006..f40d902f 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -102,15 +102,20 @@ window.onload = async () => { } else if (!G_IS_DEV) { user = JSON.parse(localStorage.getItem("user")); instance = JSON.parse(localStorage.getItem("instance")); - // instance = { - // mods: [{ - // url: "http://mods.thomasbrants.nl/static/mods/b89404ac-7cbc-45bf-81b7-7d4d8108faf0/1.0.0.js", - // id: "b89404ac-7cbc-45bf-81b7-7d4d8108faf0", - // config: {}, - // settings: {}, - // }, ], - // }; } + // else { + // instance = { + // mods: [ + // { + // url: + // "http://mods.thomasbrants.nl/static/mods/a18121cf-fc7c-4f23-906d-b7ab0512bbc8/1.0.0.js", + // id: "a18121cf-fc7c-4f23-906d-b7ab0512bbc8", + // config: {}, + // settings: {}, + // }, + // ], + // }; + // } var modMgr = new ModManager(user, instance); addVanillaBuildingsToAPI(); addVanillaComponentsToAPI(); @@ -124,7 +129,8 @@ window.onload = async () => { if (mod.split(".").pop() !== "js") continue; modMgr.addMod(mod, true); } - } else if (modMgr.modPack) await modMgr.addModPackMods(); + } + if (modMgr.modPack) await modMgr.addModPackMods(); modMgr.loadMods(); initDrawUtils(); @@ -133,12 +139,9 @@ window.onload = async () => { initMetaBuildingRegistry(); initGameSpeedRegistry(); - let app = null; - function bootApp() { logger.log("Page Loaded"); - app = new Application(); - app.boot(); + new Application().boot(); } bootApp(); }; diff --git a/src/js/modloader/mod.js b/src/js/modloader/mod.js index ba86b8a6..4ea14863 100644 --- a/src/js/modloader/mod.js +++ b/src/js/modloader/mod.js @@ -789,6 +789,9 @@ export class ShapezAPI { PreloadState, MobileWarningState, + //Hub goals + HubGoals, + //Systems ItemAcceptorSystem, BeltSystem, @@ -870,14 +873,11 @@ export class ShapezAPI { buildings: {}, components: {}, hudParts: {}, - //Must be array because of update order - systems: [], + systems: [], //Must be array because of update order items: {}, gamemodes: {}, gamespeed: {}, - //List of layer names - layers: [], - hub_goals: HubGoals, + layers: [], //List of layer names }; this.toolbars = { @@ -986,8 +986,8 @@ export class ShapezAPI { */ registerIcon(id, iconDataURL) { var css = ``; - var style = undefined; - if (!(style = document.getElementById("mod-loader-icons"))) { + var style = document.getElementById("mod-loader-icons"); + if (!style) { var head = document.head || document.getElementsByTagName("head")[0]; style = document.createElement("style"); style.id = "mod-loader-icons"; @@ -1008,19 +1008,4 @@ export class ShapezAPI { this.registerIcon("building_icons/" + id, iconDataURL); this.KEYMAPPINGS.buildings[id] = { keyCode: this.KEYMAPPINGS.key(key), id: id }; } - - /** - * Tracks clicks on a element (e.g. button). Useful because you should both support - * touch and mouse events. - * @param {HTMLElement} element - * @param {function} clickHandler - */ - trackClicks(element, clickHandler) { - const clickDetector = new ClickDetector(element, { - consumeEvents: true, - preventDefault: true, - }); - clickDetector.click.add(clickHandler); - this.clickDetectors.push(clickDetector); - } } diff --git a/src/js/modloader/modmanager.js b/src/js/modloader/modmanager.js index cf2c06b7..a107af8b 100644 --- a/src/js/modloader/modmanager.js +++ b/src/js/modloader/modmanager.js @@ -166,9 +166,11 @@ export class ModManager { let promise = Promise.resolve(null); for (let i = 0; i < this.modPack.mods.length; i++) { - promise = promise.then(() => { - return this.addMod(this.modPack.mods[i].url); - }); + if (this.modPack.mods[i].url) { + promise = promise.then(() => { + return this.addMod(this.modPack.mods[i].url); + }); + } } return promise; }