aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Raes <contact@remyraes.com>2022-10-02 17:28:42 +0200
committerGitHub <noreply@github.com>2022-10-02 17:28:42 +0200
commit7fee06ec0b746340667e12c003ff7b9f0e2f1143 (patch)
tree536ead7786940a30afed5b719243813bf0e23cef
parent2a32f80aedec671d812142cbbe2d0a461a4094e4 (diff)
parent52394a3e86373801f5285843d6931a692a619be1 (diff)
downloadFlightCore-7fee06ec0b746340667e12c003ff7b9f0e2f1143.tar.gz
FlightCore-7fee06ec0b746340667e12c003ff7b9f0e2f1143.zip
Merge pull request #3 from GeckoEidechse/add-launch-functionality
Add launch functionality
-rw-r--r--src-vue/src/plugins/store.ts42
-rw-r--r--src-vue/src/utils/InstallType.ts8
2 files changed, 40 insertions, 10 deletions
diff --git a/src-vue/src/plugins/store.ts b/src-vue/src/plugins/store.ts
index 7fdc7814..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";
@@ -13,6 +14,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 +79,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 +125,7 @@ async function _initializeApp(state: any) {
alert(err);
});
state.game_path = result.game_path;
+ 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..797f4077
--- /dev/null
+++ b/src-vue/src/utils/InstallType.ts
@@ -0,0 +1,8 @@
+// Enumerates the way Titanfall2 could be installed (Steam/Origin/EA-Desktop)
+// Needs to be synced with `pub enum InstallType` in /src-tauri/src/lib.rs
+export enum InstallType {
+ STEAM = 'STEAM',
+ ORIGIN = 'ORIGIN',
+ EAPLAY = 'EAPLAY',
+ UNKNOWN = 'UNKNOWN', // used when the install location was manually selected
+}