aboutsummaryrefslogtreecommitdiff
path: root/src/app/main.js
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2022-05-16 00:21:59 +0200
committerGitHub <noreply@github.com>2022-05-16 00:21:59 +0200
commitdee10ac8d1d361f51ce316539e45b8a4197c8ad9 (patch)
treebbe9c068cf0d851e8baba973a903de617474107f /src/app/main.js
parent108c7b97100d2a40e82f8196109c99d1d59b59ee (diff)
parent9724d433ebba9c323236078eeb87f3e5f5dc3e6d (diff)
downloadViper-dee10ac8d1d361f51ce316539e45b8a4197c8ad9.tar.gz
Viper-dee10ac8d1d361f51ce316539e45b8a4197c8ad9.zip
Merge pull request #122 from 0neGal/dependency-supportbetter-browser
feat: Dependency support
Diffstat (limited to 'src/app/main.js')
-rw-r--r--src/app/main.js55
1 files changed, 53 insertions, 2 deletions
diff --git a/src/app/main.js b/src/app/main.js
index 95b6f4c..362450a 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,58 @@ 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-.*/)) {
+ 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]}`);
+ }
+ }
+ }
+
+ 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;
+ }
+}
+
+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