aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'src/app')
-rw-r--r--src/app/js/browser.js5
-rw-r--r--src/app/js/mods.js40
-rw-r--r--src/app/js/toasts.js4
3 files changed, 49 insertions, 0 deletions
diff --git a/src/app/js/browser.js b/src/app/js/browser.js
index bd9506f..aaca6a8 100644
--- a/src/app/js/browser.js
+++ b/src/app/js/browser.js
@@ -475,6 +475,11 @@ browser.mod_el = (properties) => {
browserEntries.appendChild(entry);
}
+browser.packages = async () => {
+ await browser.loadfront();
+ return packages;
+}
+
let recent_toasts = {};
function add_recent_toast(name, timeout = 3000) {
if (recent_toasts[name]) {return}
diff --git a/src/app/js/mods.js b/src/app/js/mods.js
index f463ddb..2408548 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 = {};
@@ -328,4 +330,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;
diff --git a/src/app/js/toasts.js b/src/app/js/toasts.js
index bd9d03a..c5cdd40 100644
--- a/src/app/js/toasts.js
+++ b/src/app/js/toasts.js
@@ -24,6 +24,10 @@ toasts.show = (properties) => {
toast.fg = "#FFFFFF";
toast.bg = "#FF9B85";
break
+ case "info":
+ toast.fg = "#FFFFFF";
+ toast.bg = "rgb(var(--blue))";
+ break
}