aboutsummaryrefslogtreecommitdiff
path: root/src/app/js/set_buttons.js
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2024-06-08 18:02:48 +0200
committer0neGal <mail@0negal.com>2024-06-08 18:02:48 +0200
commitdbd8c6b152acc1188d2edd288488aa2da8f6310b (patch)
treeef5a1752e845a274c889ee18207c3a25e8290b23 /src/app/js/set_buttons.js
parent3904a4492f72ef9a9fd531c0b81f3711541c97e0 (diff)
downloadViper-dbd8c6b152acc1188d2edd288488aa2da8f6310b.tar.gz
Viper-dbd8c6b152acc1188d2edd288488aa2da8f6310b.zip
initial commit to better modularize frontend
Far from done, but this pretty much splits everything inside `src/app/main.js` into separate files.
Diffstat (limited to 'src/app/js/set_buttons.js')
-rw-r--r--src/app/js/set_buttons.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/app/js/set_buttons.js b/src/app/js/set_buttons.js
new file mode 100644
index 0000000..9cb9d3e
--- /dev/null
+++ b/src/app/js/set_buttons.js
@@ -0,0 +1,40 @@
+const ipcRenderer = require("electron").ipcRenderer;
+
+ipcRenderer.on("set-buttons", (_, state) => {
+ set_buttons(state);
+})
+
+// disables or enables certain buttons when for example
+// updating/installing Northstar.
+module.exports = (state, enable_gamepath_btns) => {
+ playNsBtn.disabled = ! state;
+
+ let disable_array = (array) => {
+ for (let i = 0; i < array.length; i++) {
+ array[i].disabled = ! state;
+
+ if (state) {
+ array[i].classList.remove("disabled")
+ } else {
+ array[i].classList.add("disabled")
+ }
+ }
+ }
+
+ disable_array(document.querySelectorAll([
+ "#modsdiv .el button",
+ ".disable-when-installing",
+ ".playBtnContainer .playBtn",
+ "#nsMods .buttons.modbtns button",
+ "#browser #browserEntries .text button",
+ ]))
+
+ if (enable_gamepath_btns) {
+ let gamepath_btns = query_all('*[onclick="gamepath.set()"]');
+
+ for (let i = 0; i < gamepath_btns.length; i++) {
+ gamepath_btns[i].disabled = false;
+ gamepath_btns[i].classList.remove("disabled");
+ }
+ }
+}