mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-14 02:31:51 +00:00
Merge branch 'modloader' of github.com:tobspr/shapez.io into modloader
This commit is contained in:
commit
a4df63549b
@ -351,21 +351,10 @@ ipcMain.handle("get-mods", async () => {
|
|||||||
buttons: ["Exit Game", "Continue"],
|
buttons: ["Exit Game", "Continue"],
|
||||||
type: "warning",
|
type: "warning",
|
||||||
defaultId: 0,
|
defaultId: 0,
|
||||||
|
|
||||||
checkboxLabel:
|
|
||||||
"I understand that mods have access to my file system and can be potentially harmful",
|
|
||||||
checkboxChecked: false,
|
|
||||||
cancelId: 0,
|
cancelId: 0,
|
||||||
});
|
});
|
||||||
if (response.response === 1) {
|
if (response.response === 1) {
|
||||||
if (response.checkboxChecked) {
|
break;
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
await dialog.showMessageBox(win, {
|
|
||||||
message:
|
|
||||||
"Please confirm that you have understood the risks by checking the checkbox in the next dialog.",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (response.response === 0) {
|
if (response.response === 0) {
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
|
|||||||
@ -93,19 +93,29 @@ export class ModLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mods.forEach(modCode => {
|
mods.forEach(modCode => {
|
||||||
const func = new Function(modCode);
|
try {
|
||||||
func();
|
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) {
|
} catch (ex) {
|
||||||
alert("Failed to load mods: " + ex);
|
alert("Failed to load mods (launch with --dev for more info): " + ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
this.modLoadQueue.forEach(modClass => {
|
this.modLoadQueue.forEach(modClass => {
|
||||||
const mod = new (modClass())(this.app, this);
|
try {
|
||||||
mod.init();
|
const mod = new (modClass())(this.app, this);
|
||||||
this.mods.push(mod);
|
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.modLoadQueue = [];
|
||||||
this.signals.postInit.dispatch();
|
this.signals.postInit.dispatch();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user