From 3a2f9fac72d141f6a5e2e56133a5ae77d6972680 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Sun, 20 Feb 2022 20:31:50 +0100 Subject: [PATCH 1/9] initial work on settings page This only has the actual UI for the settings page in place, no actual functionality has been implemented yet. I made several changes not directly related to the settings page, such as changes the CSS color variables to use RGB, as to easily add an alpha channel to colors. I also changed the way the Browser is toggled in some respects and many other changes that makes it easy to re-use the browser code to create the settings UI --- src/app/browser.js | 4 -- src/app/icons/apply.png | Bin 0 -> 2555 bytes src/app/icons/settings.png | Bin 0 -> 2496 bytes src/app/index.html | 50 +++++++++++++- src/app/main.css | 134 +++++++++++++++++++++++++++---------- src/app/main.js | 7 ++ src/app/settings.js | 46 +++++++++++++ 7 files changed, 198 insertions(+), 43 deletions(-) create mode 100644 src/app/icons/apply.png create mode 100644 src/app/icons/settings.png create mode 100644 src/app/settings.js diff --git a/src/app/browser.js b/src/app/browser.js index ded12fa4..275e16e5 100644 --- a/src/app/browser.js +++ b/src/app/browser.js @@ -104,10 +104,6 @@ var Browser = { } } -document.body.addEventListener("keyup", (e) => { - if (e.key == "Escape") {Browser.toggle(false)} -}) - function BrowserElFromObj(obj) { let pkg = {...obj, ...obj.versions[0]}; diff --git a/src/app/icons/apply.png b/src/app/icons/apply.png new file mode 100644 index 0000000000000000000000000000000000000000..915f809f6ee92d3f9cf7919bee624ec7044e3465 GIT binary patch literal 2555 zcmVDGEyWZH_wU2( zOHXg^l{2$v_C9-``6V}(T+XbSv;S+aJzskbWHOmdCX>lzGMP*!lgVTI8OaO4CSbtKcGlgP)*#6wEt2#^jd!{)d*z}+ zqi(RCLee-n;s02xl;t=eX@#WM)qOo1g`_!>{!*`YQ8^%KcHP&t=aKXlNduCG>eVY5 z8zo&)_jT@MT-^Hv~%0X6_{tFs+7aum4R%zjr_18R8$$PMk*0Nd$b@d2&^wo6)F*CV0wO67(` z4+1NzuDi#12v})muT)uSr4AtJV%%)mf-3865Ziz|&Fn-~6;|c|a;tQ|0B)|T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rh`EDM1hk{(pV%_2z?B>foJ0n}HHtr(@!#mYLsx{}Y;!4<&cz;1<%-O^_V zlCG8XAg~+wIn9nrdZx@nqoGjbNkT?ZA0cU@f2fO>6!sNn67*V3IN57lCh|qtWM&J? zJUALl#hxJiqTl2Hp=%QfrD8vePcVlkXMlNT_C}e9t5yqt8u(5X8JWsFWoADp`*4hM z@%@B*fiv~ATs?J^+4JMMkC)tEw0u@|7{Y%no2q@+)J^>@;wHRXLf$ ztgLE$h!hZFW-kC6V#vyL#dBsBrC3JnizBzud!JFg#!13$Va>WY(#&=NPsNg#8IoVc zGCt(XqkE0_fmw~cJlf2T06&c>Gjkpf#WX%R9P4(@Kvmi(E}(t zb$nJ*{057igqt`%4}6z!y<1!O2v|-yXnGjfUhsJVD`Fep6-keF5y!Si(qoe5UgY_C zlKLaW%BAKlg@d!f`puTKM$+ysWF!xMErq0SDP*#IoC6A>%(qJ#_7$X%XZWO~)3K~k zBc~)iA!)?oPLgg@xPW7DX3@Knz8TLV7vdh;rEtbR2e_7S1iP(hxi?7*2tg=KibWib zzXHq6tkB&`3hSqvflm@DjlIzerSWP(Apzq)Njq!%4HsvRq~&Tr!b)qAG)~gDC2db? z>hpP1Aw}+z)Z;U1P)JQ%D8K65-LPKLT^eC6(`0(KL!DD{E2e*Fmjl$fC~L(65ZdJcueP); zS6br$X7)DlLJdvzbpl{BO+(U6k`6lV{U4AtEw!GRVURRU(uT-}KdVpx+v`TuWVB)* z;9@A$^O*x&R#DV3!e`(9>b=TjGMP*!lgVT
+
@@ -21,9 +22,51 @@ -
-
-
+
+ + +
diff --git a/src/app/main.css b/src/app/main.css index 09dc4b38..0d4b9adc 100644 --- a/src/app/main.css +++ b/src/app/main.css @@ -236,7 +236,14 @@ button { justify-content: space-between; } -.option .actions text {opacity: 0.8} +.option .text {font-weight: 600} +.option .text .desc { + opacity: 0.8; + font-weight: 500; + font-size: 0.9em; + max-width: 400px; + margin-top: calc(var(--padding) / 3); +} .option .actions input { width: 100%; From 132fea11e3599c9c2c9df8a69fd4d093033788ba Mon Sep 17 00:00:00 2001 From: 0neGal Date: Mon, 21 Feb 2022 19:31:33 +0100 Subject: [PATCH 3/9] some functionality is now present Albeit only frontend functionality, it doesn't actually save your settings, it simply loads them, and Settings.get(), allows you to convert them to a format that can be used to save settings. --- src/app/index.html | 8 +++---- src/app/main.js | 2 ++ src/app/settings.js | 56 ++++++++++++++++++++++++++++++++++++++++++++- src/utils.js | 2 ++ 4 files changed, 63 insertions(+), 5 deletions(-) diff --git a/src/app/index.html b/src/app/index.html index 7a919b15..0bd66944 100644 --- a/src/app/index.html +++ b/src/app/index.html @@ -37,7 +37,7 @@

Northstar

-
+
Launch options
@@ -49,7 +49,7 @@

Northstar

Updates

-
+
Viper Auto-Updates
@@ -60,7 +60,7 @@

Updates

-
+
Northstar Auto-Updates
@@ -71,7 +71,7 @@

Updates

-
+
Retain files on update
diff --git a/src/app/main.js b/src/app/main.js index db3514b3..a781ef10 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -8,7 +8,9 @@ let shouldInstallNorthstar = false; // Base settings var settings = { + nsargs: "", gamepath: "", + nsupdate: true, autoupdate: true, zip: "/northstar.zip", lang: navigator.language, diff --git a/src/app/settings.js b/src/app/settings.js index c9e43aeb..e558d613 100644 --- a/src/app/settings.js +++ b/src/app/settings.js @@ -1,6 +1,7 @@ var Settings = { toggle: (state) => { if (state) { + Settings.load(); options.scrollTo(0, 0); overlay.classList.add("shown") options.classList.add("shown") @@ -14,6 +15,7 @@ var Settings = { } } + Settings.load(); options.scrollTo(0, 0); overlay.classList.toggle("shown") options.classList.toggle("shown") @@ -39,8 +41,60 @@ var Settings = { } Settings.reloadSwitches(); + }, + get: () => { + let opts = {}; + let options = document.querySelectorAll(".option"); + + for (let i = 0; i < options.length; i++) { + let optName = options[i].getAttribute("name"); + if (options[i].querySelector(".actions input")) { + let input = options[i].querySelector(".actions input").value; + if (options[i].getAttribute("type")) { + opts[optName] = input.split(" "); + } else { + opts[optName] = input; + } + } else if (options[i].querySelector(".actions .switch")) { + if (options[i].querySelector(".actions .switch.on")) { + opts[optName] = true; + } else { + opts[optName] = false; + } + } + } + + return opts; + }, + load: () => { + let options = document.querySelectorAll(".option"); + + for (let i = 0; i < options.length; i++) { + let optName = options[i].getAttribute("name"); + if (settings[optName] != undefined) { + switch(typeof settings[optName]) { + case "string": + options[i].querySelector(".actions input").value = settings[optName]; + break + case "object": + options[i].querySelector(".actions input").value = settings[optName].join(" "); + break + case "boolean": + let switchDiv = options[i].querySelector(".actions .switch"); + if (settings[optName]) { + switchDiv.classList.add("on"); + switchDiv.classList.remove("off"); + } else { + switchDiv.classList.add("off"); + switchDiv.classList.remove("on"); + } + break + + } + } + } } } Settings.reloadSwitches(); - +Settings.load(); diff --git a/src/utils.js b/src/utils.js index 2ea91cd8..b4dd920a 100644 --- a/src/utils.js +++ b/src/utils.js @@ -20,8 +20,10 @@ process.chdir(app.getPath("appData")); // Base settings var settings = { + nsargs: "", gamepath: "", lang: "en-US", + nsupdate: true, autoupdate: true, zip: "/northstar.zip", From 815106a3e1214196b25a380d83e826473840f948 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Wed, 23 Feb 2022 18:17:56 +0100 Subject: [PATCH 4/9] settings page is now fully functional It actually saves settings, loads them properly and everything... --- src/app/index.html | 4 ++-- src/app/settings.js | 5 ++++- src/index.js | 2 ++ src/utils.js | 14 ++++++++++---- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/app/index.html b/src/app/index.html index 0bd66944..f6051366 100644 --- a/src/app/index.html +++ b/src/app/index.html @@ -26,11 +26,11 @@