From 39a2672580c07eabbed116178d93d20e712a6632 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Sun, 25 Sep 2022 12:28:50 +0200 Subject: feat: load up installation path in app state on launch --- src-vue/src/App.vue | 2 +- src-vue/src/plugins/store.ts | 25 ++++++++++++++++++++++++- src-vue/src/utils/GameInstall.ts | 4 ++++ 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 src-vue/src/utils/GameInstall.ts (limited to 'src-vue') diff --git a/src-vue/src/App.vue b/src-vue/src/App.vue index 264f021d..64acc389 100644 --- a/src-vue/src/App.vue +++ b/src-vue/src/App.vue @@ -13,7 +13,7 @@ export default { return {} }, mounted: () => { - store.commit('initializeListeners'); + store.commit('initialize'); }, methods: { minimize() { diff --git a/src-vue/src/plugins/store.ts b/src-vue/src/plugins/store.ts index 5519537e..545f5484 100644 --- a/src-vue/src/plugins/store.ts +++ b/src-vue/src/plugins/store.ts @@ -1,6 +1,8 @@ import { createStore } from 'vuex'; import { listen, Event as TauriEvent } from "@tauri-apps/api/event"; import {Tabs} from "../utils/Tabs"; +import {invoke} from "@tauri-apps/api"; +import {GameInstall} from "../utils/GameInstall"; export const store = createStore({ state () { @@ -19,7 +21,9 @@ export const store = createStore({ toggleDeveloperMode(state) { state.developer_mode = !state.developer_mode; }, - initializeListeners(state) { + initialize(state) { + _initializeApp(state); + // _checkForFlightCoreUpdates(state); _initializeListeners(state); }, updateCurrentTab(state: any, newTab: Tabs) { @@ -28,6 +32,25 @@ export const store = createStore({ } }); + +async function _initializeApp(state: any) { + const result: GameInstall = await invoke("find_game_install_location_caller") + .catch((err) => { + // Gamepath not found or other error + console.error(err); + alert(err); + }); + state.game_path = result.game_path; +} + +// TODO +async function _checkForFlightCoreUpdates(state: any) { + // Get version number + let version_number_string = await invoke("get_version_number") as string; + // Check if up-to-date + let flightcore_is_outdated = await invoke("check_is_flightcore_outdated_caller") as boolean; +} + function _initializeListeners(state: any) { listen("origin-running-ping", function (evt: TauriEvent) { state.origin_is_running = evt.payload as boolean; diff --git a/src-vue/src/utils/GameInstall.ts b/src-vue/src/utils/GameInstall.ts new file mode 100644 index 00000000..07358f6c --- /dev/null +++ b/src-vue/src/utils/GameInstall.ts @@ -0,0 +1,4 @@ +export interface GameInstall { + game_path: string; + install_type: string; +} -- cgit v1.2.3