diff options
author | Alystrasz <contact@remyraes.com> | 2022-09-27 23:33:17 +0200 |
---|---|---|
committer | Alystrasz <contact@remyraes.com> | 2022-09-27 23:33:17 +0200 |
commit | 238e340ffb4d1af175e29567a772a0790174fdff (patch) | |
tree | 1445782e43d3c81978ab3a8e415996c3428b7f2c /src-vue/src/plugins | |
parent | b4531b34ca5232aadfa2cebaa1c26c66fbaea4cd (diff) | |
download | FlightCore-238e340ffb4d1af175e29567a772a0790174fdff.tar.gz FlightCore-238e340ffb4d1af175e29567a772a0790174fdff.zip |
feat: we can now install Northstar if it wasn't detected
Diffstat (limited to 'src-vue/src/plugins')
-rw-r--r-- | src-vue/src/plugins/store.ts | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src-vue/src/plugins/store.ts b/src-vue/src/plugins/store.ts index 58756a92..62d6f3ff 100644 --- a/src-vue/src/plugins/store.ts +++ b/src-vue/src/plugins/store.ts @@ -5,6 +5,7 @@ import {invoke} from "@tauri-apps/api"; import {GameInstall} from "../utils/GameInstall"; import {ReleaseCanal} from "../utils/ReleaseCanal"; import { ElNotification } from 'element-plus'; +import { NorthstarState } from '../utils/NorthstarState'; export const store = createStore({ state () { @@ -14,6 +15,7 @@ export const store = createStore({ game_path: "this/is/the/game/path", installed_northstar_version: "", + northstar_state: NorthstarState.INSTALL, northstar_is_running: false, origin_is_running: false @@ -36,9 +38,25 @@ export const store = createStore({ updateCurrentTab(state: any, newTab: Tabs) { state.current_tab = newTab; }, - launchGame(state: any) { + async launchGame(state: any) { // TODO update installation if release track was switched - // TODO install northstar if it wasn't detected + + // Install northstar if it wasn't detected. + if (state.northstar_state === NorthstarState.INSTALL) { + let install_northstar_result = invoke("install_northstar_caller", { gamePath: state.game_path, northstarPackageName: ReleaseCanal.RELEASE }); + state.northstar_state = NorthstarState.INSTALLING; + + await install_northstar_result.then((message) => { + console.log(message); + }) + .catch((error) => { + console.error(error); + alert(error); + }); + + _get_northstar_version_number(state); + } + // Show an error message if Origin is not running. if (!state.origin_is_running) { ElNotification({ @@ -101,10 +119,13 @@ async function _get_northstar_version_number(state: any) { let northstar_version_number: string = await invoke("get_northstar_version_number_caller", { gamePath: state.game_path }); if (northstar_version_number && northstar_version_number.length > 0) { state.installed_northstar_version = northstar_version_number; + state.northstar_state = NorthstarState.READY_TO_PLAY; await invoke("check_is_northstar_outdated", { gamePath: state.game_path, northstarPackageName: ReleaseCanal.RELEASE }) .then((message) => { - console.log(message); + if (message) { + state.northstar_state = NorthstarState.MUST_UPDATE; + } }) .catch((error) => { console.error(error); |