aboutsummaryrefslogtreecommitdiff
path: root/src/modules/gamepath.js
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2024-02-03 19:15:29 +0100
committer0neGal <mail@0negal.com>2024-02-03 19:21:23 +0100
commit159e2f981bdbfd6a0589639424155d34b7a4cc91 (patch)
treeb3c1dfa3aaeb989b88abea6c9fc927c5dad3c2f9 /src/modules/gamepath.js
parent647bd1f6a76c834b3db9b70005f4b8365d1ded91 (diff)
downloadViper-159e2f981bdbfd6a0589639424155d34b7a4cc91.tar.gz
Viper-159e2f981bdbfd6a0589639424155d34b7a4cc91.zip
src/modules/settings.js now provides a function
This fixes a couple issues where the main process wouldn't actually get changes made to the settings, this fixes that. On top of this, changing settings is now done with `settings.set()` There shouldn't be any breakage from this change, but I suppose it is possible. Especially because the `settings()` function still does contain backup options set, meaning `settings.nsargs` is technically still valid, but dont expect it to actually be updated when that variable is changed, its merely here to avoid any problems.
Diffstat (limited to 'src/modules/gamepath.js')
-rw-r--r--src/modules/gamepath.js33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/modules/gamepath.js b/src/modules/gamepath.js
index 0a9dcc6..8d28c29 100644
--- a/src/modules/gamepath.js
+++ b/src/modules/gamepath.js
@@ -16,7 +16,7 @@ let gamepath = {};
// returns true/false depending on if the gamepath currently exists/is
// mounted, used to avoid issues...
gamepath.exists = (folder) => {
- return fs.existsSync(folder || settings.gamepath);
+ return fs.existsSync(folder || settings().gamepath);
}
// returns false if the user doesn't have read/write permissions to the
@@ -29,7 +29,7 @@ gamepath.has_perms = (folder) => {
try {
fs.accessSync(
- folder || settings.gamepath,
+ folder || settings().gamepath,
fs.constants.R_OK | fs.constants.W_OK
)
@@ -51,14 +51,16 @@ gamepath.set = async (win, force_dialog) => {
// actually sets and saves the gamepath in the settings
function set_gamepath(folder) {
// set settings
- settings.gamepath = folder;
- settings.zip = path.join(settings.gamepath + "/northstar.zip");
+ settings().set("gamepath", folder);
+ settings().set("zip", path.join(
+ settings().gamepath + "/northstar.zip"
+ ))
- settings.save(); // save settings
+ settings().save(); // save settings
// tell the renderer the path has changed
- win.webContents.send("newpath", settings.gamepath);
- ipcMain.emit("newpath", null, settings.gamepath);
+ win.webContents.send("newpath", settings().gamepath);
+ ipcMain.emit("newpath", null, settings().gamepath);
}
if (! win) { // CLI
@@ -69,11 +71,14 @@ gamepath.set = async (win, force_dialog) => {
// gamepath, and then later fallback to the GUI/manual selection
if (! force_dialog) {
function set_gamepath(folder, force_dialog) {
- settings.gamepath = folder;
- settings.zip = path.join(settings.gamepath + "/northstar.zip");
- settings.save();
- win.webContents.send("newpath", settings.gamepath);
- ipcMain.emit("newpath", null, settings.gamepath);
+ settings().set("gamepath", folder);
+ settings().set("zip", path.join(
+ settings().gamepath + "/northstar.zip")
+ )
+
+ settings().save();
+ win.webContents.send("newpath", settings().gamepath);
+ ipcMain.emit("newpath", null, settings().gamepath);
gamepath.setting = false;
}
@@ -127,13 +132,13 @@ gamepath.set = async (win, force_dialog) => {
setInterval(() => {
if (gamepath.exists()) {
if (! gamepath.has_perms()) {
- return ipcMain.emit("gamepath-lost-perms", null, settings.gamepath);
+ return ipcMain.emit("gamepath-lost-perms", null, settings().gamepath);
}
ipcMain.emit("gui-getmods");
} else {
if (fs.existsSync("viper.json")) {
- if (settings.gamepath != "") {
+ if (settings().gamepath != "") {
ipcMain.emit("gamepath-lost");
}
}