diff options
Diffstat (limited to 'src-vue/src/views/SettingsView.vue')
-rw-r--r-- | src-vue/src/views/SettingsView.vue | 74 |
1 files changed, 73 insertions, 1 deletions
diff --git a/src-vue/src/views/SettingsView.vue b/src-vue/src/views/SettingsView.vue index dcc787ae..b1a62c56 100644 --- a/src-vue/src/views/SettingsView.vue +++ b/src-vue/src/views/SettingsView.vue @@ -1,4 +1,14 @@ <template> + <el-dialog + v-model="showProfileDialog" + :title="$t('settings.profile.dialog.title')" + width="75%" + > + <el-table :data="availableProfiles" > + <el-table-column prop="name" label="Name" /> + </el-table> + </el-dialog> + <div class="fc-container"> <el-scrollbar> <div class="fc_settings__container"> @@ -21,6 +31,22 @@ </el-input> </div> + <!-- Northstar Active Profile --> + <div class="fc_parameter__panel" v-if="$store.state.developer_mode"> + <h3>{{ $t('settings.profile.active') }}</h3> + <el-dropdown trigger="click"> + <el-button> + {{ $store.state.game_install.profile }} <el-icon class="el-icon--right"><arrow-down /></el-icon> + </el-button> + <template #dropdown> + <el-dropdown-menu> + <el-dropdown-item v-for="profile in $store.state.available_profiles" @click="switchProfile(profile)">{{ profile }}</el-dropdown-item> + <el-dropdown-item divided @click="showProfileDialog = true">{{ $t('settings.profile.edit') }}</el-dropdown-item> + </el-dropdown-menu> + </template> + </el-dropdown> + </div> + <!-- Thunderstore mods per page configuration --> <div class="fc_parameter__panel"> <h3>{{ $t('settings.nb_ts_mods_per_page') }}</h3> @@ -96,6 +122,7 @@ import { showErrorNotification, showNotification } from "../utils/ui"; import LanguageSelector from "../components/LanguageSelector.vue"; const persistentStore = new Store('flight-core-settings.json'); import { open } from '@tauri-apps/api/shell'; +import { i18n } from '../main'; export default defineComponent({ name: "SettingsView", @@ -104,7 +131,8 @@ export default defineComponent({ }, data() { return { - developerModeClicks: 0 + developerModeClicks: 0, + showProfileDialog: false, } }, computed: { @@ -144,6 +172,17 @@ export default defineComponent({ persistentStore.set('thunderstore-mods-per-page', { value }); await persistentStore.save(); // explicit save to disk } + }, + availableProfiles(): Object { + let profiles = this.$store.state.available_profiles + + // convert string array to object array so we can fill a table + let data = profiles.reduce( + (a: Object[], v: string) => [...a, {"name": v}], + [] + ); + + return data; } }, methods: { @@ -172,6 +211,39 @@ export default defineComponent({ async openGameInstallFolder() { // Opens the folder in default file explorer application await open(`${this.$store.state.game_install.game_path}`); + }, + async switchProfile(value: string) { + let store = this.$store; + let state = store.state; + + await invoke("validate_profile", { gameInstall: state.game_install, profile: value }) + .then(async (message) => { + if (!message) + { + // Profile is no longer valid, inform the user... + showErrorNotification( + i18n.global.tc('notification.profile.invalid.text'), + i18n.global.tc('notification.profile.invalid.title') + ); + + // ...and refresh + store.commit('fetchProfiles'); + return; + } + + state.game_install.profile = value; + + // Check for Northstar updates + store.commit('checkNorthstarUpdates'); + + // Save change in persistent store + await persistentStore.set('game-install', { value: state.game_install }); + await persistentStore.save(); // explicit save to disk + }) + .catch((error) => { + console.error(error); + showErrorNotification(error); + }); } }, mounted() { |