From e545724c89c9299d9dbfa5342ec84e35967ed66b Mon Sep 17 00:00:00 2001 From: GeckoEidechse Date: Sun, 2 Oct 2022 01:05:50 +0200 Subject: feat: Add initial NS launch functionality Adds logic to launch Northstar from FligthCore --- src-vue/src/plugins/store.ts | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) (limited to 'src-vue/src/plugins') diff --git a/src-vue/src/plugins/store.ts b/src-vue/src/plugins/store.ts index 7fdc7814..6914150c 100644 --- a/src-vue/src/plugins/store.ts +++ b/src-vue/src/plugins/store.ts @@ -13,6 +13,7 @@ export const store = createStore({ current_tab: Tabs.PLAY, developer_mode: false, game_path: "this/is/the/game/path", + install_type: undefined, installed_northstar_version: "", northstar_state: NorthstarState.INSTALL, @@ -77,17 +78,36 @@ export const store = createStore({ return; } - // Show an error message if Origin is not running. - if (!state.origin_is_running) { - ElNotification({ - title: 'Origin is not running', - message: "Northstar cannot launch while you're not authenticated with Origin.", - type: 'warning', - position: 'bottom-right' - }); - } + // Game is ready to play + if (state.northstar_state === NorthstarState.READY_TO_PLAY) { + // Show an error message if Origin is not running. + if (!state.origin_is_running) { + ElNotification({ + title: 'Origin is not running', + message: "Northstar cannot launch while you're not authenticated with Origin.", + type: 'warning', + position: 'bottom-right' + }); - // TODO launch game + // If Origin isn't running, end here + return; + } + + let game_install = { + game_path: state.game_path, + install_type: state.install_type + } as GameInstall; + await invoke("launch_northstar_caller", { gameInstall: game_install }) + .then((message) => { + console.log(message); + // NorthstarState.RUNNING + }) + .catch((error) => { + console.error(error); + alert(error); + }); + return; + } } } }); @@ -104,6 +124,7 @@ async function _initializeApp(state: any) { alert(err); }); state.game_path = result.game_path; + state.install_type = result.install_type; // Check installed Northstar version if found await _get_northstar_version_number(state); -- cgit v1.2.3 From a17edbf0cc2da4997048dd4196e7bfb3d8d2b21f Mon Sep 17 00:00:00 2001 From: GeckoEidechse Date: Sun, 2 Oct 2022 13:17:34 +0200 Subject: refactor: Use enum for install type Same way like in backend code --- src-vue/src/plugins/store.ts | 3 ++- src-vue/src/utils/InstallType.ts | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 src-vue/src/utils/InstallType.ts (limited to 'src-vue/src/plugins') diff --git a/src-vue/src/plugins/store.ts b/src-vue/src/plugins/store.ts index 6914150c..87c8921f 100644 --- a/src-vue/src/plugins/store.ts +++ b/src-vue/src/plugins/store.ts @@ -1,6 +1,7 @@ import { createStore } from 'vuex'; import { listen, Event as TauriEvent } from "@tauri-apps/api/event"; import {Tabs} from "../utils/Tabs"; +import {InstallType} from "../utils/InstallType"; import {invoke} from "@tauri-apps/api"; import {GameInstall} from "../utils/GameInstall"; import {ReleaseCanal} from "../utils/ReleaseCanal"; @@ -124,7 +125,7 @@ async function _initializeApp(state: any) { alert(err); }); state.game_path = result.game_path; - state.install_type = result.install_type; + state.install_type = result.install_type as InstallType; // Check installed Northstar version if found await _get_northstar_version_number(state); diff --git a/src-vue/src/utils/InstallType.ts b/src-vue/src/utils/InstallType.ts new file mode 100644 index 00000000..4e992ab2 --- /dev/null +++ b/src-vue/src/utils/InstallType.ts @@ -0,0 +1,7 @@ +// Enumerates the way Titanfall2 could be installed (Steam/Origin/EA-Desktop) +export enum InstallType { + STEAM = 'STEAM', + ORIGIN = 'ORIGIN', + EAPLAY = 'EAPLAY', + UNKNOWN = 'UNKNOWN', // used when the install location was manually selected +} -- cgit v1.2.3