aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2022-02-23 18:17:56 +0100
committer0neGal <mail@0negal.com>2022-02-23 18:17:56 +0100
commit815106a3e1214196b25a380d83e826473840f948 (patch)
tree9b37315b8068931d69755acf7b00900f64474de5
parent132fea11e3599c9c2c9df8a69fd4d093033788ba (diff)
downloadViper-815106a3e1214196b25a380d83e826473840f948.tar.gz
Viper-815106a3e1214196b25a380d83e826473840f948.zip
settings page is now fully functional
It actually saves settings, loads them properly and everything...
-rw-r--r--src/app/index.html4
-rw-r--r--src/app/settings.js5
-rw-r--r--src/index.js2
-rw-r--r--src/utils.js14
4 files changed, 18 insertions, 7 deletions
diff --git a/src/app/index.html b/src/app/index.html
index 0bd6694..f605136 100644
--- a/src/app/index.html
+++ b/src/app/index.html
@@ -26,11 +26,11 @@
<div class="popup" id="options">
<div class="misc">
<div style="width:100%"></div>
- <button id="apply" onclick="Settings.apply()">
+ <button id="apply" onclick="Settings.toggle(false);Settings.apply()">
<img src="icons/apply.png">
Save
</button>
- <button id="close" onclick="Settings.toggle(false)">
+ <button id="close" onclick="Settings.toggle(false);Settings.load()">
<img src="icons/close.png">
Discard
</button>
diff --git a/src/app/settings.js b/src/app/settings.js
index e558d61..4921e07 100644
--- a/src/app/settings.js
+++ b/src/app/settings.js
@@ -20,7 +20,10 @@ var Settings = {
overlay.classList.toggle("shown")
options.classList.toggle("shown")
},
- apply: () => {},
+ apply: () => {
+ settings = {...settings, ...Settings.get()};
+ ipcRenderer.send("savesettings", Settings.get());
+ },
reloadSwitches: () => {
let switches = document.querySelectorAll(".switch");
diff --git a/src/index.js b/src/index.js
index 95115b4..fa2a35f 100644
--- a/src/index.js
+++ b/src/index.js
@@ -53,6 +53,8 @@ function start() {
ipcMain.on("installedmod", (event, modname) => {win.webContents.send("installedmod", modname)});
ipcMain.on("guigetmods", (event, ...args) => {win.webContents.send("mods", utils.mods.list())});
+ ipcMain.on("savesettings", (event, obj) => {utils.saveSettings(obj)})
+
win.webContents.on("dom-ready", () => {
win.webContents.send("mods", utils.mods.list());
});
diff --git a/src/utils.js b/src/utils.js
index b4dd920..5055a2e 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -20,15 +20,15 @@ process.chdir(app.getPath("appData"));
// Base settings
var settings = {
- nsargs: "",
gamepath: "",
lang: "en-US",
nsupdate: true,
autoupdate: true,
+ nsargs: "-multiple",
zip: "/northstar.zip",
// These files won't be overwritten when installing/updating
- // Northstar, useful for config file.
+ // Northstar, useful for config files
excludes: [
"ns_startup_args.txt",
"ns_startup_args_dedi.txt"
@@ -172,8 +172,13 @@ async function setpath(win, forcedialog) {
// As to not have to do the same one liner a million times, this
// function exists, as the name suggests, it simply writes the current
// settings to the disk.
-function saveSettings() {
- fs.writeFileSync(app.getPath("appData") + "/viper.json", JSON.stringify(settings));
+//
+// You can also pass a settings object to the function and it'll try and
+// merge it together with the already existing settings
+function saveSettings(obj = {}) {
+ settings = {...settings, ...obj};
+ fs.writeFileSync(path.join(settings.gamepath, "ns_startup_args.txt"), settings.nsargs);
+ fs.writeFileSync(app.getPath("appData") + "/viper.json", JSON.stringify({...settings, ...obj}));
}
// Returns the current Northstar version
@@ -754,6 +759,7 @@ module.exports = {
setpath,
updatevp,
settings,
+ saveSettings,
getNSVersion,
getTF2Version,
isGameRunning,