diff options
author | 0neGal <mail@0negal.com> | 2023-09-16 18:17:04 +0200 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2023-09-16 18:17:04 +0200 |
commit | f3e5e1596a22c3df38a8c00a5ceadf8a5dd2967a (patch) | |
tree | a5ae56bdc7baedc22930697de9cefc171705410d /src | |
parent | 53c19052738a4a9cc43feca31e8231c844b4d2b5 (diff) | |
download | Viper-f3e5e1596a22c3df38a8c00a5ceadf8a5dd2967a.tar.gz Viper-f3e5e1596a22c3df38a8c00a5ceadf8a5dd2967a.zip |
added buttons for fixing some problems and alike
I will likely add more buttons in the future, but for now this is most
of the ones a user could need to repair problems.
Diffstat (limited to 'src')
-rw-r--r-- | src/app/css/popups.css | 26 | ||||
-rw-r--r-- | src/app/css/theming.css | 8 | ||||
-rw-r--r-- | src/app/css/toasts.css | 7 | ||||
-rw-r--r-- | src/app/index.html | 34 | ||||
-rw-r--r-- | src/app/js/settings.js | 1 | ||||
-rw-r--r-- | src/app/js/toast.js | 12 | ||||
-rw-r--r-- | src/app/main.js | 32 | ||||
-rw-r--r-- | src/index.js | 50 | ||||
-rw-r--r-- | src/lang/en.json | 24 | ||||
-rw-r--r-- | src/modules/requests.js | 7 | ||||
-rw-r--r-- | src/modules/update.js | 7 |
11 files changed, 190 insertions, 18 deletions
diff --git a/src/app/css/popups.css b/src/app/css/popups.css index 7ece7e3..9d307d1 100644 --- a/src/app/css/popups.css +++ b/src/app/css/popups.css @@ -89,7 +89,8 @@ margin: calc(var(--padding) / 2); } -.popup .options .option { +.popup .options .option, +.popup .options .buttons { width: 100%; display: flex; margin-bottom: var(--padding); @@ -146,8 +147,13 @@ background-image: url(../icons/check.png); } -.option .text {font-weight: 600} -.option .text .desc { +.option .text, +.buttons .text { + font-weight: 600; +} + +.option .text .desc, +.buttons .text .desc { opacity: 0.8; font-weight: 500; font-size: 0.9em; @@ -155,7 +161,8 @@ margin-top: calc(var(--padding) / 3); } -.option .actions input, .option .actions select { +.option .actions input, +.option .actions select { width: 100%; margin: 0px; --spacing: calc(var(--padding) / 3); @@ -166,7 +173,16 @@ margin-right: 15vw; } -.option .actions button { +.buttons .actions { + text-align: right; +} + +.buttons .actions button { + margin-bottom: calc(var(--padding) / 5); +} + +.option .actions button, +.buttons .actions button { background: var(--selbg); } diff --git a/src/app/css/theming.css b/src/app/css/theming.css index d92c42e..d16f455 100644 --- a/src/app/css/theming.css +++ b/src/app/css/theming.css @@ -37,10 +37,18 @@ a { transition: filter 0.2s ease-in !important; } +a.disabled { + opacity: 0.5; + pointer-events: none; +} + a:hover { filter: brightness(80%) !important; } +input:disabled { + opacity: 0.5; +} ::-webkit-scrollbar { width: 8px !important; diff --git a/src/app/css/toasts.css b/src/app/css/toasts.css index 57ba055..65e325f 100644 --- a/src/app/css/toasts.css +++ b/src/app/css/toasts.css @@ -18,9 +18,10 @@ cursor: pointer; overflow: hidden; max-height: 100vh; - background: #FFFFFF; transform: scale(0.95); + background: var(--selbg); transition: 0.2s ease-in-out; + backdrop-filter: blur(15px); padding: calc(var(--padding) / 2); margin-top: calc(var(--padding) / 2); border-radius: calc(var(--padding) / 2.5); @@ -33,6 +34,10 @@ animation-timing-function: ease-in-out; } +#toasts .toast .title:only-child { + margin-bottom: 0px; +} + #toasts .toast.hidden { margin-top: 0px; max-height: 0px; diff --git a/src/app/index.html b/src/app/index.html index 4a8dca9..9ca5e07 100644 --- a/src/app/index.html +++ b/src/app/index.html @@ -121,7 +121,20 @@ </div> </div> <div class="actions"> - <input type="text"> + <input type="text" class="disable-when-installing"> + </div> + </div> + <div class="buttons"> + <div class="text"> + %%gui.settings.updatebuttons.title%% + <div class="desc"> + %%gui.settings.updatebuttons.desc%% + </div> + </div> + <div class="actions"> + <button onclick="delete_request_cache()">%%gui.settings.updatebuttons.buttons.reset_cached_api_requests%%</button> + <button onclick="force_update_ns()" class="disable-when-installing">%%gui.settings.updatebuttons.buttons.force_northstar_reinstall%%</button> + <button onclick="delete_install_cache()" class="disable-when-installing">%%gui.settings.updatebuttons.buttons.force_delete_install_cache%%</button> </div> </div> <div class="title"> @@ -139,6 +152,21 @@ <button class="switch off"></button> </div> </div> + <div class="buttons"> + <div class="text"> + %%gui.settings.miscbuttons.title%% + <div class="desc"> + %%gui.settings.miscbuttons.desc%% + </div> + </div> + <div class="actions"> + <button onclick="relaunch()">%%gui.settings.miscbuttons.buttons.restart_viper%%</button> + <button onclick="reset_config()">%%gui.settings.miscbuttons.buttons.reset_config%%</button> + <button onclick="kill_game()">%%gui.settings.miscbuttons.buttons.force_quit_game%%</button> + <button onclick="kill_origin()">%%gui.settings.miscbuttons.buttons.force_quit_origin%%</button> + <button onclick="setpath()" class="disable-when-installing">%%gui.settings.miscbuttons.buttons.change_gamepath%%</button> + </div> + </div> </div> </div> @@ -195,7 +223,7 @@ <img src="icons/viper.png"/> <div class="inline" style="margin-top: 20px;"> <div id="vpversion"></div> | - <a id="setpath" href="#" onclick="setpath()">%%gui.setpath%%</a> + <a id="setpath" href="#" onclick="setpath()" class="disable-when-installing">%%gui.setpath%%</a> </div> </div> <div id="vpReleaseNotes" class="hidden section"></div> @@ -228,7 +256,7 @@ <button id="playNsBtn" class="playBtn" onclick="launch()">%%gui.launch%%</button> <div class="inline"> <div id="nsversion"></div> - <a id="update" href="#" onclick="updateNorthstar()">(%%gui.update.check%%)</a> + <a id="update" href="#" onclick="updateNorthstar()" class="disable-when-installing">(%%gui.update.check%%)</a> <div id="serverstatus" class="checking"></div> </div> </div> diff --git a/src/app/js/settings.js b/src/app/js/settings.js index db29300..8aeb2ca 100644 --- a/src/app/js/settings.js +++ b/src/app/js/settings.js @@ -1,4 +1,3 @@ - var Settings = { toggle: (state) => { let settings_btn = document.getElementById("settings"); diff --git a/src/app/js/toast.js b/src/app/js/toast.js index 3bc1745..e0aba6b 100644 --- a/src/app/js/toast.js +++ b/src/app/js/toast.js @@ -1,8 +1,8 @@ function Toast(properties) { let toast = { - fg: "#000000", - bg: "#FFFFFF", timeout: 3000, + fg: "#FFFFFF", + bg: "var(--selbg)", callback: () => {}, title: "Untitled Toast", description: "No description provided for toast", @@ -45,6 +45,14 @@ function Toast(properties) { <div class="description">${toast.description}</div> ` + if (! toast.title) { + el.querySelector(".title").remove(); + } + + if (! toast.description) { + el.querySelector(".description").remove(); + } + toasts.appendChild(el); setTimeout(() => { diff --git a/src/app/main.js b/src/app/main.js index bbf1e57..d94d508 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -122,6 +122,17 @@ if (! navigator.onLine) { function exit() {ipcRenderer.send("exit")} function updateNorthstar() {ipcRenderer.send("update-northstar")} +function force_update_ns() { + ipcRenderer.send("update-northstar", true); +} + +function reset_config() { + ipcRenderer.send("reset-config"); +} + +function relaunch() { + ipcRenderer.send("relaunch"); +} // Reports to the main process about game path status. // @param {boolean} value is game path loaded @@ -151,11 +162,18 @@ function setButtons(state) { let disablearray = (array) => { for (let i = 0; i < array.length; i++) { - array[i].disabled = !state; + array[i].disabled = ! state; + + if (state) { + array[i].classList.remove("disabled") + } else { + array[i].classList.add("disabled") + } } } disablearray(document.querySelectorAll("#modsdiv .el button")); + disablearray(document.querySelectorAll(".disable-when-installing")); disablearray(document.querySelectorAll(".playBtnContainer .playBtn")); disablearray(document.querySelectorAll("#nsMods .buttons.modbtns button")); disablearray(document.querySelectorAll("#browser #browserEntries .text button")); @@ -333,6 +351,18 @@ function kill_game() { ipcRenderer.send("kill-game"); } +function kill_origin() { + ipcRenderer.send("kill-origin"); +} + +function delete_request_cache() { + ipcRenderer.send("delete-request-cache"); +} + +function delete_install_cache() { + ipcRenderer.send("delete-install-cache"); +} + // Updates the installed mods ipcRenderer.on("mods", (event, mods_obj) => { modsobj = mods_obj; diff --git a/src/index.js b/src/index.js index a097525..220d490 100644 --- a/src/index.js +++ b/src/index.js @@ -81,11 +81,55 @@ function start() { }); ipcMain.on("minimize", () => {win.minimize()}); - ipcMain.on("relaunch", () => {app.relaunch(); app.exit()}); + ipcMain.on("relaunch", () => { + app.relaunch({ + args: process.argv.slice(1) + }); + + app.exit(0); + }); + ipcMain.on("kill-game", () => { kill.game(); }); + ipcMain.on("kill-origin", () => { + kill.origin(); + }); + + ipcMain.on("delete-request-cache", () => { + requests.delete_cache(); + }); + + ipcMain.on("delete-install-cache", () => { + let delete_dirs = [ + path.join(app.getPath("cache"), "vipertmp"), + path.join(settings.gamepath, "northstar.zip") + ] + + for (let i = 0; i < delete_dirs.length; i++) { + if (fs.existsSync(delete_dirs[i])) { + fs.rmSync(delete_dirs[i], {recursive: true}); + } + } + }); + + ipcMain.on("reset-config", async () => { + let confirmation = await win_show.confirm( + lang("gui.settings.miscbuttons.reset_config_alert") + ) + + if (confirmation) { + fs.rmSync("viper.json"); + + app.relaunch({ + args: process.argv.slice(1) + }); + + app.exit(0); + } + }); + // passthrough to renderer from main ipcMain.on("win-log", (event, ...args) => {send("log", ...args)}); ipcMain.on("win-alert", (event, msg, id) => { @@ -207,12 +251,12 @@ ipcMain.on("setlang", (event, lang) => { settings.save(); }); -ipcMain.on("update-northstar", async () => { +ipcMain.on("update-northstar", async (e, force_install) => { if (await is_running.game()) { return win_show.alert(lang("general.auto_updates.game_running")); } - update.northstar(); + update.northstar(force_install); }) ipcMain.on("setpath-cli", () => {gamepath.set()}); diff --git a/src/lang/en.json b/src/lang/en.json index 56d7cd8..5cb443e 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -172,6 +172,30 @@ "originkill": { "title": "Automatically quit Origin and or EA Desktop", "desc": "When Viper exits, automatically quit Origin and or EA Desktop as well." + }, + + "updatebuttons": { + "title": "Repair actions", + "desc": "If you're having problems with updates, some of these buttons may help in fixing them.", + "buttons": { + "reset_cached_api_requests": "Reset cached API requests", + "force_northstar_reinstall": "Force re-install of Northstar", + "force_delete_install_cache": "Force delete cached install files" + } + }, + + "miscbuttons": { + "title": "Misc repair actions", + "desc": "If you're having problems then some of these buttons may help fixing it", + "buttons": { + "reset_config": "Reset config file", + "restart_viper": "Restart Viper", + "change_gamepath": "Change gamepath", + "force_quit_game": "Force quit Titanfall and Northstar", + "force_quit_origin": "Force quit Origin and or EA Desktop" + }, + + "reset_config_alert": "Please confirm that you want to reset the config file, after confirming Viper will delete the config file, and then restart." } }, diff --git a/src/modules/requests.js b/src/modules/requests.js index 94639fa..a67bc26 100644 --- a/src/modules/requests.js +++ b/src/modules/requests.js @@ -27,6 +27,12 @@ function _getRequestsCache() { } } +function delete_cache() { + if (fs.existsSync(cachePath)) { + return fs.rmSync(cachePath); + } +} + // Returns latest Northstar version available from GitHub releases. If // there's no cache result for this request, or if cache exists but is // old, refreshes cache with new data. @@ -182,6 +188,7 @@ async function getVpReleaseNotes() { } module.exports = { + delete_cache, getLatestNsVersion, getLatestNsVersionLink, getNsReleaseNotes, diff --git a/src/modules/update.js b/src/modules/update.js index 087cbd9..c2d10d3 100644 --- a/src/modules/update.js +++ b/src/modules/update.js @@ -150,7 +150,10 @@ update.viper = (autoinstall) => { // as to handle not overwriting files we rename certain files to // <file>.excluded, then rename them back after the extraction. The // unzip module does not support excluding files directly. -update.northstar = async () => { +// +// `force_install` makes this function not care about whether or not +// we're already up-to-date, forcing the install +update.northstar = async (force_install) => { if (await is_running.game()) { console.error(lang("general.auto_updates.game_running")); return false; @@ -170,7 +173,7 @@ update.northstar = async () => { } // Makes sure it is not already the latest version - if (! await northstar_update_available()) { + if (! force_install && ! await northstar_update_available()) { ipcMain.emit("ns-update-event", "cli.update.uptodate_short"); console.ok(lang("cli.update.uptodate").replace("%s", ns_version)); |