aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2021-12-27 01:33:23 +0100
committer0neGal <mail@0negal.com>2021-12-27 01:55:24 +0100
commit6ac8259ec96db1ac0e770dd42b4f21c2eabd5c63 (patch)
tree17b0e9f58eb827ee46a57719d9d7daa629225d0d
parentee7753c1e03fe74bc133ecbf7eb149fb53841f58 (diff)
downloadViper-6ac8259ec96db1ac0e770dd42b4f21c2eabd5c63.tar.gz
Viper-6ac8259ec96db1ac0e770dd42b4f21c2eabd5c63.zip
changed how settings are loaded/saved
-rw-r--r--src/app/main.js2
-rw-r--r--src/utils.js9
2 files changed, 5 insertions, 6 deletions
diff --git a/src/app/main.js b/src/app/main.js
index 8d174c1..9783459 100644
--- a/src/app/main.js
+++ b/src/app/main.js
@@ -9,7 +9,7 @@ var settings = {
}
if (fs.existsSync(settings.file)) {
- settings.gamepath = JSON.parse(fs.readFileSync(settings.file, "utf8")).path;
+ settings.gamepath = {...settings, ...JSON.parse(fs.readFileSync(settings.file, "utf8"))};
settings.zip = path.join(settings.gamepath + "/northstar.zip");
} else {
alert("Game path is not set! Please select the path!");
diff --git a/src/utils.js b/src/utils.js
index 000c911..5394894 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -20,7 +20,7 @@ var settings = {
}
if (fs.existsSync(settings.file)) {
- settings.gamepath = JSON.parse(fs.readFileSync(settings.file, "utf8")).path;
+ settings = {...settings, ...JSON.parse(fs.readFileSync(settings.file, "utf8"))};
settings.zip = path.join(settings.gamepath + "/northstar.zip");
} else {
console.log("Game path is not set! Please select the path.");
@@ -29,17 +29,16 @@ if (fs.existsSync(settings.file)) {
function setpath(win) {
if (! win) {
- fs.writeFileSync(app.getPath("appData") + "/viper.json", JSON.stringify({path: cli.param("setpath")}));
settings.gamepath = cli.param("setpath");
- cli.exit();
} else {
dialog.showOpenDialog({properties: ["openDirectory"]}).then(res => {
- fs.writeFileSync(app.getPath("appData") + "/viper.json", JSON.stringify({path: res.filePaths[0]}));
-
win.webContents.send("newpath", res.filePaths[0]);
settings.gamepath = res.filePaths[0];
}).catch(err => {console.error(err)})
}
+
+ fs.writeFileSync(app.getPath("appData") + "/viper.json", JSON.stringify({...settings}));
+ cli.exit();
}
function update() {