1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-13 18:21:51 +00:00

Merge branch 'modloader' of github.com:tobspr/shapez.io into modloader

This commit is contained in:
tobspr 2022-01-15 13:35:22 +01:00
commit a4df63549b
2 changed files with 17 additions and 18 deletions

View File

@ -351,21 +351,10 @@ ipcMain.handle("get-mods", async () => {
buttons: ["Exit Game", "Continue"],
type: "warning",
defaultId: 0,
checkboxLabel:
"I understand that mods have access to my file system and can be potentially harmful",
checkboxChecked: false,
cancelId: 0,
});
if (response.response === 1) {
if (response.checkboxChecked) {
break;
} else {
await dialog.showMessageBox(win, {
message:
"Please confirm that you have understood the risks by checking the checkbox in the next dialog.",
});
}
break;
}
if (response.response === 0) {
process.exit(0);

View File

@ -93,19 +93,29 @@ export class ModLoader {
}
mods.forEach(modCode => {
const func = new Function(modCode);
func();
try {
const func = new Function(modCode);
const response = func();
} catch (ex) {
console.error(ex);
alert("Failed to parse mod (launch with --dev for more info): " + ex);
}
});
} catch (ex) {
alert("Failed to load mods: " + ex);
alert("Failed to load mods (launch with --dev for more info): " + ex);
}
}
this.initialized = true;
this.modLoadQueue.forEach(modClass => {
const mod = new (modClass())(this.app, this);
mod.init();
this.mods.push(mod);
try {
const mod = new (modClass())(this.app, this);
mod.init();
this.mods.push(mod);
} catch (ex) {
console.error(ex);
alert("Failed to initialize mods (launch with --dev for more info): " + ex);
}
});
this.modLoadQueue = [];
this.signals.postInit.dispatch();