diff options
author | GeckoEidechse <gecko.eidechse+git@pm.me> | 2022-09-01 01:00:35 +0200 |
---|---|---|
committer | GeckoEidechse <gecko.eidechse+git@pm.me> | 2022-09-01 01:00:35 +0200 |
commit | 340b96e5878b892d81dbc7e5cdbc0215ce78b4d9 (patch) | |
tree | aebb0d4237f228f9cbdba580f285318d0bcfa8de | |
parent | c82336dfd2945680b4919dcbbc71ff3effd6809d (diff) | |
download | FlightCore-340b96e5878b892d81dbc7e5cdbc0215ce78b4d9.tar.gz FlightCore-340b96e5878b892d81dbc7e5cdbc0215ce78b4d9.zip |
Add dir picker if Titanfall2 is not installed
Allows user to select install location if the Titanfall2 install path
was not found under the assumption that Titanfall2 was installed but
couldn't be found by FlightCore
-rw-r--r-- | src-ui/src/main.ts | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src-ui/src/main.ts b/src-ui/src/main.ts index 4cbd8099..aedcceb5 100644 --- a/src-ui/src/main.ts +++ b/src-ui/src/main.ts @@ -1,5 +1,7 @@ import { invoke } from "@tauri-apps/api"; import { listen, Event as TauriEvent } from "@tauri-apps/api/event"; +import { open } from '@tauri-apps/api/dialog'; +import { appDir } from '@tauri-apps/api/path'; const $ = document.querySelector.bind(document); @@ -29,6 +31,43 @@ document.addEventListener("DOMContentLoaded", async function () { }, 500); }) + // omni button click + omniButtonEl.addEventListener("click", async function () { + // Check if Titanfall2 install path as found + let install_location = await invoke("find_game_install_location_caller") as string; + if (!(install_location && install_location.length > 0)) { + alert("Titanfall2 install not found"); + // Open a selection dialog for directories + const selected = await open({ + directory: true, + multiple: false, + defaultPath: await appDir(), + }); + if (Array.isArray(selected)) { + // user selected multiple directories + alert("Please only select a single directory"); + } else if (selected === null) { + // user cancelled the selection + } else { + // user selected a single directory + alert(selected); + + globalState.gamepath = selected; + + // TODO Verify if valid Titanfall2 install location + + // Update omni-button + omniButtonEl.textContent = "Install"; + + // TODO Check for Northstar install + // TODO Check for updated Northstar + } + return; + } + + alert("TODO"); + }); + // counter button click counterButtonEl.addEventListener("pointerup", async function () { const result = await invoke("add_count", { num: 1 }) as string; |