aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2022-02-08 23:22:39 +0100
committer0neGal <mail@0negal.com>2022-02-08 23:22:39 +0100
commit0a317f81def6b4c041cfc340e454a9bc8f0046fb (patch)
treef8be9e32dbef3ed9fc1a8a961420d9402dea2bbe
parent0813769008f5436e1cea2ad97f1a527c8ce94df7 (diff)
downloadViper-0a317f81def6b4c041cfc340e454a9bc8f0046fb.tar.gz
Viper-0a317f81def6b4c041cfc340e454a9bc8f0046fb.zip
added toasts for installation of mods
It'll notify of incorrectly formatted mods, it'll also notify on errors and on success.
-rw-r--r--src/app/browser.js29
-rw-r--r--src/app/main.css2
-rw-r--r--src/lang/en.json7
-rw-r--r--src/utils.js10
4 files changed, 42 insertions, 6 deletions
diff --git a/src/app/browser.js b/src/app/browser.js
index e1f37e5..ded12fa 100644
--- a/src/app/browser.js
+++ b/src/app/browser.js
@@ -198,9 +198,34 @@ ipcRenderer.on("removedmod", (event, mod) => {
}
})
-ipcRenderer.on("installedmod", (event, modname) => {
+ipcRenderer.on("failedmod", (event, modname) => {
setButtons(true);
- Browser.setbutton(modname, lang("gui.browser.reinstall"));
+ new Toast({
+ timeout: 10000,
+ scheme: "error",
+ title: lang("gui.toast.title.failed"),
+ description: lang("gui.toast.desc.failed")
+ })
+})
+
+ipcRenderer.on("installedmod", (event, mod) => {
+ setButtons(true);
+ Browser.setbutton(mod.name, lang("gui.browser.reinstall"));
+
+ if (mod.malformed) {
+ new Toast({
+ timeout: 8000,
+ scheme: "warning",
+ title: lang("gui.toast.title.malformed"),
+ description: mod.name + " " + lang("gui.toast.desc.malformed")
+ })
+ }
+
+ new Toast({
+ scheme: "success",
+ title: lang("gui.toast.title.installed"),
+ description: mod.name + " " + lang("gui.toast.desc.installed")
+ })
})
function normalize(items) {
diff --git a/src/app/main.css b/src/app/main.css
index 14348bd..a532490 100644
--- a/src/app/main.css
+++ b/src/app/main.css
@@ -609,7 +609,7 @@ code {
.toast .description {
opacity: 0.8;
font-size: 0.8em;
- font-weight: 400;
+ font-weight: 600;
}
/* drag control */
diff --git a/src/lang/en.json b/src/lang/en.json
index a9eb47f..27630ec 100644
--- a/src/lang/en.json
+++ b/src/lang/en.json
@@ -90,6 +90,13 @@
"gui.gamepath.must": "The game path must be set to start Viper.",
"gui.gamepath.wrong": "This folder is not a valid game path.",
+ "gui.toast.title.installed": "Mod installed!",
+ "gui.toast.title.failed": "Failed to install",
+ "gui.toast.title.malformed": "Incorrect folder structure!",
+ "gui.toast.desc.installed": "has been installed successfully!",
+ "gui.toast.desc.malformed": "has an incorrect folder structure, if you're the developer, you should fix this.",
+ "gui.toast.desc.failed": "An unknown error occurred while trying to install the mod. This may be the author's fault, and it may also be Viper's fault.",
+
"viper.menu.main": "Viper",
"viper.menu.release": "Release Notes",
"viper.menu.info": "Extras",
diff --git a/src/utils.js b/src/utils.js
index b825309..7a1e333 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -450,7 +450,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, manifestfile) => {
+ install: (mod, destname, manifestfile, malformed = false) => {
let modname = mod.replace(/^.*(\\|\/|\:)/, "");
if (getNSVersion() == "unknown") {
@@ -481,7 +481,10 @@ const mods = {
}
}
- ipcMain.emit("installedmod", "", modname);
+ ipcMain.emit("installedmod", "", {
+ name: modname,
+ malformed: malformed,
+ });
ipcMain.emit("guigetmods");
return true;
}
@@ -539,7 +542,7 @@ const mods = {
files = fs.readdirSync(path.join(cache, "mods"));
if (fs.existsSync(path.join(cache, "mods/mod.json"))) {
- if (mods.install(path.join(cache, "mods"), require(manifest).name, manifest)) {
+ if (mods.install(path.join(cache, "mods"), require(manifest).name, manifest, true)) {
return true;
}
} else {
@@ -553,6 +556,7 @@ const mods = {
}
}
+ ipcMain.emit("failedmod", "", modname);
return notamod();
}