aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2023-09-13 16:50:35 +0200
committer0neGal <mail@0negal.com>2023-09-13 16:50:35 +0200
commit809aacaa9a0449de654264983adceca268790586 (patch)
tree7204ef006d628a1f1727a1152c88b65c15ce1229
parent31db9fbe27eb77a4c9372f57c0dbdf199aa8e965 (diff)
downloadViper-809aacaa9a0449de654264983adceca268790586.tar.gz
Viper-809aacaa9a0449de654264983adceca268790586.zip
use json.js for loading settings in the renderer
-rw-r--r--src/app/main.js22
1 files changed, 5 insertions, 17 deletions
diff --git a/src/app/main.js b/src/app/main.js
index 51d9e73..4eae3ec 100644
--- a/src/app/main.js
+++ b/src/app/main.js
@@ -2,6 +2,8 @@ const fs = require("fs");
const path = require("path");
const { app, ipcRenderer, shell } = require("electron");
+const json = require("../modules/json");
+
const lang = require("../lang");
var modsobj = {
all: [],
@@ -33,25 +35,11 @@ ipcRenderer.send("setlang", settings.lang);
// Loads the settings
if (fs.existsSync("viper.json")) {
- let conf = fs.readFileSync("viper.json", "utf8");
- let json = {};
-
- // Validates viper.json
- try {
- json = JSON.parse(conf);
- }catch (e) {
- let reset = confirm(lang("general.invalidconfig", navigator.language) + e);
- if (! reset) {
- ipcRenderer.send("exit");
- } else {
- fs.rmSync("viper.json");
- ipcRenderer.send("relaunch");
- }
-
+ settings = {
+ ...settings,
+ ...json("viper.json") || {}
}
- settings = {...settings, ...json};
-
if (settings.gamepath.length === 0) {
setpath(false);
} else {