From 340b96e5878b892d81dbc7e5cdbc0215ce78b4d9 Mon Sep 17 00:00:00 2001 From: GeckoEidechse Date: Thu, 1 Sep 2022 01:00:35 +0200 Subject: 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 --- src-ui/src/main.ts | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) 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; -- cgit v1.2.3