diff options
-rw-r--r-- | src/app/browser.js | 19 | ||||
-rw-r--r-- | src/utils.js | 33 |
2 files changed, 44 insertions, 8 deletions
diff --git a/src/app/browser.js b/src/app/browser.js index 7b67822..c266b41 100644 --- a/src/app/browser.js +++ b/src/app/browser.js @@ -77,10 +77,15 @@ var Browser = { 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); + } } } }, 1501) @@ -137,6 +142,20 @@ function BrowserEl(properties) { installstr = lang("gui.browser.update"); } } + } else { + 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)) { + installstr = lang("gui.browser.reinstall"); + + if (folder == title + && "v" + modsobj.all[i].Version != properties.version) { + + installstr = lang("gui.browser.update"); + } + } + } } browserEntries.innerHTML += ` diff --git a/src/utils.js b/src/utils.js index 048e0e6..125a8d7 100644 --- a/src/utils.js +++ b/src/utils.js @@ -412,7 +412,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) => { + install: (mod, destname) => { let modname = mod.replace(/^.*(\\|\/|\:)/, ""); if (getNSVersion() == "unknown") { @@ -435,6 +435,14 @@ const mods = { winLog(lang("gui.mods.installedmod")) + if (modname == "mods") { + let manifest = path.join(app.getPath("userData"), "Archives/manifest.json") + + if (fs.existsSync(manifest)) { + modname = require(manifest).name; + } + } + ipcMain.emit("installedmod", "", modname); ipcMain.emit("guigetmods"); return true; @@ -451,7 +459,9 @@ const mods = { if (fs.existsSync(path.join(modpath, modname))) { fs.rmSync(path.join(modpath, modname), {recursive: true}); } - copy(mod, path.join(modpath, modname)) + let copydest = path.join(modpath, modname); + if (typeof destname == "string") {copydest = path.join(modpath, destname)} + copy(mod, copydest) return installed(); } else { @@ -488,14 +498,21 @@ const mods = { if (fs.existsSync(path.join(cache, "manifest.json"))) { files = fs.readdirSync(path.join(cache, "mods")); - for (let i = 0; i < files.length; i++) { - let mod = path.join(cache, "mods", files[i]); - if (fs.statSync(mod).isDirectory()) { - setTimeout(() => { - if (mods.install(mod)) {return true}; - }, 1000) + if (fs.existsSync(path.join(cache, "mods/mod.json"))) { + if (mods.install(path.join(cache, "mods"), require(path.join(cache, "manifest.json")).name)) { + return true; + } + } else { + for (let i = 0; i < files.length; i++) { + let mod = path.join(cache, "mods", files[i]); + if (fs.statSync(mod).isDirectory()) { + setTimeout(() => { + if (mods.install(mod)) {return true}; + }, 1000) + } } } + return notamod(); } |