From 809aacaa9a0449de654264983adceca268790586 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Wed, 13 Sep 2023 16:50:35 +0200 Subject: use json.js for loading settings in the renderer --- src/app/main.js | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'src') 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 { -- cgit v1.2.3