aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src-tauri/src/lib.rs6
-rw-r--r--src-vue/src/components/PlayButton.vue2
-rw-r--r--src-vue/src/plugins/store.ts54
-rw-r--r--src-vue/src/views/SettingsView.vue36
4 files changed, 58 insertions, 40 deletions
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index 38acf069..6a44514d 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -267,7 +267,8 @@ pub fn launch_northstar(game_install: GameInstall) -> Result<String, String> {
// Explicetly fail early certain (currently) unsupported install setups
if host_os != "windows"
|| !(matches!(game_install.install_type, InstallType::STEAM)
- || matches!(game_install.install_type, InstallType::ORIGIN))
+ || matches!(game_install.install_type, InstallType::ORIGIN)
+ || matches!(game_install.install_type, InstallType::UNKNOWN))
{
return Err(format!(
"Not yet implemented for \"{}\" with Titanfall2 installed via \"{:?}\"",
@@ -294,7 +295,8 @@ pub fn launch_northstar(game_install: GameInstall) -> Result<String, String> {
// Only Windows with Steam or Origin are supported at the moment
if host_os == "windows"
&& (matches!(game_install.install_type, InstallType::STEAM)
- || matches!(game_install.install_type, InstallType::ORIGIN))
+ || matches!(game_install.install_type, InstallType::ORIGIN)
+ || matches!(game_install.install_type, InstallType::UNKNOWN))
{
let _output =
std::process::Command::new(format!("{}/NorthstarLauncher.exe", game_install.game_path))
diff --git a/src-vue/src/components/PlayButton.vue b/src-vue/src/components/PlayButton.vue
index 8e0b4149..ff57e706 100644
--- a/src-vue/src/components/PlayButton.vue
+++ b/src-vue/src/components/PlayButton.vue
@@ -13,7 +13,7 @@ export default defineComponent({
switch(this.$store.state.northstar_state) {
case NorthstarState.GAME_NOT_FOUND:
- return "Titanfall2 not found";
+ return "Select Titanfall2 game folder";
case NorthstarState.INSTALL:
return "Install";
case NorthstarState.INSTALLING:
diff --git a/src-vue/src/plugins/store.ts b/src-vue/src/plugins/store.ts
index 647ee4e9..ce0b0ded 100644
--- a/src-vue/src/plugins/store.ts
+++ b/src-vue/src/plugins/store.ts
@@ -5,8 +5,10 @@ import { InstallType } from "../utils/InstallType";
import { invoke } from "@tauri-apps/api";
import { GameInstall } from "../utils/GameInstall";
import { ReleaseCanal } from "../utils/ReleaseCanal";
-import { ElNotification } from 'element-plus';
+import { ElNotification, NotificationHandle } from 'element-plus';
import { NorthstarState } from '../utils/NorthstarState';
+import { appDir } from '@tauri-apps/api/path';
+import { open } from '@tauri-apps/api/dialog';
import { Store } from 'tauri-plugin-store-api';
const persistentStore = new Store('flight-core-settings.json');
@@ -28,6 +30,8 @@ export interface FlightCoreStore {
origin_is_running: boolean
}
+let notification_handle: NotificationHandle;
+
export const store = createStore<FlightCoreStore>({
state (): FlightCoreStore {
return {
@@ -66,6 +70,48 @@ export const store = createStore<FlightCoreStore>({
updateCurrentTab(state: any, newTab: Tabs) {
state.current_tab = newTab;
},
+ async updateGamePath(state: FlightCoreStore) {
+ // Open a selection dialog for directories
+ const selected = await open({
+ directory: true,
+ multiple: false,
+ defaultPath: await appDir(),
+ });
+ if (Array.isArray(selected)) {
+ // user selected multiple directories
+ alert("Please only select a single directory");
+ } else if (selected === null) {
+ // user cancelled the selection
+ } else {
+ // user selected a single directory
+
+ // Verify if valid Titanfall2 install location
+ let is_valid_titanfall2_install = await invoke("verify_install_location", { gamePath: selected }) as boolean;
+ if (is_valid_titanfall2_install) {
+ state.game_path = selected;
+ ElNotification({
+ title: 'New game folder',
+ message: "Game folder was successfully updated.",
+ type: 'success',
+ position: 'bottom-right'
+ });
+ notification_handle.close();
+ state.install_type = InstallType.UNKNOWN;
+
+ // Check for Northstar install
+ store.commit('checkNorthstarUpdates');
+ }
+ else {
+ // Not valid Titanfall2 install
+ ElNotification({
+ title: 'Wrong folder',
+ message: "Selected folder is not a valid Titanfall2 install.",
+ type: 'error',
+ position: 'bottom-right'
+ });
+ }
+ }
+ },
async launchGame(state: any) {
// TODO update installation if release track was switched
switch (state.northstar_state) {
@@ -131,6 +177,10 @@ export const store = createStore<FlightCoreStore>({
alert(error);
});
break;
+
+ case NorthstarState.GAME_NOT_FOUND:
+ store.commit('updateGamePath');
+ break;
}
}
}
@@ -163,7 +213,7 @@ async function _initializeApp(state: any) {
.catch((err) => {
// Gamepath not found or other error
console.error(err);
- ElNotification({
+ notification_handle = ElNotification({
title: 'Titanfall2 not found!',
message: "Please manually select install location",
type: 'error',
diff --git a/src-vue/src/views/SettingsView.vue b/src-vue/src/views/SettingsView.vue
index 5dd4e2b9..acc1874d 100644
--- a/src-vue/src/views/SettingsView.vue
+++ b/src-vue/src/views/SettingsView.vue
@@ -21,11 +21,7 @@
</template>
<script lang="ts">
-import { open } from '@tauri-apps/api/dialog';
-import { appDir } from '@tauri-apps/api/path';
-import { invoke } from "@tauri-apps/api";
import { defineComponent } from "vue";
-import { ElNotification } from 'element-plus';
export default defineComponent({
name: "SettingsView",
@@ -36,37 +32,7 @@ export default defineComponent({
},
methods: {
async updateGamePath() {
- // Open a selection dialog for directories
- const selected = await open({
- directory: true,
- multiple: false,
- defaultPath: await appDir(),
- });
- if (Array.isArray(selected)) {
- // user selected multiple directories
- alert("Please only select a single directory");
- } else if (selected === null) {
- // user cancelled the selection
- } else {
- // user selected a single directory
-
- // Verify if valid Titanfall2 install location
- let is_valid_titanfall2_install = await invoke("verify_install_location", { gamePath: selected }) as boolean;
- if (is_valid_titanfall2_install) {
- this.$store.state.game_path = selected;
- // Check for Northstar install
- this.$store.commit('checkNorthstarUpdates');
- }
- else {
- // Not valid Titanfall2 install
- ElNotification({
- title: 'Wrong folder',
- message: "Selected folder is not a valid Titanfall2 install.",
- type: 'error',
- position: 'bottom-right'
- });
- }
- }
+ this.$store.commit('updateGamePath');
}
},
mounted() {