diff options
author | 0neGal <mail@0negal.com> | 2024-12-20 13:09:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-20 13:09:12 +0100 |
commit | 28130f46eb9c167671994b47b77b926386002ac2 (patch) | |
tree | 26185cbcba747df98e6de6d7e225777093c6720c /src/app/js | |
parent | 8fddf38701f50015ee8f61ce7bc8978f1dcebfd3 (diff) | |
parent | b9c0243d6433550784116fac7eec462cc5ae2a79 (diff) | |
download | Viper-28130f46eb9c167671994b47b77b926386002ac2.tar.gz Viper-28130f46eb9c167671994b47b77b926386002ac2.zip |
Merge pull request #248 from Jan200101/PR/protocol
feat: support thunderstore ror2mm protocol for installing mods
Diffstat (limited to 'src/app/js')
-rw-r--r-- | src/app/js/browser.js | 5 | ||||
-rw-r--r-- | src/app/js/mods.js | 40 | ||||
-rw-r--r-- | src/app/js/toasts.js | 4 |
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 } |