From 72f85aa2297f5c46d029f1e25193aa98ced884c3 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Thu, 12 May 2022 01:34:07 +0200 Subject: initial draft for supporting dependencies This should allow you to install packages that have dependencies, however maybe not with the best UI/UX experience, as currently there's only an English localization, and we also install dependencies even if the dependency is already installed. --- src/app/browser.js | 10 ++++++++-- src/app/main.js | 37 +++++++++++++++++++++++++++++++++++-- src/lang/en.json | 1 + src/utils.js | 8 -------- 4 files changed, 44 insertions(+), 12 deletions(-) diff --git a/src/app/browser.js b/src/app/browser.js index e22ab3c..5c943ba 100644 --- a/src/app/browser.js +++ b/src/app/browser.js @@ -171,7 +171,8 @@ function BrowserElFromObj(obj) { download: pkg.download_url, version: pkg.version_number, categories: pkg.categories, - description: pkg.description + description: pkg.description, + dependencies: pkg.dependencies, }) } @@ -240,7 +241,7 @@ function BrowserEl(properties) {
${properties.title}
${properties.description}
- + @@ -285,6 +286,11 @@ ipcRenderer.on("installedmod", (event, mod) => { title: lang("gui.toast.title.installed"), description: mod.name + " " + lang("gui.toast.desc.installed") }) + + if (installqueue.length != 0) { + installFromURL("https://thunderstore.io/package/download/" + installqueue[0]); + installqueue.shift(); + } }) function normalize(items) { diff --git a/src/app/main.js b/src/app/main.js index 95b6f4c..109ca61 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -190,6 +190,8 @@ function selected(all) { } } +let installqueue = []; + // Tells the main process to install a mod through the file selector function installmod() { setButtons(false); @@ -203,9 +205,40 @@ function installFromPath(path) { } // Tells the main process to install a mod from a URL -function installFromURL(url) { +function installFromURL(url, dependencies, clearqueue) { + if (clearqueue) {installqueue = []}; + console.log(installqueue) + + let prettydepends = []; + + if (dependencies) { + let newdepends = []; + for (let i = 0; i < dependencies.length; i++) { + 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]}`); + } + } + + dependencies = newdepends; + } + + if (dependencies && dependencies.length != 0) { + let confirminstall = confirm(lang("gui.mods.confirmdependencies") + prettydepends.join("\n")); + if (! confirminstall) { + return + } + } + setButtons(false); - ipcRenderer.send("installfromurl", url) + ipcRenderer.send("installfromurl", url, dependencies) + + if (dependencies) { + installqueue = dependencies; + } } // Frontend part of settings a new game path diff --git a/src/lang/en.json b/src/lang/en.json index ee932a2..024b44a 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -68,6 +68,7 @@ "gui.mods.installing": "Installing mod...", "gui.mods.installedmod": "Installed mod!", "gui.mods.dragdrop": "Drag and drop a mod to install", + "gui.mods.confirmdependencies": "This package has dependencies, shown below, clicking \"Ok\" will install the package and the dependencies.\n\n", "gui.browser.info": "Info", "gui.browser.madeby": "by", diff --git a/src/utils.js b/src/utils.js index eb9f195..e63297e 100644 --- a/src/utils.js +++ b/src/utils.js @@ -720,14 +720,6 @@ const mods = { let stream = fs.createWriteStream(modlocation); res.pipe(stream); - // let received = 0; - // // Progress messages, we should probably switch this to - // // percentage instead of how much is downloaded. - // res.on("data", (chunk) => { - // received += chunk.length; - // ipcMain.emit("ns-update-event", lang("gui.update.downloading") + " " + (received / 1024 / 1024).toFixed(1) + "mb"); - // }) - stream.on("finish", () => { stream.close(); mods.install(modlocation); -- cgit v1.2.3 From 71e4fd2600d015c4cf978cb448640efeabff3371 Mon Sep 17 00:00:00 2001 From: Delta <31860825+AA-Delta@users.noreply.github.com> Date: Thu, 12 May 2022 08:49:40 -0500 Subject: "gui.mods.confirmdependencies" "es" localization #122 --- src/lang/es.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lang/es.json b/src/lang/es.json index dbccad8..c2871f1 100644 --- a/src/lang/es.json +++ b/src/lang/es.json @@ -68,6 +68,7 @@ "gui.mods.installing": "Instalando modificación...", "gui.mods.installedmod": "¡Modificación instalada!", "gui.mods.dragdrop": "Arrastra y suelta una modificación para instalarla", + "gui.mods.confirmdependencies": "Este paquete tiene dependencias, se muestran abajo. Presionar \"Ok\" instalará el paquete y las dependencias.\n\n", "gui.browser.info": "Información", "gui.browser.madeby": "por", -- cgit v1.2.3 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