aboutsummaryrefslogtreecommitdiff
path: root/src/app/js/gamepath.js
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2024-06-09 18:15:45 +0200
committer0neGal <mail@0negal.com>2024-06-09 18:23:29 +0200
commit760031c079ce830755ba4fea029e149f4140e00b (patch)
tree8dbb9f8d5bb4e19cdaffb40e8a091b457a597769 /src/app/js/gamepath.js
parent1c1e8fb730b9974cd9b8060499773b0f37ff28d2 (diff)
parent04b0e9fcea6c60257d7bc68994103eacb340a82b (diff)
downloadViper-760031c079ce830755ba4fea029e149f4140e00b.tar.gz
Viper-760031c079ce830755ba4fea029e149f4140e00b.zip
Merge branch 'main' into linux-launch-v2linux-launch-v2
Diffstat (limited to 'src/app/js/gamepath.js')
-rw-r--r--src/app/js/gamepath.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/app/js/gamepath.js b/src/app/js/gamepath.js
new file mode 100644
index 0000000..c3e5c2b
--- /dev/null
+++ b/src/app/js/gamepath.js
@@ -0,0 +1,52 @@
+const ipcRenderer = require("electron").ipcRenderer;
+
+const lang = require("../../lang");
+const process = require("./process");
+const launcher = require("./launcher");
+const settings = require("./settings");
+
+// frontend part of settings a new game path
+ipcRenderer.on("newpath", (_, newpath) => {
+ set_buttons(true);
+
+ settings.set({gamepath: newpath});
+
+ ipcRenderer.send("gui-getmods");
+ ipcRenderer.send("save-settings", settings.data());
+})
+
+// a previously valid gamepath no longer exists, and is therefore lost
+ipcRenderer.on("gamepath-lost", () => {
+ launcher.change_page(0);
+ set_buttons(false, true);
+ alert(lang("gui.gamepath.lost"));
+})
+
+// error out when no game path is set
+ipcRenderer.on("no-path-selected", () => {
+ alert(lang("gui.gamepath.must"));
+ process.exit();
+})
+
+// error out when game path is wrong
+ipcRenderer.on("wrong-path", () => {
+ alert(lang("gui.gamepath.wrong"));
+ gamepath.set(false);
+})
+
+// reports to the main process about game path status.
+module.exports = {
+ open: () => {
+ let gamepath = settings.data().gamepath;
+
+ if (gamepath) {
+ require("electron").shell.openPath(gamepath);
+ } else {
+ alert(lang("gui.settings.miscbuttons.open_gamepath_alert"));
+ }
+ },
+
+ set: (value) => {
+ ipcRenderer.send("setpath", value);
+ }
+}