aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app/browser.js35
-rw-r--r--src/utils.js30
2 files changed, 50 insertions, 15 deletions
diff --git a/src/app/browser.js b/src/app/browser.js
index 69db6de..5062d86 100644
--- a/src/app/browser.js
+++ b/src/app/browser.js
@@ -66,7 +66,6 @@ var Browser = {
},
setbutton: (mod, string) => {
mod = normalize(mod);
- console.log(mod)
if (document.getElementById(mod)) {
let elems = document.querySelectorAll(`#${mod}`);
@@ -74,19 +73,27 @@ var Browser = {
elems[i].querySelector(".text button").innerHTML = string;
}
} else {
+ let make = (str) => {
+ if (document.getElementById(str)) {
+ return Browser.setbutton(str, string);
+ } else {
+ return false;
+ }
+ }
+
setTimeout(() => {
for (let i = 0; i < modsobj.all.length; i++) {
let modname = normalize(modsobj.all[i].Name);
let modfolder = normalize(modsobj.all[i].FolderName);
+
if (mod.includes(modname)) {
- if (document.getElementById(modname)) {
- Browser.setbutton(modname, string);
- }
- } else if (mod.includes(modfolder)) {
- if (document.getElementById(modfolder)) {
- Browser.setbutton(modfolder, string);
+ if (! make(modname)) {
+ if (modsobj.all[i].ManifestName) {
+ make(normalize(modsobj.all[i].ManifestName));
+ }
}
}
+ else if (mod.includes(modfolder)) {make(modfolder);break}
}
}, 1501)
}
@@ -145,7 +152,12 @@ function BrowserEl(properties) {
for (let i = 0; i < modsobj.all.length; i++) {
let title = normalize(properties.title);
let folder = normalize(modsobj.all[i].FolderName);
- if (title.includes(folder)) {
+ let manifestname = null;
+ if (modsobj.all[i].ManifestName) {
+ manifestname = normalize(modsobj.all[i].ManifestName);
+ }
+
+ if (title.includes(folder) || title.includes(manifestname)) {
installstr = lang("gui.browser.reinstall");
if (folder == title
@@ -174,9 +186,12 @@ function BrowserEl(properties) {
`
}
-ipcRenderer.on("removedmod", (event, modname) => {
+ipcRenderer.on("removedmod", (event, mod) => {
setButtons(true);
- Browser.setbutton(modname, lang("gui.browser.install"));
+ Browser.setbutton(mod.name, lang("gui.browser.install"));
+ if (mod.manifestname) {
+ Browser.setbutton(mod.manifestname, lang("gui.browser.install"));
+ }
})
ipcRenderer.on("installedmod", (event, modname) => {
diff --git a/src/utils.js b/src/utils.js
index 125a8d7..5016ef6 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -352,6 +352,11 @@ const mods = {
if (cli.hasArgs()) {console.log("error: " + lang("cli.mods.improperjson"), file)}
mods.push({Name: file, FolderName: file, Version: "unknown", Disabled: false})
}
+
+ let manifest = path.join(modpath, file, "manifest.json");
+ if (fs.existsSync(manifest)) {
+ mods[mods.length - 1].ManifestName = require(manifest).name;
+ }
}
}
})
@@ -372,6 +377,11 @@ const mods = {
disabled.push({Name: file, FolderName: file, Version: "unknown", Disabled: true})
}
}
+
+ let manifest = path.join(modpath, file, "manifest.json");
+ if (fs.existsSync(manifest)) {
+ mods[mods.length - 1].ManifestName = require(manifest).name;
+ }
}
})
@@ -412,7 +422,7 @@ const mods = {
// Either a zip or folder is supported, we'll also try to search
// inside the zip or folder to see if buried in another folder or
// not, as sometimes that's the case.
- install: (mod, destname) => {
+ install: (mod, destname, manifestfile) => {
let modname = mod.replace(/^.*(\\|\/|\:)/, "");
if (getNSVersion() == "unknown") {
@@ -462,6 +472,7 @@ const mods = {
let copydest = path.join(modpath, modname);
if (typeof destname == "string") {copydest = path.join(modpath, destname)}
copy(mod, copydest)
+ copy(manifestfile, path.join(copydest, "manifest.json"))
return installed();
} else {
@@ -495,11 +506,12 @@ const mods = {
fs.createReadStream(mod).pipe(unzip.Extract({path: cache}))
.on("finish", () => {
setTimeout(() => {
- if (fs.existsSync(path.join(cache, "manifest.json"))) {
+ let manifest = path.join(cache, "manifest.json");
+ if (fs.existsSync(manifest)) {
files = fs.readdirSync(path.join(cache, "mods"));
if (fs.existsSync(path.join(cache, "mods/mod.json"))) {
- if (mods.install(path.join(cache, "mods"), require(path.join(cache, "manifest.json")).name)) {
+ if (mods.install(path.join(cache, "mods"), require(manifest).name, manifest)) {
return true;
}
} else {
@@ -507,7 +519,7 @@ const mods = {
let mod = path.join(cache, "mods", files[i]);
if (fs.statSync(mod).isDirectory()) {
setTimeout(() => {
- if (mods.install(mod)) {return true};
+ if (mods.install(mod, false, manifest)) {return true};
}, 1000)
}
}
@@ -602,11 +614,19 @@ const mods = {
}
if (fs.statSync(modPath).isDirectory()) {
+ let manifestname = null;
+ if (fs.existsSync(path.join(modPath, "manifest.json"))) {
+ manifestname = require(path.join(modPath, "manifest.json")).name;
+ }
+
fs.rmSync(modPath, {recursive: true});
console.log(lang("cli.mods.removed"));
cli.exit();
ipcMain.emit("guigetmods");
- ipcMain.emit("removedmod", "", mod.replace(/^.*(\\|\/|\:)/, ""));
+ ipcMain.emit("removedmod", "", {
+ name: mod.replace(/^.*(\\|\/|\:)/, ""),
+ manifestname: manifestname
+ });
} else {
cli.exit(1);
}