diff options
author | GeckoEidechse <gecko.eidechse+git@pm.me> | 2023-07-24 14:18:04 +0200 |
---|---|---|
committer | GeckoEidechse <gecko.eidechse+git@pm.me> | 2023-07-24 14:18:04 +0200 |
commit | 5042bb767d73f9eaacf50de02a9ca3bbbe649c12 (patch) | |
tree | c03d252980ef3b6a0eb980e8990144e2edaa3084 | |
parent | d0b8eefd3a338ac0831c9e8fda10a936fb4adc0d (diff) | |
parent | 399f0e78b4773aa97a8a80c43fb2312ea830a845 (diff) | |
download | FlightCore-5042bb767d73f9eaacf50de02a9ca3bbbe649c12.tar.gz FlightCore-5042bb767d73f9eaacf50de02a9ca3bbbe649c12.zip |
Merge branch 'main' into feat/calculate-checksums-install-folder
-rw-r--r-- | src-tauri/Cargo.lock | 2 | ||||
-rw-r--r-- | src-tauri/Cargo.toml | 2 | ||||
-rw-r--r-- | src-tauri/src/mod_management/mod.rs | 7 | ||||
-rw-r--r-- | src-tauri/src/mod_management/plugins.rs | 26 | ||||
-rw-r--r-- | src-tauri/tauri.conf.json | 2 | ||||
-rw-r--r-- | src-vue/src/components/LocalModCard.vue | 15 | ||||
-rw-r--r-- | src-vue/src/components/ThunderstoreModCard.vue | 15 | ||||
-rw-r--r-- | src-vue/src/plugins/modules/pull_requests.ts | 4 | ||||
-rw-r--r-- | src-vue/src/plugins/store.ts | 55 | ||||
-rw-r--r-- | src-vue/src/views/DeveloperView.vue | 22 | ||||
-rw-r--r-- | src-vue/src/views/RepairView.vue | 26 | ||||
-rw-r--r-- | src-vue/src/views/SettingsView.vue | 4 |
12 files changed, 66 insertions, 114 deletions
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index dca74714..66c1206c 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -81,7 +81,7 @@ checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" [[package]] name = "app" -version = "2.1.0" +version = "2.2.0" dependencies = [ "anyhow", "async-recursion", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 50e75987..ae658087 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "app" -version = "2.1.0" +version = "2.2.0" description = "A Tauri App" authors = ["you"] license = "" diff --git a/src-tauri/src/mod_management/mod.rs b/src-tauri/src/mod_management/mod.rs index 0d4edd87..879d3b04 100644 --- a/src-tauri/src/mod_management/mod.rs +++ b/src-tauri/src/mod_management/mod.rs @@ -12,6 +12,7 @@ use std::string::ToString; use std::{fs, path::PathBuf}; mod legacy; +mod plugins; use crate::GameInstall; #[derive(Debug, Clone)] @@ -498,8 +499,10 @@ fn fc_sanity_check(input: &&fs::File) -> bool { if file_path.starts_with("plugins/") { if let Some(name) = file_path.file_name() { if name.to_str().unwrap().contains(".dll") { - log::warn!("Plugin detected, skipping"); - return false; // We disallow plugins for now + log::warn!("Plugin detected, prompting user"); + if !plugins::plugin_prompt() { + return false; // Plugin detected and user denied install + } } } } diff --git a/src-tauri/src/mod_management/plugins.rs b/src-tauri/src/mod_management/plugins.rs new file mode 100644 index 00000000..e2427a16 --- /dev/null +++ b/src-tauri/src/mod_management/plugins.rs @@ -0,0 +1,26 @@ +use tauri::api::dialog::blocking::MessageDialogBuilder; +use tauri::api::dialog::{MessageDialogButtons, MessageDialogKind}; + +/// Prompt on plugin +/// Returns: +/// - true: user accepted plugin install +/// - false: user denied plugin install +pub fn plugin_prompt() -> bool { + let dialog = MessageDialogBuilder::new( + "Plugin in package detected", + "This mod contains a plugin. Plugins have unrestricted access to your computer! + \nMake sure you trust the author! + \n + \nPress 'Ok' to continue or 'Cancel' to abort mod installation", + ) + .kind(MessageDialogKind::Warning) + .buttons(MessageDialogButtons::OkCancel); + + if dialog.show() { + log::info!("Accepted plugin install"); + true + } else { + log::warn!("Plugin install cancelled"); + false + } +} diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 9b048e50..245915f0 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -8,7 +8,7 @@ }, "package": { "productName": "FlightCore", - "version": "2.1.0" + "version": "2.2.0" }, "tauri": { "allowlist": { diff --git a/src-vue/src/components/LocalModCard.vue b/src-vue/src/components/LocalModCard.vue index dd3629f8..f8d0256d 100644 --- a/src-vue/src/components/LocalModCard.vue +++ b/src-vue/src/components/LocalModCard.vue @@ -30,7 +30,6 @@ import { defineComponent } from "vue"; import { invoke } from "@tauri-apps/api"; import { NorthstarMod } from "../../../src-tauri/bindings/NorthstarMod"; -import { GameInstall } from "../utils/GameInstall"; import { showErrorNotification, showNotification } from "../utils/ui"; export default defineComponent({ @@ -50,16 +49,10 @@ export default defineComponent({ async updateWhichModsEnabled(mod: NorthstarMod) { this.global_load_indicator = true; - // Setup up struct - let game_install = { - game_path: this.$store.state.game_path, - install_type: this.$store.state.install_type - } as GameInstall; - // enable/disable specific mod try { await invoke("set_mod_enabled_status", { - gameInstall: game_install, + gameInstall: this.$store.state.game_install, modName: mod.name, // Need to set it to the opposite of current state, // as current state is only updated after command is run @@ -76,11 +69,7 @@ export default defineComponent({ return true; }, async deleteMod(mod: NorthstarMod) { - let game_install = { - game_path: this.$store.state.game_path, - install_type: this.$store.state.install_type - } as GameInstall; - await invoke("delete_northstar_mod", { gameInstall: game_install, nsmodName: mod.name }) + await invoke("delete_northstar_mod", { gameInstall: this.$store.state.game_install, nsmodName: mod.name }) .then((message) => { // Just a visual indicator that it worked showNotification(this.$t('mods.local.success_deleting', { modName: mod.name })); diff --git a/src-vue/src/components/ThunderstoreModCard.vue b/src-vue/src/components/ThunderstoreModCard.vue index 2fbbac40..30ffbc68 100644 --- a/src-vue/src/components/ThunderstoreModCard.vue +++ b/src-vue/src/components/ThunderstoreModCard.vue @@ -71,7 +71,6 @@ import { ThunderstoreModVersion } from "../../../src-tauri/bindings/Thunderstore import { invoke, shell } from "@tauri-apps/api"; import { ThunderstoreModStatus } from "../utils/thunderstore/ThunderstoreModStatus"; import { NorthstarMod } from "../../../src-tauri/bindings/NorthstarMod"; -import { GameInstall } from "../utils/GameInstall"; import { NorthstarState } from "../utils/NorthstarState"; import { ElMessageBox } from "element-plus"; import { showErrorNotification, showNotification } from "../utils/ui"; @@ -217,12 +216,7 @@ export default defineComponent({ } ) .then(async () => { // Deletion confirmed - let game_install = { - game_path: this.$store.state.game_path, - install_type: this.$store.state.install_type - } as GameInstall; - - await invoke<string>("delete_thunderstore_mod", { gameInstall: game_install, thunderstoreModString: this.latestVersion.full_name }) + await invoke<string>("delete_thunderstore_mod", { gameInstall: this.$store.state.game_install, thunderstoreModString: this.latestVersion.full_name }) .then((message) => { showNotification(this.$t('mods.card.remove_success', { modName: mod.name }), message); }) @@ -239,11 +233,6 @@ export default defineComponent({ }, async installMod(mod: ThunderstoreMod) { - let game_install = { - game_path: this.$store.state.game_path, - install_type: this.$store.state.install_type - } as GameInstall; - // set internal state according to current installation state if (this.modStatus === ThunderstoreModStatus.OUTDATED) { this.isBeingUpdated = true; @@ -254,7 +243,7 @@ export default defineComponent({ // Capture translation method in a context, so it can be used outside Vue component context. // (see https://github.com/R2NorthstarTools/FlightCore/issues/384) (async (translate: Function) => { - await invoke<string>("install_mod_caller", { gameInstall: game_install, thunderstoreModString: this.latestVersion.full_name }).then((message) => { + await invoke<string>("install_mod_caller", { gameInstall: this.$store.state.game_install, thunderstoreModString: this.latestVersion.full_name }).then((message) => { showNotification(translate('mods.card.install_success', { modName: mod.name }), message); }) .catch((error) => { diff --git a/src-vue/src/plugins/modules/pull_requests.ts b/src-vue/src/plugins/modules/pull_requests.ts index 57d5fa07..3f3ba259 100644 --- a/src-vue/src/plugins/modules/pull_requests.ts +++ b/src-vue/src/plugins/modules/pull_requests.ts @@ -54,7 +54,7 @@ export const pullRequestModule = { // Send notification telling the user to wait for the process to finish const notification = showNotification(`Installing launcher PR ${pull_request.number}`, 'Please wait', 'info', 0); - await invoke("apply_launcher_pr", { pullRequest: pull_request, gameInstallPath: store.state.game_path }) + await invoke("apply_launcher_pr", { pullRequest: pull_request, gameInstallPath: store.state.game_install.game_path }) .then((message) => { console.log(message); // Show user notification if mod install completed. @@ -72,7 +72,7 @@ export const pullRequestModule = { // Send notification telling the user to wait for the process to finish const notification = showNotification(`Installing mods PR ${pull_request.number}`, 'Please wait', 'info', 0); - await invoke("apply_mods_pr", { pullRequest: pull_request, gameInstallPath: store.state.game_path }) + await invoke("apply_mods_pr", { pullRequest: pull_request, gameInstallPath: store.state.game_install.game_path }) .then((message) => { // Show user notification if mod install completed. showNotification( diff --git a/src-vue/src/plugins/store.ts b/src-vue/src/plugins/store.ts index e7dc0763..37d0d89d 100644 --- a/src-vue/src/plugins/store.ts +++ b/src-vue/src/plugins/store.ts @@ -25,8 +25,7 @@ const persistentStore = new Store('flight-core-settings.json'); export interface FlightCoreStore { developer_mode: boolean, - game_path: string, - install_type: InstallType, + game_install: GameInstall, flightcore_version: string, @@ -61,8 +60,7 @@ export const store = createStore<FlightCoreStore>({ state(): FlightCoreStore { return { developer_mode: false, - game_path: undefined as unknown as string, - install_type: undefined as unknown as InstallType, + game_install: {} as unknown as GameInstall, flightcore_version: "", @@ -133,7 +131,7 @@ export const store = createStore<FlightCoreStore>({ // 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; + state.game_install.game_path = selected; showNotification( i18n.global.tc('notification.game_folder.new.title'), i18n.global.tc('notification.game_folder.new.text') @@ -144,15 +142,10 @@ export const store = createStore<FlightCoreStore>({ catch { console.warn("Nothing to close"); } - state.install_type = InstallType.UNKNOWN; - - let game_install = { - game_path: selected, - install_type: InstallType.UNKNOWN - } as GameInstall; + state.game_install.install_type = InstallType.UNKNOWN; // Save change in persistent store - await persistentStore.set('game-install', { value: game_install }); + await persistentStore.set('game-install', { value: state.game_install }); await persistentStore.save(); // explicit save to disk // Check for Northstar install @@ -168,13 +161,8 @@ export const store = createStore<FlightCoreStore>({ } }, async launchGame(state: any, no_checks = false) { - let game_install = { - game_path: state.game_path, - install_type: state.install_type - } as GameInstall; - if (no_checks) { - await invoke("launch_northstar", { gameInstall: game_install, bypassChecks: no_checks }) + await invoke("launch_northstar", { gameInstall: state.game_install, bypassChecks: no_checks }) .then((message) => { console.log("Launched with bypassed checks"); console.log(message); @@ -191,7 +179,7 @@ export const store = createStore<FlightCoreStore>({ switch (state.northstar_state) { // Install northstar if it wasn't detected. case NorthstarState.INSTALL: - let install_northstar_result = invoke("install_northstar_caller", { gamePath: state.game_path, northstarPackageName: state.northstar_release_canal }); + let install_northstar_result = invoke("install_northstar_caller", { gamePath: state.game_install.game_path, northstarPackageName: state.northstar_release_canal }); state.northstar_state = NorthstarState.INSTALLING; await install_northstar_result.then((message) => { @@ -208,7 +196,7 @@ export const store = createStore<FlightCoreStore>({ // Update northstar if it is outdated. case NorthstarState.MUST_UPDATE: // Updating is the same as installing, simply overwrites the existing files - let reinstall_northstar_result = invoke("install_northstar_caller", { gamePath: state.game_path, northstarPackageName: state.northstar_release_canal }); + let reinstall_northstar_result = invoke("install_northstar_caller", { gamePath: state.game_install.game_path, northstarPackageName: state.northstar_release_canal }); state.northstar_state = NorthstarState.UPDATING; await reinstall_northstar_result.then((message) => { @@ -224,7 +212,7 @@ export const store = createStore<FlightCoreStore>({ // Game is ready to play. case NorthstarState.READY_TO_PLAY: - await invoke("launch_northstar", { gameInstall: game_install }) + await invoke("launch_northstar", { gameInstall: state.game_install }) .then((message) => { console.log(message); // NorthstarState.RUNNING @@ -241,12 +229,7 @@ export const store = createStore<FlightCoreStore>({ } }, async launchGameSteam(state: any, no_checks = false) { - let game_install = { - game_path: state.game_path, - install_type: state.install_type - } as GameInstall; - - await invoke("launch_northstar_steam", { gameInstall: game_install, bypassChecks: no_checks }) + await invoke("launch_northstar_steam", { gameInstall: state.game_install, bypassChecks: no_checks }) .then((message) => { showNotification('Success'); }) @@ -295,19 +278,14 @@ export const store = createStore<FlightCoreStore>({ .sort(); }, async loadInstalledMods(state: FlightCoreStore) { - let game_install = { - game_path: state.game_path, - install_type: state.install_type - } as GameInstall; - // If there's no game path, prevent looking for installed mods. - if (state.game_path === undefined) { - console.warn('Cannot load installed mods since so game path is selected.'); + if (state.game_install.game_path === undefined) { + console.warn('Cannot load installed mods since no game path is selected.'); return; } // Call back-end for installed mods - await invoke("get_installed_mods_and_properties", { gameInstall: game_install }) + await invoke("get_installed_mods_and_properties", { gameInstall: state.game_install }) .then((message) => { state.installed_mods = (message as NorthstarMod[]); }) @@ -425,8 +403,7 @@ async function _initializeApp(state: any) { await persistentStore.save(); // explicit save to disk // Update UI store - state.game_path = typedResult.game_path; - state.install_type = typedResult.install_type; + state.game_install = typedResult; // Check installed Northstar version if found await _get_northstar_version_number(state); @@ -482,13 +459,13 @@ function _initializeListeners(state: any) { * state, for it to be displayed in UI. */ async function _get_northstar_version_number(state: any) { - await invoke("get_northstar_version_number", { gamePath: state.game_path }) + await invoke("get_northstar_version_number", { gamePath: state.game_install.game_path }) .then((message) => { let northstar_version_number: string = message as string; state.installed_northstar_version = northstar_version_number; state.northstar_state = NorthstarState.READY_TO_PLAY; - invoke("check_is_northstar_outdated", { gamePath: state.game_path, northstarPackageName: state.northstar_release_canal }) + invoke("check_is_northstar_outdated", { gamePath: state.game_install.game_path, northstarPackageName: state.northstar_release_canal }) .then((message) => { if (message) { state.northstar_state = NorthstarState.MUST_UPDATE; diff --git a/src-vue/src/views/DeveloperView.vue b/src-vue/src/views/DeveloperView.vue index 6a551781..af49c2be 100644 --- a/src-vue/src/views/DeveloperView.vue +++ b/src-vue/src/views/DeveloperView.vue @@ -150,7 +150,6 @@ <script lang="ts"> import { defineComponent } from "vue"; import { invoke } from "@tauri-apps/api"; -import { GameInstall } from "../utils/GameInstall"; import { TagWrapper } from "../../../src-tauri/bindings/TagWrapper"; import { NorthstarThunderstoreReleaseWrapper } from "../../../src-tauri/bindings/NorthstarThunderstoreReleaseWrapper"; import PullRequestsSelector from "../components/PullRequestsSelector.vue"; @@ -228,11 +227,7 @@ export default defineComponent({ this.$store.commit('launchGameSteam', true); }, async getInstalledMods() { - let game_install = { - game_path: this.$store.state.game_path, - install_type: this.$store.state.install_type - } as GameInstall; - await invoke("get_installed_mods_and_properties", { gameInstall: game_install }).then((message) => { + await invoke("get_installed_mods_and_properties", { gameInstall: this.$store.state.game_install }).then((message) => { // Simply console logging for now // In the future we should display the installed mods somewhere console.log(message); @@ -245,12 +240,8 @@ export default defineComponent({ }); }, async installMod() { - let game_install = { - game_path: this.$store.state.game_path, - install_type: this.$store.state.install_type - } as GameInstall; let mod_to_install = this.mod_to_install_field_string; - await invoke<string>("install_mod_caller", { gameInstall: game_install, thunderstoreModString: mod_to_install }).then((message) => { + await invoke<string>("install_mod_caller", { gameInstall: this.$store.state.game_install, thunderstoreModString: mod_to_install }).then((message) => { // Show user notification if mod install completed. showNotification(`Installed ${mod_to_install}`, message); }) @@ -285,7 +276,7 @@ export default defineComponent({ const notification = showNotification(`Installing git main`, 'Please wait', 'info', 0); - await invoke<string>("install_git_main", { gameInstallPath: this.$store.state.game_path }) + await invoke<string>("install_git_main", { gameInstallPath: this.$store.state.game_install.game_path }) .then((message) => { this.release_notes_text = message; showNotification("Done", `Installed launcher build from ${message}`); @@ -309,11 +300,6 @@ export default defineComponent({ }); }, async installNorthstarVersion() { - let game_install = { - game_path: this.$store.state.game_path, - install_type: this.$store.state.install_type - } as GameInstall; - // Send notification telling the user to wait for the process to finish const notification = showNotification( `Installing Northstar version v${this.selected_ns_version.value.version}`, @@ -322,7 +308,7 @@ export default defineComponent({ 0 ); - let install_northstar_result = invoke("install_northstar_caller", { gamePath: game_install.game_path, northstarPackageName: this.selected_ns_version.value.package, versionNumber: this.selected_ns_version.value.version }); + let install_northstar_result = invoke("install_northstar_caller", { gamePath: this.$store.state.game_install.game_path, northstarPackageName: this.selected_ns_version.value.package, versionNumber: this.selected_ns_version.value.version }); await install_northstar_result .then((message) => { diff --git a/src-vue/src/views/RepairView.vue b/src-vue/src/views/RepairView.vue index e284e824..614c1e56 100644 --- a/src-vue/src/views/RepairView.vue +++ b/src-vue/src/views/RepairView.vue @@ -54,11 +54,7 @@ export default defineComponent({ }, methods: { async disableAllModsButCore() { - let game_install = { - game_path: this.$store.state.game_path, - install_type: this.$store.state.install_type - } as GameInstall; - await invoke("disable_all_but_core", { gameInstall: game_install }) + await invoke("disable_all_but_core", { gameInstall: this.$store.state.game_install }) .then((message) => { showNotification(this.$t('generic.success'), this.$t('settings.repair.window.disable_all_but_core_success')); }) @@ -67,11 +63,6 @@ export default defineComponent({ }); }, async forceInstallNorthstar() { - let game_install = { - game_path: this.$store.state.game_path, - install_type: this.$store.state.install_type - } as GameInstall; - // Send notification telling the user to wait for the process to finish const notification = showNotification( this.$t('settings.repair.window.reinstall_title'), @@ -80,7 +71,7 @@ export default defineComponent({ 0 ); - let install_northstar_result = invoke("install_northstar_caller", { gamePath: game_install.game_path, northstarPackageName: ReleaseCanal.RELEASE }); + let install_northstar_result = invoke("install_northstar_caller", { gamePath: this.$store.state.game_install.game_path, northstarPackageName: ReleaseCanal.RELEASE }); appWindow.listen<InstallProgress>( 'northstar-install-download-progress', @@ -107,11 +98,7 @@ export default defineComponent({ }); }, async cleanUpDownloadFolder() { - let game_install = { - game_path: this.$store.state.game_path, - install_type: this.$store.state.install_type - } as GameInstall; - await invoke("clean_up_download_folder_caller", { gameInstall: game_install, force: true }).then((message) => { + await invoke("clean_up_download_folder_caller", { gameInstall: this.$store.state.game_install, force: true }).then((message) => { // Show user notification if task completed. showNotification(this.$t('generic.done'), this.$t('generic.done')); }) @@ -126,12 +113,7 @@ export default defineComponent({ await persistentStore.save(); }, async disableModsettingsMod() { - let game_install = { - game_path: this.$store.state.game_path, - install_type: this.$store.state.install_type - } as GameInstall; - - await invoke("set_mod_enabled_status", { gameInstall: game_install, modName: "Mod Settings", isEnabled: false }) + await invoke("set_mod_enabled_status", { gameInstall: this.$store.state.game_install, modName: "Mod Settings", isEnabled: false }) .then((message) => { showNotification(this.$t('generic.success'), this.$t('settings.repair.window.disable_modsettings_success')); }) diff --git a/src-vue/src/views/SettingsView.vue b/src-vue/src/views/SettingsView.vue index c4e94c80..dcc787ae 100644 --- a/src-vue/src/views/SettingsView.vue +++ b/src-vue/src/views/SettingsView.vue @@ -6,7 +6,7 @@ <div class="fc_parameter__panel"> <h3>{{ $t('settings.manage_install') }}</h3> <el-input - v-model="$store.state.game_path" + v-model="$store.state.game_install.game_path" :placeholder="$t('settings.choose_folder')" @click="updateGamePath" > @@ -171,7 +171,7 @@ export default defineComponent({ }, async openGameInstallFolder() { // Opens the folder in default file explorer application - await open(`${this.$store.state.game_path}`); + await open(`${this.$store.state.game_install.game_path}`); } }, mounted() { |