From f3e5e1596a22c3df38a8c00a5ceadf8a5dd2967a Mon Sep 17 00:00:00 2001 From: 0neGal Date: Sat, 16 Sep 2023 18:17:04 +0200 Subject: added buttons for fixing some problems and alike I will likely add more buttons in the future, but for now this is most of the ones a user could need to repair problems. --- src/index.js | 50 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) (limited to 'src/index.js') diff --git a/src/index.js b/src/index.js index a097525..220d490 100644 --- a/src/index.js +++ b/src/index.js @@ -81,11 +81,55 @@ function start() { }); ipcMain.on("minimize", () => {win.minimize()}); - ipcMain.on("relaunch", () => {app.relaunch(); app.exit()}); + ipcMain.on("relaunch", () => { + app.relaunch({ + args: process.argv.slice(1) + }); + + app.exit(0); + }); + ipcMain.on("kill-game", () => { kill.game(); }); + ipcMain.on("kill-origin", () => { + kill.origin(); + }); + + ipcMain.on("delete-request-cache", () => { + requests.delete_cache(); + }); + + ipcMain.on("delete-install-cache", () => { + let delete_dirs = [ + path.join(app.getPath("cache"), "vipertmp"), + path.join(settings.gamepath, "northstar.zip") + ] + + for (let i = 0; i < delete_dirs.length; i++) { + if (fs.existsSync(delete_dirs[i])) { + fs.rmSync(delete_dirs[i], {recursive: true}); + } + } + }); + + ipcMain.on("reset-config", async () => { + let confirmation = await win_show.confirm( + lang("gui.settings.miscbuttons.reset_config_alert") + ) + + if (confirmation) { + fs.rmSync("viper.json"); + + app.relaunch({ + args: process.argv.slice(1) + }); + + app.exit(0); + } + }); + // passthrough to renderer from main ipcMain.on("win-log", (event, ...args) => {send("log", ...args)}); ipcMain.on("win-alert", (event, msg, id) => { @@ -207,12 +251,12 @@ ipcMain.on("setlang", (event, lang) => { settings.save(); }); -ipcMain.on("update-northstar", async () => { +ipcMain.on("update-northstar", async (e, force_install) => { if (await is_running.game()) { return win_show.alert(lang("general.auto_updates.game_running")); } - update.northstar(); + update.northstar(force_install); }) ipcMain.on("setpath-cli", () => {gamepath.set()}); -- cgit v1.2.3