diff options
author | Alystrasz <contact@remyraes.com> | 2022-10-03 21:58:16 +0200 |
---|---|---|
committer | Alystrasz <contact@remyraes.com> | 2022-10-03 21:58:16 +0200 |
commit | 6665621da87811d2f219b83b21fb705b538dca90 (patch) | |
tree | 10258b287903538f3259ab38c820532db7646819 /src-vue/src/views/SettingsView.vue | |
parent | 02127ed8793e5344c28fa9c7c2c16c7a0b3f3ae9 (diff) | |
download | FlightCore-6665621da87811d2f219b83b21fb705b538dca90.tar.gz FlightCore-6665621da87811d2f219b83b21fb705b538dca90.zip |
feat: implement updateGamePath method
Diffstat (limited to 'src-vue/src/views/SettingsView.vue')
-rw-r--r-- | src-vue/src/views/SettingsView.vue | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/src-vue/src/views/SettingsView.vue b/src-vue/src/views/SettingsView.vue index e0ffc026..0e5498e9 100644 --- a/src-vue/src/views/SettingsView.vue +++ b/src-vue/src/views/SettingsView.vue @@ -18,17 +18,53 @@ </template> <script lang="ts"> -export default { +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", methods: { - updateGamePath() { - console.log('TODO: update path'); + 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' + }); + } + } } }, mounted() { document.querySelector('input')!.disabled = true; } -} +}); </script> <style scoped> |