From 8b96f540dd5b8549f737df74e9d5a8e52ff15c70 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Sat, 24 Sep 2022 22:16:03 +0200 Subject: feat: add a "see patch notes" link to main view --- src-vue/src/utils/Tabs.ts | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src-vue/src/utils/Tabs.ts (limited to 'src-vue/src/utils') diff --git a/src-vue/src/utils/Tabs.ts b/src-vue/src/utils/Tabs.ts new file mode 100644 index 00000000..5266da81 --- /dev/null +++ b/src-vue/src/utils/Tabs.ts @@ -0,0 +1,6 @@ +export enum Tabs { + PLAY = 'Play', + CHANGELOG = 'Changelog', + SETTINGS = 'Settings', + DEV = 'Dev' +} -- cgit v1.2.3 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/src/utils') 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 From 634a0581c68e01d7f5155f369e1350010e7f7e91 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Sun, 25 Sep 2022 12:39:39 +0200 Subject: feat: load northstar version in app state --- src-vue/src/plugins/store.ts | 22 +++++++++++++++++++++- src-vue/src/utils/ReleaseCanal.ts | 4 ++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 src-vue/src/utils/ReleaseCanal.ts (limited to 'src-vue/src/utils') diff --git a/src-vue/src/plugins/store.ts b/src-vue/src/plugins/store.ts index 545f5484..98ad2342 100644 --- a/src-vue/src/plugins/store.ts +++ b/src-vue/src/plugins/store.ts @@ -3,6 +3,7 @@ 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"; +import {ReleaseCanal} from "../utils/ReleaseCanal"; export const store = createStore({ state () { @@ -11,7 +12,7 @@ export const store = createStore({ developer_mode: false, game_path: "this/is/the/game/path", - installed_northstar_version: "1.9.7", + installed_northstar_version: "Unknown version", northstar_is_running: false, origin_is_running: false @@ -41,6 +42,9 @@ async function _initializeApp(state: any) { alert(err); }); state.game_path = result.game_path; + + // Check installed Northstar version if found + await _get_northstar_version_number_and_set_button_accordingly(state); } // TODO @@ -60,3 +64,19 @@ function _initializeListeners(state: any) { state.northstar_is_running = evt.payload as boolean; }); } + +async function _get_northstar_version_number_and_set_button_accordingly(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; + + await invoke("check_is_northstar_outdated", { gamePath: state.game_path, northstarPackageName: ReleaseCanal.RELEASE }) + .then((message) => { + console.log(message); + }) + .catch((error) => { + console.error(error); + alert(error); + }); + } +} diff --git a/src-vue/src/utils/ReleaseCanal.ts b/src-vue/src/utils/ReleaseCanal.ts new file mode 100644 index 00000000..ca1ba8a5 --- /dev/null +++ b/src-vue/src/utils/ReleaseCanal.ts @@ -0,0 +1,4 @@ +export enum ReleaseCanal { + RELEASE = 'Northstar', + RELEASE_CANDIDATE = 'NorthstarReleaseCandidate' +} -- cgit v1.2.3 From 238e340ffb4d1af175e29567a772a0790174fdff Mon Sep 17 00:00:00 2001 From: Alystrasz Date: Tue, 27 Sep 2022 23:33:17 +0200 Subject: feat: we can now install Northstar if it wasn't detected --- src-vue/src/plugins/store.ts | 27 ++++++++++++++++++++++++--- src-vue/src/utils/NorthstarState.ts | 7 +++++++ src-vue/src/views/PlayView.vue | 21 ++++++++++++++++++++- 3 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 src-vue/src/utils/NorthstarState.ts (limited to 'src-vue/src/utils') 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); diff --git a/src-vue/src/utils/NorthstarState.ts b/src-vue/src/utils/NorthstarState.ts new file mode 100644 index 00000000..d6e31923 --- /dev/null +++ b/src-vue/src/utils/NorthstarState.ts @@ -0,0 +1,7 @@ +export enum NorthstarState { + INSTALL, + INSTALLING, + MUST_UPDATE, + UPDATING, + READY_TO_PLAY +} \ No newline at end of file diff --git a/src-vue/src/views/PlayView.vue b/src-vue/src/views/PlayView.vue index 02d59b15..03f54936 100644 --- a/src-vue/src/views/PlayView.vue +++ b/src-vue/src/views/PlayView.vue @@ -1,5 +1,6 @@