From 9d8ceea77b6f172f0c055c0061bc07e6f45c0d2d Mon Sep 17 00:00:00 2001 From: 0neGal Date: Thu, 30 Dec 2021 19:11:59 +0100 Subject: buttons now disable when updating, and app logs The buttons in the GUI disable whilst you're updating Northstar and potentionally doing other things in the future, I also added a way to log things in the app, albeit it just prints it in the "Welcome to Viper!" part of the app, which is just fine. I also added all the needed language strings for the GUI logs and removed "gui.missinggamepath" as we use it for both the CLI and GUI even tho "general.missinggamepath" exists, and so we now use the general one for both, as the messages are the same. --- src/app/index.html | 2 +- src/app/main.css | 3 +++ src/app/main.js | 20 +++++++++++++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) (limited to 'src/app') diff --git a/src/app/index.html b/src/app/index.html index 426b4c5..dc65d67 100644 --- a/src/app/index.html +++ b/src/app/index.html @@ -6,7 +6,7 @@
-
%%gui.welcome%%
+
%%gui.welcome%%
diff --git a/src/app/main.css b/src/app/main.css index f49cc98..b668f55 100644 --- a/src/app/main.css +++ b/src/app/main.css @@ -1,4 +1,5 @@ :root { + --disabled: #656E7F; --background: #4C515B; --foreground: #DDE2EB; --btnforeground: var(--foreground); @@ -64,7 +65,9 @@ button:active { transform: scale(0.95); } + #update {background: #81A1C1} #setpath {background: #5E81AC} #northstar {background: #C7777F} #vanilla, #exit {background: #656E7F} +button:disabled {background: var(--disabled) !important; opacity: 0.5} diff --git a/src/app/main.js b/src/app/main.js index 9bafaa5..809b5c8 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -20,7 +20,7 @@ if (fs.existsSync("viper.json")) { settings = {...settings, ...JSON.parse(fs.readFileSync("viper.json", "utf8"))}; settings.zip = path.join(settings.gamepath + "/northstar.zip"); } else { - alert(lang("gui.missinggamepath")); + alert(lang("general.missinggamepath")); setpath(); } @@ -31,10 +31,28 @@ function setpath() {ipcRenderer.send("setpath")} function launch() {ipcRenderer.send("launch")} function launchVanilla() {ipcRenderer.send("launchVanilla")} +function log(msg) { + console.log(msg); + welcome.innerHTML = msg; +} + +function setButtons(state) { + let buttons = document.querySelectorAll("button"); + + for (let i = 0; i < buttons.length; i++) { + buttons[i].disabled = !state; + } +} + +ipcRenderer.on("ns-updated", () => {setButtons(true)}) +ipcRenderer.on("ns-updating", () => {setButtons(false)}) + ipcRenderer.on("newpath", (event, newpath) => { settings.gamepath = newpath; }) +ipcRenderer.on("log", (event, msg) => {log(msg)}) + setlang(); setInterval(() => { ipcRenderer.send("setsize", document.querySelector(".lines").offsetHeight + 20); -- cgit v1.2.3