aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2025-01-02 23:04:40 +0100
committer0neGal <mail@0negal.com>2025-01-02 23:04:40 +0100
commit579ccb867bd419541621107d546eb34bd8e1ced0 (patch)
tree84ca8d20a1292f8e60c5690b7c669cedb2910d3f
parent291a781b5c0b5e0874069ee8c47d8f4d28ffbfb3 (diff)
downloadViper-new-enabledmods-json.tar.gz
Viper-new-enabledmods-json.zip
initial support for multiple mods in mods listnew-enabledmods-json
-rw-r--r--src/app/js/mods.js25
-rw-r--r--src/modules/mods.js25
2 files changed, 31 insertions, 19 deletions
diff --git a/src/app/js/mods.js b/src/app/js/mods.js
index 7e5e750..9dab61a 100644
--- a/src/app/js/mods.js
+++ b/src/app/js/mods.js
@@ -31,7 +31,8 @@ mods.load = (mods_obj) => {
name = mod.package.package_name;
}
- let normalized_name = "mod-list-" + mods.normalize(name);
+ let normalized_name =
+ mod.version + "-mod-list-" + mods.normalize(name)
normalized_names.push(normalized_name);
@@ -97,11 +98,14 @@ mods.load = (mods_obj) => {
div.querySelector(".remove").onclick = () => {
if (! mod.package) {
- return mods.remove(mod.name);
+ return mods.remove(mod.name, mod.version);
}
- for (let i = 0; i < mod.packaged_mods.length; i++) {
- mods.remove(mod.packaged_mods[i]);
+ for (let i in mod.packaged_mods) {
+ mods.remove(
+ mod.packaged_mods[i].name,
+ mod.packaged_mods[i].version
+ )
}
}
@@ -111,11 +115,14 @@ mods.load = (mods_obj) => {
div.querySelector(".switch").addEventListener("click", () => {
if (! mod.package) {
- return mods.toggle(mod.name);
+ return mods.toggle(mod.name, mod.version);
}
- for (let i = 0; i < mod.packaged_mods.length; i++) {
- mods.toggle(mod.packaged_mods[i]);
+ for (let i in mod.packaged_mods) {
+ mods.toggle(
+ mod.packaged_mods[i].name,
+ mod.packaged_mods[i].version
+ )
}
})
@@ -142,7 +149,7 @@ mods.load = (mods_obj) => {
}
for (let i = 0; i < mod_els.length; i++) {
- let mod = mod_els[i].id.replace(/^mod-list-/, "");
+ let mod = mod_els[i].id.replace(/.*mod-list-/, "");
if (! normalized_names.includes(mod_els[i].id)) {
mod_els[i].remove();
@@ -254,7 +261,7 @@ mods.remove = (mod) => {
ipcRenderer.send("remove-mod", mod);
}
-mods.toggle = (mod) => {
+mods.toggle = (mod, version) => {
// is this a core mod?
if (mod.toLowerCase().match(/^northstar\./)) {
// keep track of whether this mod is disabled
diff --git a/src/modules/mods.js b/src/modules/mods.js
index 3db0693..737fbcf 100644
--- a/src/modules/mods.js
+++ b/src/modules/mods.js
@@ -21,8 +21,8 @@ var mods = {
dupe_msg_sent: false,
}
-ipcMain.on("remove-mod", (_, mod) => {
- mods.remove(mod);
+ipcMain.on("remove-mod", (_, mod, mod_version) => {
+ mods.remove(mod, mod_version);
})
ipcMain.on("toggle-mod", (_, mod, mod_version) => {
@@ -153,12 +153,16 @@ mods.list = () => {
}
if (obj.package) {
- packaged_mods.push(obj.name);
+ packaged_mods.push({
+ name: obj.name,
+ version: obj.version
+ })
+
obj.author = obj.package.author;
obj.version = obj.package.version;
}
- obj.disabled = ! mods.modfile.get(obj.name);
+ obj.disabled = ! mods.modfile.get(obj.name, obj.version);
// add manifest data from manifest.json, if it exists
let manifest_file = path.join(dir, file, "manifest.json");
@@ -193,7 +197,8 @@ mods.list = () => {
let add_packaged_mods = (mods_array) => {
for (let i = 0; i < mods_array.length; i++) {
if (mods_array[i].package.package_name !==
- package_obj.package_name) {
+ package_obj.package_name
+ || mods_array[i].version != package_obj.version) {
continue;
}
@@ -734,7 +739,7 @@ mods.installFromURL = (url, author) => {
//
// takes in the names of the mod then removes it, no confirmation,
// that'd be up to the GUI.
-mods.remove = (mod) => {
+mods.remove = (mod, mod_version) => {
update_path();
// make sure Northstar is actually installed
@@ -759,7 +764,7 @@ mods.remove = (mod) => {
return
}
- let mod_data = mods.get(mod);
+ let mod_data = mods.get(mod, mod_version);
let mod_name = mod_data.folder_name;
if (! mod_name) {
@@ -811,7 +816,7 @@ mods.remove = (mod) => {
// it's disabled. You could have a direct .disable() function if you
// checked for if a mod is already disable and if not run the function.
// However we currently have no need for that.
-mods.toggle = (mod, fork) => {
+mods.toggle = (mod, mod_version, fork) => {
update_path();
// make sure Northstar is actually installed
@@ -839,7 +844,7 @@ mods.toggle = (mod, fork) => {
continue;
}
- mods.toggle(modlist[i].name, true); // enable mod
+ mods.toggle(modlist[i].name, mod_version, true); // enable mod
}
console.ok(lang("cli.mods.toggled_all"));
@@ -848,7 +853,7 @@ mods.toggle = (mod, fork) => {
}
// toggle specific mod
- mods.modfile.toggle(mod);
+ mods.modfile.toggle(mod, mod_version);
if (! fork) {
console.ok(lang("cli.mods.toggled"));