aboutsummaryrefslogtreecommitdiff
path: root/src-ui
diff options
context:
space:
mode:
authorGeckoEidechse <gecko.eidechse+git@pm.me>2022-09-09 23:31:05 +0200
committerGeckoEidechse <gecko.eidechse+git@pm.me>2022-09-09 23:31:05 +0200
commit10ec5953d600207922dc4bb2fad3b552f85552a2 (patch)
tree3a01ddb94ce4cd6e69c03711a80d551eb36a9fc0 /src-ui
parent8d5a7eba98fc01999d54ee89d1455ed024801359 (diff)
downloadFlightCore-10ec5953d600207922dc4bb2fad3b552f85552a2.tar.gz
FlightCore-10ec5953d600207922dc4bb2fad3b552f85552a2.zip
Use consts to define button content
i.e. replace setting button to a string with setting it to a variable to ensure that value is consistent over multiple places.
Diffstat (limited to 'src-ui')
-rw-r--r--src-ui/src/main.ts17
1 files changed, 10 insertions, 7 deletions
diff --git a/src-ui/src/main.ts b/src-ui/src/main.ts
index a9fe0301..a8cf4ad2 100644
--- a/src-ui/src/main.ts
+++ b/src-ui/src/main.ts
@@ -4,6 +4,9 @@ import { open } from '@tauri-apps/api/dialog';
import { appDir } from '@tauri-apps/api/path';
const $ = document.querySelector.bind(document);
+const button_install_string = "Install";
+const button_update_string = "Update";
+const button_play_string = "Play";
// Stores the overall state of the application
var globalState = {
@@ -60,7 +63,7 @@ document.addEventListener("DOMContentLoaded", async function () {
// globalState.gamepath = selected;
// // Update omni-button
- // omniButtonEl.textContent = "Install";
+ // omniButtonEl.textContent = button_install_string;
// // Check for Northstar install
// let northstar_version_number = await invoke("get_northstar_version_number_caller") as string;
@@ -70,7 +73,7 @@ document.addEventListener("DOMContentLoaded", async function () {
// // Check for updated Northstar
// let northstar_is_outdated = await invoke("check_is_northstar_outdated") as boolean;
// if (northstar_is_outdated) {
- // omniButtonEl.textContent = "Update";
+ // omniButtonEl.textContent = button_update_string;
// }
// }
// }
@@ -83,7 +86,7 @@ document.addEventListener("DOMContentLoaded", async function () {
// }
switch (omniButtonEl.textContent) {
- case "Install":
+ case button_install_string:
omniButtonEl.textContent = "Installing";
await invoke("install_northstar_caller", { gamePath: globalState.gamepath }) as boolean;
alert("Done?");
@@ -95,7 +98,7 @@ document.addEventListener("DOMContentLoaded", async function () {
omniButtonEl.textContent = `Play (${northstar_version_number})`;
let northstar_is_outdated = await invoke("check_is_northstar_outdated") as boolean;
if (northstar_is_outdated) {
- omniButtonEl.textContent = "Update";
+ omniButtonEl.textContent = button_update_string;
}
}
@@ -138,7 +141,7 @@ document.addEventListener("DOMContentLoaded", async function () {
let install_location = await invoke("find_game_install_location_caller") as string;
// Change omni-button content based on whether game install was found
if (install_location && install_location.length > 0) {
- omniButtonEl.textContent = "Install";
+ omniButtonEl.textContent = button_install_string;
installLocationHolderEl.textContent = install_location;
globalState.gamepath = install_location;
@@ -146,10 +149,10 @@ document.addEventListener("DOMContentLoaded", async function () {
let northstar_version_number = await invoke("get_northstar_version_number_caller") as string;
if (northstar_version_number && northstar_version_number.length > 0) {
globalState.installed_northstar_version = northstar_version_number;
- omniButtonEl.textContent = `Play (${northstar_version_number})`;
+ omniButtonEl.textContent = `${button_play_string} (${northstar_version_number})`;
let northstar_is_outdated = await invoke("check_is_northstar_outdated") as boolean;
if (northstar_is_outdated) {
- omniButtonEl.textContent = "Update";
+ omniButtonEl.textContent = button_update_string;
}
}
console.log(globalState);