diff options
author | 0neGal <mail@0negal.com> | 2023-09-13 16:50:35 +0200 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2023-09-13 16:50:35 +0200 |
commit | 809aacaa9a0449de654264983adceca268790586 (patch) | |
tree | 7204ef006d628a1f1727a1152c88b65c15ce1229 /src | |
parent | 31db9fbe27eb77a4c9372f57c0dbdf199aa8e965 (diff) | |
download | Viper-809aacaa9a0449de654264983adceca268790586.tar.gz Viper-809aacaa9a0449de654264983adceca268790586.zip |
use json.js for loading settings in the renderer
Diffstat (limited to 'src')
-rw-r--r-- | src/app/main.js | 22 |
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 { |