diff options
author | 0neGal <mail@0negal.com> | 2024-06-18 18:39:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-18 18:39:00 +0200 |
commit | 8a13bbf15b7d4082e657b76bbd999b19c39f035b (patch) | |
tree | 98ad63331edd6634616494719addde2f9e4b2d55 /src/app | |
parent | 0d7eebe74814e9da992dd88836075acabd218f47 (diff) | |
parent | 760031c079ce830755ba4fea029e149f4140e00b (diff) | |
download | Viper-8a13bbf15b7d4082e657b76bbd999b19c39f035b.tar.gz Viper-8a13bbf15b7d4082e657b76bbd999b19c39f035b.zip |
Merge pull request #229 from 0neGal/linux-launch-v2
feat: Linux launch support v2
Diffstat (limited to 'src/app')
-rw-r--r-- | src/app/icons/linux.png | bin | 0 -> 6465 bytes | |||
-rw-r--r-- | src/app/index.html | 47 | ||||
-rw-r--r-- | src/app/js/settings.js | 37 | ||||
-rw-r--r-- | src/app/js/toasts.js | 4 |
4 files changed, 87 insertions, 1 deletions
diff --git a/src/app/icons/linux.png b/src/app/icons/linux.png Binary files differnew file mode 100644 index 0000000..29460ce --- /dev/null +++ b/src/app/icons/linux.png diff --git a/src/app/index.html b/src/app/index.html index ffc13de..ca80c86 100644 --- a/src/app/index.html +++ b/src/app/index.html @@ -63,6 +63,53 @@ </div> </div> </details> + <details open platform="linux"> + <summary> + <div class="title"> + <img src="icons/linux.png"> + <h2>%%gui.settings.title.linux%%</h2> + </div> + </summary> + <div class="option" name="linux_launch_method"> + <div class="text"> + %%gui.settings.linux_launch_method.title%% + <div class="desc"> + %%gui.settings.linux_launch_method.desc%% + </div> + </div> + <div class="actions"> + <select> + <option value="steam_auto">%%gui.settings.linux_launch_method.methods.steam_auto%%</option> + <option value="steam_executable">%%gui.settings.linux_launch_method.methods.steam_executable%%</option> + <option value="steam_flatpak">%%gui.settings.linux_launch_method.methods.steam_flatpak%%</option> + <option value="steam_protocol">%%gui.settings.linux_launch_method.methods.steam_protocol%%</option> + <option value="custom_command">%%gui.settings.linux_launch_method.methods.command%%</option> + </select> + </div> + </div> + <div class="option" name="linux_launch_cmd_ns"> + <div class="text"> + %%gui.settings.linux_launch_cmd_ns.title%% + <div class="desc"> + %%gui.settings.linux_launch_cmd_ns.desc%% + </div> + </div> + <div class="actions"> + <input> + </div> + </div> + <div class="option" name="linux_launch_cmd_vanilla"> + <div class="text"> + %%gui.settings.linux_launch_cmd_vanilla.title%% + <div class="desc"> + %%gui.settings.linux_launch_cmd_vanilla.desc%% + </div> + </div> + <div class="actions"> + <input> + </div> + </div> + </details> <details open> <summary> diff --git a/src/app/js/settings.js b/src/app/js/settings.js index 3addf0e..3aa9c43 100644 --- a/src/app/js/settings.js +++ b/src/app/js/settings.js @@ -106,6 +106,8 @@ ipcRenderer.on("changed-settings", (e, new_settings) => { }) let settings = { + default: {...settings_data}, + data: () => {return settings_data}, // asks the main process to reset the config/settings file @@ -138,7 +140,7 @@ settings.popup.toggle = (state) => { } settings.popup.apply = () => { - settings = {...settings, ...settings.popup.get()}; + settings.set(settings.popup.get()); ipcRenderer.send("save-settings", settings.popup.get()); } @@ -174,11 +176,25 @@ settings.popup.load = () => { let categories = document.querySelectorAll("#options details"); for (let i = 0; i < categories.length; i++) { categories[i].setAttribute("open", true); + + // hide categories that aren't for the current platform + let for_platform = categories[i].getAttribute("platform"); + if (for_platform && process.platform != for_platform) { + categories[i].style.display = "none"; + categories[i].setAttribute("perma-hidden", true); + } } let options = document.querySelectorAll(".option"); for (let i = 0; i < options.length; i++) { + // hide options that aren't for the current platform + let for_platform = options[i].getAttribute("platform"); + if (for_platform && process.platform != for_platform) { + options[i].style.display = "none"; + options[i].setAttribute("perma-hidden", true); + } + let optName = options[i].getAttribute("name"); if (optName == "forcedlang") { let div = options[i].querySelector("select"); @@ -207,6 +223,25 @@ settings.popup.load = () => { } if (settings_data[optName] != undefined) { + // check if setting has a `<select>` + let select_el = options[i].querySelector(".actions select"); + if (select_el) { + // get `<option>` for settings value, if it exists + let option = select_el.querySelector( + `option[value="${settings_data[optName]}"]` + ) + + // check if it exists + if (option) { + // set the `<select>` to the settings value + select_el.value = settings_data[optName]; + } else { // use the default value + select_el.value = settings.default[optName]; + } + + continue; + } + switch(typeof settings_data[optName]) { case "string": options[i].querySelector(".actions input").value = settings_data[optName]; diff --git a/src/app/js/toasts.js b/src/app/js/toasts.js index c3bba99..83ddf6a 100644 --- a/src/app/js/toasts.js +++ b/src/app/js/toasts.js @@ -74,4 +74,8 @@ toasts.dismiss = (id) => { } } +ipcRenderer.on("toast", (_, properties) => { + Toast(properties); +}) + module.exports = toasts; |