aboutsummaryrefslogtreecommitdiff
path: root/src/app/js/mods.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/js/mods.js')
-rw-r--r--src/app/js/mods.js56
1 files changed, 55 insertions, 1 deletions
diff --git a/src/app/js/mods.js b/src/app/js/mods.js
index f463ddb..755aad1 100644
--- a/src/app/js/mods.js
+++ b/src/app/js/mods.js
@@ -1,8 +1,10 @@
+const util = require('util');
const ipcRenderer = require("electron").ipcRenderer;
const lang = require("../../lang");
const version = require("./version");
+const toasts = require("./toasts");
const set_buttons = require("./set_buttons");
let mods = {};
@@ -216,8 +218,22 @@ mods.remove = (mod) => {
}
mods.toggle = (mod) => {
+ // is this a core mod?
if (mod.toLowerCase().match(/^northstar\./)) {
- if (! confirm(lang("gui.mods.required_confirm"))) {
+ // keep track of whether this mod is disabled
+ let is_disabled = false;
+
+ // run through disabled mods
+ for (let mod_obj of mods_list.disabled) {
+ // if `mod` is `mod_obj`, update `is_disabled`
+ if (mod_obj.name.toLowerCase() == mod.toLowerCase()) {
+ is_disabled = true;
+ break;
+ }
+ }
+
+ // show prompt if the mod is enabled
+ if (! is_disabled && ! confirm(lang("gui.mods.required_confirm"))) {
return;
}
} else if (mod == "allmods") {
@@ -328,4 +344,42 @@ ipcRenderer.on("mods", (event, mods_obj) => {
mods.load(mods_obj);
})
+ipcRenderer.on("protocol-install-mod", async (event, data) => {
+ const domain = data[0];
+ const author = data[1];
+ const package_name = data[2];
+ const version = data[3];
+
+ const packages = await browser.packages();
+
+ const package = packages.find((package) => { return package.owner == author && package.name == package_name; })
+ if (!package) {
+ alert(util.format(lang("gui.mods.cant_find_specific"), author, package_name));
+ return;
+ }
+
+ const package_obj = package.versions.find((package_version) => { return package_version.version_number == version; })
+ if (!package_obj) {
+ alert(util.format(lang("gui.mods.cant_find_version"), version, author, package_name))
+ return;
+ }
+
+ toasts.show({
+ timeout: 3000,
+ scheme: "info",
+ title: lang("gui.mods.installing"),
+ description: package_obj.full_name
+ })
+
+ mods.install_from_url(
+ package_obj.download_url,
+ package_obj.dependencies,
+ false,
+
+ author,
+ package_name,
+ version
+ );
+})
+
module.exports = mods;