From 52de086f36e5b32643fa641e072c56d53a6d2bc1 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Mon, 16 May 2022 00:19:50 +0200 Subject: already installed dependencies are now skipped If you already have all the dependencies or some dependencies of a package those will be skipped, if there is no dependencies missing it'll just install, and otherwise it'll show the missing and ask whether you want to install them. Meaning if a package has two dependencies and you've one of them only the one you don't have will show up. --- src/app/main.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/app/main.js b/src/app/main.js index 109ca61..362450a 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -217,9 +217,12 @@ function installFromURL(url, dependencies, clearqueue) { let depend = dependencies[i].toLowerCase(); console.log(depend) if (! depend.match(/northstar-northstar-.*/)) { - newdepends.push(dependencies[i].replaceAll("-", "/")); - let pkg = newdepends[newdepends.length - 1].split("/"); - prettydepends.push(`${pkg[1]} v${pkg[2]} - ${lang("gui.browser.madeby")} ${pkg[0]}`); + depend = dependencies[i].replaceAll("-", "/"); + let pkg = depend.split("/"); + if (! isModInstalled(pkg[1])) { + newdepends.push(depend); + prettydepends.push(`${pkg[1]} v${pkg[2]} - ${lang("gui.browser.madeby")} ${pkg[0]}`); + } } } @@ -241,6 +244,21 @@ function installFromURL(url, dependencies, clearqueue) { } } +function isModInstalled(modname) { + for (let i = 0; i < modsobj.all.length; i++) { + let mod = modsobj.all[i]; + if (mod.ManifestName) { + if (mod.ManifestName.match(modname)) { + return true; + } + } else if (mod.Name.match(modname)) { + return true; + } + } + + return false; +} + // Frontend part of settings a new game path ipcRenderer.on("newpath", (event, newpath) => { settings.gamepath = newpath; -- cgit v1.2.3