From 145baa0e1606816d7784deac8eafa58490854141 Mon Sep 17 00:00:00 2001 From: Rémy Raes Date: Tue, 4 Jan 2022 17:41:13 +0100 Subject: fix: No game path (#24) * [refactor] moving main.setPath listener outside start method * [refactor] setpath tells if game path is set or not * newpath event tells if game path dialog is successful or not * [feat] main window will not show if path is not set * [feat] viper displays a dialog and exits if no game path was prompted * [fix] viper prompts for game path if viper.json:gamepath is not set * [feat] translating gui.gamepath.must key * code cleanup fixing single quotes and alike * fix gui.gamepath.must message Co-authored-by: 0neGal --- src/app/main.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/app') diff --git a/src/app/main.js b/src/app/main.js index 8cd00a3..aa2ba68 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -20,6 +20,13 @@ ipcRenderer.send("setlang", settings.lang); if (fs.existsSync("viper.json")) { settings = {...settings, ...JSON.parse(fs.readFileSync("viper.json", "utf8"))}; settings.zip = path.join(settings.gamepath + "/northstar.zip"); + + if (settings.gamepath.length === 0) { + alert(lang("general.missingpath")); + setpath(false); + } else { + setpath(true); + } } else { alert(lang("general.missingpath")); setpath(); @@ -27,7 +34,14 @@ if (fs.existsSync("viper.json")) { function exit() {ipcRenderer.send("exit")} function update() {ipcRenderer.send("update")} -function setpath() {ipcRenderer.send("setpath")} + +/** + * Reports to the main thread about game path status. + * @param {boolean} value is game path loaded + */ +function setpath(value = false) { + ipcRenderer.send("setpath", value); +} function launch() {ipcRenderer.send("launch")} function launchVanilla() {ipcRenderer.send("launchVanilla")} @@ -65,6 +79,11 @@ ipcRenderer.on("updateavailable", () => { } }) +ipcRenderer.on("nopathselected", () => { + alert(lang("gui.gamepath.must")); + exit(); +}); + setlang(); setInterval(() => { ipcRenderer.send("setsize", document.querySelector(".lines").offsetHeight + 20); -- cgit v1.2.3