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/index.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'src/index.js') diff --git a/src/index.js b/src/index.js index b43611d..330b2b7 100644 --- a/src/index.js +++ b/src/index.js @@ -1,7 +1,7 @@ const fs = require("fs"); const path = require("path"); const { autoUpdater } = require("electron-updater"); -const { app, dialog, ipcMain, BrowserWindow, ipcRenderer } = require("electron"); +const { app, ipcMain, BrowserWindow } = require("electron"); const Emitter = require("events"); const events = new Emitter(); @@ -31,12 +31,8 @@ function start() { win.loadFile(__dirname + "/app/index.html"); ipcMain.on("exit", () => {process.exit(0)}) - ipcMain.on("setpath", () => {utils.setpath(win)}) ipcMain.on("setsize", (event, height) => { win.setSize(width, height); - if (! win.isVisible()) { - win.show(); - } }) ipcMain.on("ns-updated", () => {win.webContents.send("ns-updated")}) @@ -61,6 +57,22 @@ ipcMain.on("launchVanilla", (event) => {utils.launch("vanilla")}) ipcMain.on("update", (event) => {utils.update()}) ipcMain.on("setpathcli", (event) => {utils.setpath()}); +ipcMain.on("setpath", (event, value) => { + if (!value) { + utils.setpath(win) + } else if (!win.isVisible()) { + win.show(); + } +}); +ipcMain.on("newpath", (event, newpath) => { + if (newpath === false && !win.isVisible()) { + win.webContents.send("nopathselected"); + } else { + if (!win.isVisible()) { + win.show(); + } + } +}); ipcMain.on("getversion", () => { win.webContents.send("version", { -- cgit v1.2.3