From aebcf4024b371441d3443beccad7be9419b06b95 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Wed, 6 Aug 2025 21:27:46 +0200 Subject: [PATCH 1/7] feat: add LaunchArgumentsSelector component --- .../components/LaunchArgumentsSelector.vue | 235 ++++++++++++++++++ src-vue/src/main.ts | 2 + src-vue/src/utils/LaunchArgument.ts | 9 + src-vue/src/views/SettingsView.vue | 10 +- 4 files changed, 255 insertions(+), 1 deletion(-) create mode 100644 src-vue/src/components/LaunchArgumentsSelector.vue create mode 100644 src-vue/src/utils/LaunchArgument.ts diff --git a/src-vue/src/components/LaunchArgumentsSelector.vue b/src-vue/src/components/LaunchArgumentsSelector.vue new file mode 100644 index 000000000..8f9c061b6 --- /dev/null +++ b/src-vue/src/components/LaunchArgumentsSelector.vue @@ -0,0 +1,235 @@ + + + + + \ No newline at end of file diff --git a/src-vue/src/main.ts b/src-vue/src/main.ts index 73219c9d7..60eb337d3 100644 --- a/src-vue/src/main.ts +++ b/src-vue/src/main.ts @@ -64,5 +64,7 @@ export const router = createRouter({ }); app.use(router); +// Store keys +export const argumentsStoreKey = 'launch_arguments'; app.mount('#app') diff --git a/src-vue/src/utils/LaunchArgument.ts b/src-vue/src/utils/LaunchArgument.ts new file mode 100644 index 000000000..55b907bd4 --- /dev/null +++ b/src-vue/src/utils/LaunchArgument.ts @@ -0,0 +1,9 @@ +export class LaunchArgument { + public argumentName: string; + public i18nEntry: string; + + constructor(argumentName: string, i18nEntry: string = '') { + this.argumentName = argumentName; + this.i18nEntry = i18nEntry; + } +} \ No newline at end of file diff --git a/src-vue/src/views/SettingsView.vue b/src-vue/src/views/SettingsView.vue index efc16e187..a29ef9230 100644 --- a/src-vue/src/views/SettingsView.vue +++ b/src-vue/src/views/SettingsView.vue @@ -67,6 +67,12 @@ + +
+

{{ $t('settings.launch_args.title') }}

+ +
+

{{ $t('settings.nb_ts_mods_per_page') }}

@@ -148,6 +154,7 @@ import { ReleaseCanal } from "../utils/ReleaseCanal"; import { load } from '@tauri-apps/plugin-store'; import { showErrorNotification, showNotification } from "../utils/ui"; import LanguageSelector from "../components/LanguageSelector.vue"; +import LaunchArgumentsSelector from "../components/LaunchArgumentsSelector.vue"; const persistentStore = await load('flight-core-settings.json', { autoSave: false }); import { open } from '@tauri-apps/plugin-shell'; import { i18n } from '../main'; @@ -156,7 +163,8 @@ import { ElMessageBox } from 'element-plus' export default defineComponent({ name: "SettingsView", components: { - LanguageSelector + LanguageSelector, + LaunchArgumentsSelector }, data() { return { From bd902c0a5e5031bfac62eb4412747eade67a2e32 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Wed, 6 Aug 2025 21:28:20 +0200 Subject: [PATCH 2/7] feat: add english+french translation --- src-vue/src/i18n/lang/en.json | 17 +++++++++++++++++ src-vue/src/i18n/lang/fr.json | 19 ++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src-vue/src/i18n/lang/en.json b/src-vue/src/i18n/lang/en.json index 4c3da49f3..b2812b5fa 100644 --- a/src-vue/src/i18n/lang/en.json +++ b/src-vue/src/i18n/lang/en.json @@ -145,6 +145,23 @@ "reinstall_text": "Please wait", "reinstall_success": "Successfully reinstalled Northstar" } + }, + + "launch_args": { + "title": "Launch arguments", + "new_arg_btn": "+ New launch argument", + "select_game_language": "Select game language", + "descriptions": { + "disablelogs": "Disable logging and creation of log files", + "vanilla": "Disables Northstar loading", + "northstar": "Enables Northstar loading", + "dedicated": "Starts a dedicated server without video output", + "waitfordebugger": "Waits for debugger to connect before launching game", + "enablechathooks": "Enables the use of chathooks for use by mods", + "noplugins": "Disables the plugin system", + "novid": "Disables startup videos", + "nosound": "Disables all game sounds" + } } }, diff --git a/src-vue/src/i18n/lang/fr.json b/src-vue/src/i18n/lang/fr.json index da9c2b1a0..3b444a2f4 100644 --- a/src-vue/src/i18n/lang/fr.json +++ b/src-vue/src/i18n/lang/fr.json @@ -131,7 +131,24 @@ "new_profile_name": "Entrez le nouveau nom du profil" } }, - "show_nsfw_mods": "Montrer les mods NSFW de Thunderstore" + "show_nsfw_mods": "Montrer les mods NSFW de Thunderstore", + + "launch_args": { + "title": "Paramètres de démarrage", + "new_arg_btn": "+ Nouveau paramètre", + "select_game_language": "Langage du jeu", + "descriptions": { + "disablelogs": "Désactive la journalisation et la création de journaux", + "vanilla": "Désactive le chargement de Northstar", + "northstar": "Active le chargement de Northstar", + "dedicated": "Démarre un serveur dédié sans sortie graphique", + "waitfordebugger": "Attend la connexion au débuggueur avant de lancer le jeu", + "enablechathooks": "Active les chathooks pour les mods", + "noplugins": "Désactive le système de plugins", + "novid": "Désactive les vidéos au démarrage", + "nosound": "Désactive tous les sons du jeu" + } + } }, "notification": { "date_prefix": "à", From da7a9e34f96bf46de154533bab1fa1420141675c Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Wed, 6 Aug 2025 23:58:08 +0200 Subject: [PATCH 3/7] feat: transmit launch args to rust backend --- src-tauri/src/northstar/mod.rs | 18 +++++++++++------- src-vue/src/plugins/store.ts | 11 +++++++---- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src-tauri/src/northstar/mod.rs b/src-tauri/src/northstar/mod.rs index 9953d742e..bf005a7b8 100644 --- a/src-tauri/src/northstar/mod.rs +++ b/src-tauri/src/northstar/mod.rs @@ -14,7 +14,7 @@ use ts_rs::TS; #[ts(export)] pub struct NorthstarLaunchOptions { launch_via_steam: bool, - bypass_checks: bool, + bypass_checks: bool } /// Gets list of available Northstar versions from Thunderstore @@ -160,11 +160,12 @@ pub fn get_northstar_version_number(game_install: GameInstall) -> Result ) -> Result { dbg!(game_install.clone()); if launch_options.launch_via_steam { - return launch_northstar_steam(game_install); + return launch_northstar_steam(game_install, launch_arguments); } let host_os = get_host_os(); @@ -179,7 +180,7 @@ pub fn launch_northstar( )); } - return launch_northstar_steam(game_install); + return launch_northstar_steam(game_install, launch_arguments); } // Only check guards if bypassing checks is not enabled @@ -213,9 +214,11 @@ pub fn launch_northstar( { let ns_exe_path = format!("{}/NorthstarLauncher.exe", game_install.game_path); let ns_profile_arg = format!("-profile={}", game_install.profile); + let mut arguments = vec!["/C", "start", "", &ns_exe_path, &ns_profile_arg]; + arguments.extend(launch_arguments); let mut output = std::process::Command::new("C:\\Windows\\System32\\cmd.exe") - .args(["/C", "start", "", &ns_exe_path, &ns_profile_arg]) + .args(arguments) .spawn() .expect("failed to execute process"); output.wait().expect("failed waiting on child process"); @@ -230,7 +233,7 @@ pub fn launch_northstar( } /// Prepare Northstar and Launch through Steam using the Browser Protocol -pub fn launch_northstar_steam(game_install: GameInstall) -> Result { +pub fn launch_northstar_steam(game_install: GameInstall, launch_arguments: Vec<&str>) -> Result { if !matches!(game_install.install_type, InstallType::STEAM) { return Err("Titanfall2 was not installed via Steam".to_string()); } @@ -266,9 +269,10 @@ pub fn launch_northstar_steam(game_install: GameInstall) -> Result Ok("Started game".to_string()), Err(_err) => Err("Failed to launch Titanfall 2 via Steam".to_string()), diff --git a/src-vue/src/plugins/store.ts b/src-vue/src/plugins/store.ts index 9ec7301f1..1e798baaf 100644 --- a/src-vue/src/plugins/store.ts +++ b/src-vue/src/plugins/store.ts @@ -10,7 +10,7 @@ import { NorthstarState } from '../utils/NorthstarState'; import { appDataDir } from '@tauri-apps/api/path'; import { open } from '@tauri-apps/plugin-dialog'; import { load } from '@tauri-apps/plugin-store'; -import { router } from "../main"; +import { argumentsStoreKey, router } from "../main"; import { ReleaseInfo } from "../../../src-tauri/bindings/ReleaseInfo"; import { ThunderstoreMod } from "../../../src-tauri/bindings/ThunderstoreMod"; import { NorthstarMod } from "../../../src-tauri/bindings/NorthstarMod"; @@ -173,9 +173,10 @@ export const store = createStore({ } }, async launchGame(state: any, launch_options: NorthstarLaunchOptions = { launch_via_steam: false, bypass_checks: false}) { + const launchArguments: string[] = await persistentStore.get(argumentsStoreKey) ?? []; if (launch_options.bypass_checks) { - await invoke("launch_northstar", { gameInstall: state.game_install, launchOptions: launch_options }) + await invoke("launch_northstar", { gameInstall: state.game_install, launchOptions: launch_options, launchArguments }) .then((message) => { console.log("Launched with bypassed checks"); console.log(message); @@ -225,7 +226,7 @@ export const store = createStore({ // Game is ready to play. case NorthstarState.READY_TO_PLAY: - await invoke("launch_northstar", { gameInstall: state.game_install, launchOptions: launch_options }) + await invoke("launch_northstar", { gameInstall: state.game_install, launchOptions: launch_options, launchArguments }) .then((message) => { console.log(message); // NorthstarState.RUNNING @@ -242,7 +243,9 @@ export const store = createStore({ } }, async launchGameSteam(state: any, launch_options: NorthstarLaunchOptions = { launch_via_steam: true, bypass_checks: false}) { - await invoke("launch_northstar", { gameInstall: state.game_install, launchOptions: launch_options }) + const launchArguments: string[] = await persistentStore.get(argumentsStoreKey) ?? []; + + await invoke("launch_northstar", { gameInstall: state.game_install, launchOptions: launch_options, launchArguments }) .then((_message) => { showNotification('Success'); }) From 98e695808563860f2839c4c320e660c10f6fcb2e Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Thu, 7 Aug 2025 00:38:56 +0200 Subject: [PATCH 4/7] build: apply cargo fmt --- src-tauri/src/northstar/mod.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src-tauri/src/northstar/mod.rs b/src-tauri/src/northstar/mod.rs index bf005a7b8..7ae44e28c 100644 --- a/src-tauri/src/northstar/mod.rs +++ b/src-tauri/src/northstar/mod.rs @@ -14,7 +14,7 @@ use ts_rs::TS; #[ts(export)] pub struct NorthstarLaunchOptions { launch_via_steam: bool, - bypass_checks: bool + bypass_checks: bool, } /// Gets list of available Northstar versions from Thunderstore @@ -160,7 +160,7 @@ pub fn get_northstar_version_number(game_install: GameInstall) -> Result + launch_arguments: Vec<&str>, ) -> Result { dbg!(game_install.clone()); @@ -233,7 +233,10 @@ pub fn launch_northstar( } /// Prepare Northstar and Launch through Steam using the Browser Protocol -pub fn launch_northstar_steam(game_install: GameInstall, launch_arguments: Vec<&str>) -> Result { +pub fn launch_northstar_steam( + game_install: GameInstall, + launch_arguments: Vec<&str>, +) -> Result { if !matches!(game_install.install_type, InstallType::STEAM) { return Err("Titanfall2 was not installed via Steam".to_string()); } From 0b184f8ed57551f0478c6c66b2ebe2462a1b442e Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Thu, 7 Aug 2025 01:06:29 +0200 Subject: [PATCH 5/7] build: apply cargo clippy --fix --- src-tauri/src/development/mod.rs | 18 +++++-------- src-tauri/src/github/mod.rs | 16 +++++------ src-tauri/src/github/pull_requests.rs | 31 +++++++++------------- src-tauri/src/mod_management/legacy.rs | 6 ++--- src-tauri/src/mod_management/mod.rs | 14 +++++----- src-tauri/src/northstar/install.rs | 15 +++++------ src-tauri/src/northstar/profile.rs | 8 +++--- src-tauri/src/platform_specific/windows.rs | 12 ++++----- src-tauri/src/util.rs | 11 ++++---- 9 files changed, 59 insertions(+), 72 deletions(-) diff --git a/src-tauri/src/development/mod.rs b/src-tauri/src/development/mod.rs index 7184904cd..4911a81e1 100644 --- a/src-tauri/src/development/mod.rs +++ b/src-tauri/src/development/mod.rs @@ -25,15 +25,13 @@ pub async fn install_git_main(game_install_path: &str) -> Result }; let extract_directory = format!( - "{}/___flightcore-temp/download-dir/launcher-pr-{}", - game_install_path, latest_commit_sha + "{game_install_path}/___flightcore-temp/download-dir/launcher-pr-{latest_commit_sha}" ); match std::fs::create_dir_all(extract_directory.clone()) { Ok(_) => (), Err(err) => { return Err(format!( - "Failed creating temporary download directory: {}", - err + "Failed creating temporary download directory: {err}" )) } }; @@ -42,7 +40,7 @@ pub async fn install_git_main(game_install_path: &str) -> Result match zip_extract::extract(std::io::Cursor::new(archive), &target_dir, true) { Ok(()) => (), Err(err) => { - return Err(format!("Failed unzip: {}", err)); + return Err(format!("Failed unzip: {err}")); } }; @@ -52,14 +50,13 @@ pub async fn install_git_main(game_install_path: &str) -> Result // - Northstar.dll let files_to_copy = vec!["NorthstarLauncher.exe", "Northstar.dll"]; for file_name in files_to_copy { - let source_file_path = format!("{}/{}", extract_directory, file_name); - let destination_file_path = format!("{}/{}", game_install_path, file_name); + let source_file_path = format!("{extract_directory}/{file_name}"); + let destination_file_path = format!("{game_install_path}/{file_name}"); match std::fs::copy(source_file_path, destination_file_path) { Ok(_result) => (), Err(err) => { return Err(format!( - "Failed to copy necessary file {} from temp dir: {}", - file_name, err + "Failed to copy necessary file {file_name} from temp dir: {err}" )) } }; @@ -70,8 +67,7 @@ pub async fn install_git_main(game_install_path: &str) -> Result Ok(()) => (), Err(err) => { return Err(format!( - "Failed to delete temporary download directory: {}", - err + "Failed to delete temporary download directory: {err}" )) } } diff --git a/src-tauri/src/github/mod.rs b/src-tauri/src/github/mod.rs index 9bc3f834e..fb2adf150 100644 --- a/src-tauri/src/github/mod.rs +++ b/src-tauri/src/github/mod.rs @@ -70,7 +70,7 @@ pub fn get_list_of_tags(project: Project) -> Result, String> { }; // Fetch the list of tags for the repository as a `Vec`. - let tags_url = format!("https://api.github.com/repos/{}/tags", repo_name); + let tags_url = format!("https://api.github.com/repos/{repo_name}/tags"); let tags: Vec = client.get(tags_url).send().unwrap().json().unwrap(); // Map each `Tag` element to a `TagWrapper` element with the desired label and `Tag` value. @@ -108,7 +108,7 @@ pub fn compare_tags_flightcore(first_tag: Tag, second_tag: Tag) -> Result = [].to_vec(); - println!("{}", repo); + println!("{repo}"); // let repo = "R2Northstar/NorthstarLauncher"; let comparison_url = format!( "https://api.github.com/repos/{}/compare/{}...{}", @@ -170,10 +170,10 @@ fn generate_flightcore_release_notes(commits: Vec) -> String { _ => "**Other:**", }; - release_notes.push_str(&format!("{}\n", section_title)); + release_notes.push_str(&format!("{section_title}\n")); for commit_message in commit_list { - release_notes.push_str(&format!("- {}\n", commit_message)); + release_notes.push_str(&format!("- {commit_message}\n")); } release_notes.push('\n'); @@ -235,10 +235,10 @@ pub fn compare_tags_northstar(first_tag: Tag, second_tag: Tag) -> Result = [].to_vec(); - println!("{}", repo); + println!("{repo}"); // let repo = "R2Northstar/NorthstarLauncher"; let comparison_url = format!( "https://api.github.com/repos/{}/compare/{}...{}", @@ -306,7 +306,7 @@ fn turn_pr_number_into_link(input: &str, repo: &str) -> String { let re = Regex::new(r"#(\d+)").unwrap(); // Generate pull request link - let pull_link = format!("https://github.com/{}/pull/", repo); - re.replace_all(input, format!("[{}#$1]({}$1)", last_line, pull_link)) + let pull_link = format!("https://github.com/{repo}/pull/"); + re.replace_all(input, format!("[{last_line}#$1]({pull_link}$1)")) .to_string() } diff --git a/src-tauri/src/github/pull_requests.rs b/src-tauri/src/github/pull_requests.rs index de733feb3..f0f15fc52 100644 --- a/src-tauri/src/github/pull_requests.rs +++ b/src-tauri/src/github/pull_requests.rs @@ -197,13 +197,12 @@ pub async fn get_launcher_download_link(commit_sha: String) -> Result serde_json::from_value(result).unwrap(), - Err(err) => return Err(format!("{}", err)), + Err(err) => return Err(format!("{err}")), }; // Cross-reference commit sha against workflow runs @@ -236,20 +235,19 @@ pub async fn get_launcher_download_link(commit_sha: String) -> Result` let mut file = match File::create(path) { - Err(why) => panic!("couldn't create {}: {}", display, why), + Err(why) => panic!("couldn't create {display}: {why}"), Ok(file) => file, }; @@ -258,7 +256,7 @@ fn add_batch_file(game_install_path: &str) { "NorthstarLauncher.exe -profile=R2Northstar-PR-test-managed-folder\r\n"; match file.write_all(batch_file_content.as_bytes()) { - Err(why) => panic!("couldn't write to {}: {}", display, why), + Err(why) => panic!("couldn't write to {display}: {why}"), Ok(_) => log::info!("successfully wrote to {}", display), } } @@ -296,8 +294,7 @@ pub async fn apply_launcher_pr( Ok(_) => (), Err(err) => { return Err(format!( - "Failed creating temporary download directory: {}", - err + "Failed creating temporary download directory: {err}" )) } }; @@ -306,7 +303,7 @@ pub async fn apply_launcher_pr( match zip_extract::extract(io::Cursor::new(archive), &target_dir, true) { Ok(()) => (), Err(err) => { - return Err(format!("Failed unzip: {}", err)); + return Err(format!("Failed unzip: {err}")); } }; @@ -316,14 +313,13 @@ pub async fn apply_launcher_pr( // - Northstar.dll let files_to_copy = vec!["NorthstarLauncher.exe", "Northstar.dll"]; for file_name in files_to_copy { - let source_file_path = format!("{}/{}", extract_directory, file_name); + let source_file_path = format!("{extract_directory}/{file_name}"); let destination_file_path = format!("{}/{}", game_install.game_path, file_name); match std::fs::copy(source_file_path, destination_file_path) { Ok(_result) => (), Err(err) => { return Err(format!( - "Failed to copy necessary file {} from temp dir: {}", - file_name, err + "Failed to copy necessary file {file_name} from temp dir: {err}" )) } }; @@ -334,8 +330,7 @@ pub async fn apply_launcher_pr( Ok(()) => (), Err(err) => { return Err(format!( - "Failed to delete temporary download directory: {}", - err + "Failed to delete temporary download directory: {err}" )) } } @@ -383,11 +378,11 @@ pub async fn apply_mods_pr( Err(err) => return Err(err.to_string()), } - let target_dir = std::path::PathBuf::from(format!("{}/mods", profile_folder)); // Doesn't need to exist + let target_dir = std::path::PathBuf::from(format!("{profile_folder}/mods")); // Doesn't need to exist match zip_extract::extract(io::Cursor::new(archive), &target_dir, true) { Ok(()) => (), Err(err) => { - return Err(format!("Failed unzip: {}", err)); + return Err(format!("Failed unzip: {err}")); } }; // Add batch file to launch right profile diff --git a/src-tauri/src/mod_management/legacy.rs b/src-tauri/src/mod_management/legacy.rs index 9cfbd8a19..a5cbc0873 100644 --- a/src-tauri/src/mod_management/legacy.rs +++ b/src-tauri/src/mod_management/legacy.rs @@ -20,8 +20,8 @@ pub struct ModJson { /// Parses `manifest.json` for Thunderstore mod string fn parse_for_thunderstore_mod_string(nsmod_path: &str) -> Result { - let manifest_json_path = format!("{}/manifest.json", nsmod_path); - let ts_author_txt_path = format!("{}/thunderstore_author.txt", nsmod_path); + let manifest_json_path = format!("{nsmod_path}/manifest.json"); + let ts_author_txt_path = format!("{nsmod_path}/thunderstore_author.txt"); // Check if `manifest.json` exists and parse let data = std::fs::read_to_string(manifest_json_path)?; @@ -71,7 +71,7 @@ pub fn parse_installed_mods( for directory in directories { let directory_str = directory.to_str().unwrap().to_string(); // Check if mod.json exists - let mod_json_path = format!("{}/mod.json", directory_str); + let mod_json_path = format!("{directory_str}/mod.json"); if !std::path::Path::new(&mod_json_path).exists() { continue; } diff --git a/src-tauri/src/mod_management/mod.rs b/src-tauri/src/mod_management/mod.rs index 52ef1180d..85f30bcb8 100644 --- a/src-tauri/src/mod_management/mod.rs +++ b/src-tauri/src/mod_management/mod.rs @@ -135,7 +135,7 @@ pub fn get_enabled_mods(game_install: &GameInstall) -> Result result, - Err(err) => return Err(format!("Failed to read JSON due to: {}", err)), + Err(err) => return Err(format!("Failed to read JSON due to: {err}")), }; // Return parsed data @@ -255,7 +255,7 @@ pub fn parse_mods_in_package( for directory in directories { let directory_str = directory.to_str().unwrap().to_string(); // Check if mod.json exists - let mod_json_path = format!("{}/mod.json", directory_str); + let mod_json_path = format!("{directory_str}/mod.json"); if !std::path::Path::new(&mod_json_path).exists() { continue; } @@ -613,8 +613,7 @@ pub async fn fc_download_mod_and_install( for special_mod in MODS_WITH_SPECIAL_REQUIREMENTS { if thunderstore_mod_string.contains(special_mod) { return Err(format!( - "{} has special install requirements and cannot be installed with FlightCore", - thunderstore_mod_string + "{thunderstore_mod_string} has special install requirements and cannot be installed with FlightCore" )); } } @@ -667,7 +666,7 @@ pub async fn fc_download_mod_and_install( log::warn!("libthermite couldn't install mod {thunderstore_mod_string} due to {err:?}",); return match err { ThermiteError::SanityError(e) => Err( - format!("Mod failed sanity check during install. It's probably not correctly formatted. {}", e) + format!("Mod failed sanity check during install. It's probably not correctly formatted. {e}") ), _ => Err(err.to_string()), }; @@ -703,7 +702,7 @@ fn delete_mod_folder(ns_mod_directory: &str) -> Result<(), String> { let mod_json_path = ns_mod_dir_path.join("mod.json"); if !mod_json_path.exists() { // If it doesn't exist, return an error - return Err(format!("mod.json does not exist in {}", ns_mod_directory)); + return Err(format!("mod.json does not exist in {ns_mod_directory}")); } match std::fs::remove_dir_all(ns_mod_directory) { @@ -747,8 +746,7 @@ fn delete_package_folder(ts_package_directory: &str) -> Result<(), String> { if !mod_json_path.exists() { // If it doesn't exist, return an error return Err(format!( - "manifest.json does not exist in {}", - ts_package_directory + "manifest.json does not exist in {ts_package_directory}" )); } diff --git a/src-tauri/src/northstar/install.rs b/src-tauri/src/northstar/install.rs index 0e1df3c11..ff47e7032 100644 --- a/src-tauri/src/northstar/install.rs +++ b/src-tauri/src/northstar/install.rs @@ -84,14 +84,14 @@ async fn do_install( ) -> Result<()> { let filename = format!("northstar-{}.zip", nmod.version); let temp_dir = format!("{}/___flightcore-temp", game_install.game_path); - let download_directory = format!("{}/download-dir", temp_dir); - let extract_directory = format!("{}/extract-dir", temp_dir); + let download_directory = format!("{temp_dir}/download-dir"); + let extract_directory = format!("{temp_dir}/extract-dir"); log::info!("Attempting to create temporary directory {}", temp_dir); std::fs::create_dir_all(download_directory.clone())?; std::fs::create_dir_all(extract_directory.clone())?; - let download_path = format!("{}/{}", download_directory, filename); + let download_path = format!("{download_directory}/{filename}"); log::info!("Download path: {download_path}"); let last_emit = RefCell::new(Instant::now()); // Keep track of the last time a signal was emitted @@ -146,15 +146,14 @@ async fn do_install( // - rename the Profile // Move DLL into the default R2Northstar Profile - let old_dll_path = format!("{}/{}", extract_directory, NORTHSTAR_DLL); + let old_dll_path = format!("{extract_directory}/{NORTHSTAR_DLL}"); let new_dll_path = format!( - "{}/{}/{}", - extract_directory, NORTHSTAR_DEFAULT_PROFILE, NORTHSTAR_DLL + "{extract_directory}/{NORTHSTAR_DEFAULT_PROFILE}/{NORTHSTAR_DLL}" ); std::fs::rename(old_dll_path, new_dll_path)?; // rename default R2Northstar Profile to the profile we want to use - let old_profile_path = format!("{}/{}/", extract_directory, NORTHSTAR_DEFAULT_PROFILE); + let old_profile_path = format!("{extract_directory}/{NORTHSTAR_DEFAULT_PROFILE}/"); let new_profile_path = format!("{}/{}/", extract_directory, game_install.profile); std::fs::rename(old_profile_path, new_profile_path)?; } @@ -188,7 +187,7 @@ async fn do_install( // Safety check for mod.json // Just so that we won't ever have a https://github.com/ValveSoftware/steam-for-linux/issues/3671 moment - let mod_json_path = format!("{}/mod.json", path_to_delete_string); + let mod_json_path = format!("{path_to_delete_string}/mod.json"); let mod_json_path = std::path::Path::new(&mod_json_path); if !mod_json_path.exists() { diff --git a/src-tauri/src/northstar/profile.rs b/src-tauri/src/northstar/profile.rs index 26a32d6b5..f1effc935 100644 --- a/src-tauri/src/northstar/profile.rs +++ b/src-tauri/src/northstar/profile.rs @@ -80,7 +80,7 @@ pub fn validate_profile(game_install: GameInstall, profile: String) -> bool { pub fn delete_profile(game_install: GameInstall, profile: String) -> Result<(), String> { // Check if the Profile actually exists if !validate_profile(game_install.clone(), profile.clone()) { - return Err(format!("{} is not a valid Profile", profile)); + return Err(format!("{profile} is not a valid Profile")); } log::info!("Deleting Profile {}", profile); @@ -89,7 +89,7 @@ pub fn delete_profile(game_install: GameInstall, profile: String) -> Result<(), match std::fs::remove_dir_all(profile_path) { Ok(()) => Ok(()), - Err(err) => Err(format!("Failed to delete Profile: {}", err)), + Err(err) => Err(format!("Failed to delete Profile: {err}")), } } @@ -102,12 +102,12 @@ pub fn clone_profile( ) -> Result<(), String> { // Check if the old Profile already exists if !validate_profile(game_install.clone(), old_profile.clone()) { - return Err(format!("{} is not a valid Profile", old_profile)); + return Err(format!("{old_profile} is not a valid Profile")); } // Check that new Profile does not already exist if validate_profile(game_install.clone(), new_profile.clone()) { - return Err(format!("{} already exists", new_profile)); + return Err(format!("{new_profile} already exists")); } log::info!("Cloning Profile {} to {}", old_profile, new_profile); diff --git a/src-tauri/src/platform_specific/windows.rs b/src-tauri/src/platform_specific/windows.rs index fc6aab5d6..c361955fb 100644 --- a/src-tauri/src/platform_specific/windows.rs +++ b/src-tauri/src/platform_specific/windows.rs @@ -42,11 +42,11 @@ pub async fn check_cgnat() -> Result { // Check if valid IPv4 address and return early if not if response.parse::().is_err() { - return Err(format!("Not valid IPv4 address: {}", response)); + return Err(format!("Not valid IPv4 address: {response}")); } let hops_count = run_tracert(&response)?; - Ok(format!("Counted {} hops to {}", hops_count, response)) + Ok(format!("Counted {hops_count} hops to {response}")) } /// Count number of hops in tracert output @@ -82,7 +82,7 @@ fn run_tracert(target_ip: &str) -> Result { .output() { Ok(res) => res, - Err(err) => return Err(format!("Failed running tracert: {}", err)), + Err(err) => return Err(format!("Failed running tracert: {err}")), }; // Check if the command was successful @@ -90,7 +90,7 @@ fn run_tracert(target_ip: &str) -> Result { // Convert the output to a string let stdout = std::str::from_utf8(&output.stdout).expect("Invalid UTF-8 sequence in command output"); - println!("{}", stdout); + println!("{stdout}"); // Count the number of hops let hop_count = count_hops(stdout); @@ -98,7 +98,7 @@ fn run_tracert(target_ip: &str) -> Result { } else { let stderr = std::str::from_utf8(&output.stderr) .expect("Invalid UTF-8 sequence in command error output"); - println!("{}", stderr); - Err(format!("Failed collecting tracert output: {}", stderr)) + println!("{stderr}"); + Err(format!("Failed collecting tracert output: {stderr}")) } } diff --git a/src-tauri/src/util.rs b/src-tauri/src/util.rs index d2234be50..0eb1047df 100644 --- a/src-tauri/src/util.rs +++ b/src-tauri/src/util.rs @@ -31,10 +31,10 @@ pub async fn get_flightcore_version_number() -> String { let version = env!("CARGO_PKG_VERSION"); if cfg!(debug_assertions) { // Debugging enabled - format!("v{} (debug mode)", version) + format!("v{version} (debug mode)") } else { // Debugging disabled - format!("v{}", version) + format!("v{version}") } } @@ -244,18 +244,17 @@ pub fn convert_release_candidate_number(version_number: String) -> String { let release_candidate: u32 = captures[4].parse().unwrap(); // Zero pad - let padded_release_candidate = format!("{:02}", release_candidate); + let padded_release_candidate = format!("{release_candidate:02}"); // Combine - let combined_patch_version = format!("{}{}", patch_version, padded_release_candidate); + let combined_patch_version = format!("{patch_version}{padded_release_candidate}"); // Strip leading zeroes let trimmed_combined_patch_version = combined_patch_version.trim_start_matches('0'); // Combine all let version_number = format!( - "{}.{}.{}", - major_version, minor_version, trimmed_combined_patch_version + "{major_version}.{minor_version}.{trimmed_combined_patch_version}" ); return version_number; } From 3061a9ae99c02967faa5b35d8967d89855857a19 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Thu, 7 Aug 2025 01:09:57 +0200 Subject: [PATCH 6/7] build: reapply cargo fmt --- src-tauri/src/northstar/install.rs | 5 ++--- src-tauri/src/util.rs | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src-tauri/src/northstar/install.rs b/src-tauri/src/northstar/install.rs index ff47e7032..5d24d969a 100644 --- a/src-tauri/src/northstar/install.rs +++ b/src-tauri/src/northstar/install.rs @@ -147,9 +147,8 @@ async fn do_install( // Move DLL into the default R2Northstar Profile let old_dll_path = format!("{extract_directory}/{NORTHSTAR_DLL}"); - let new_dll_path = format!( - "{extract_directory}/{NORTHSTAR_DEFAULT_PROFILE}/{NORTHSTAR_DLL}" - ); + let new_dll_path = + format!("{extract_directory}/{NORTHSTAR_DEFAULT_PROFILE}/{NORTHSTAR_DLL}"); std::fs::rename(old_dll_path, new_dll_path)?; // rename default R2Northstar Profile to the profile we want to use diff --git a/src-tauri/src/util.rs b/src-tauri/src/util.rs index 0eb1047df..9d4d3d983 100644 --- a/src-tauri/src/util.rs +++ b/src-tauri/src/util.rs @@ -253,9 +253,8 @@ pub fn convert_release_candidate_number(version_number: String) -> String { let trimmed_combined_patch_version = combined_patch_version.trim_start_matches('0'); // Combine all - let version_number = format!( - "{major_version}.{minor_version}.{trimmed_combined_patch_version}" - ); + let version_number = + format!("{major_version}.{minor_version}.{trimmed_combined_patch_version}"); return version_number; } From c37e87b1bb14beda1d06ebf7e0a617811a71c511 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Thu, 7 Aug 2025 01:18:51 +0200 Subject: [PATCH 7/7] build: manually fix missing clippy errors 3 errors were reported by CI that I could not reproduce locally for some reason. --- src-tauri/src/platform_specific/linux.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src-tauri/src/platform_specific/linux.rs b/src-tauri/src/platform_specific/linux.rs index fcac5b671..348f22821 100644 --- a/src-tauri/src/platform_specific/linux.rs +++ b/src-tauri/src/platform_specific/linux.rs @@ -65,14 +65,14 @@ pub fn install_ns_proton() -> Result<(), String> { /// Remove NS Proton pub fn uninstall_ns_proton() -> Result<(), String> { let compat_dir = get_proton_dir()?; - let pattern = format!("{}/NorthstarProton*", compat_dir); + let pattern = format!("{compat_dir}/NorthstarProton*"); for e in glob::glob(&pattern).expect("Failed to read glob pattern") { match e { Ok(path) => match std::fs::remove_dir_all(path.clone()) { Ok(_) => {} Err(_) => return Err(format!("Failed to remove {}", path.display())), }, - Err(e) => return Err(format!("Found unprocessable entry {}", e)), + Err(e) => return Err(format!("Found unprocessable entry {e}")), } } @@ -82,7 +82,7 @@ pub fn uninstall_ns_proton() -> Result<(), String> { /// Get the latest installed NS Proton version pub fn get_local_ns_proton_version() -> Result { let compat_dir = get_proton_dir().unwrap(); - let pattern = format!("{}/NorthstarProton*/version", compat_dir); + let pattern = format!("{compat_dir}/NorthstarProton*/version"); if let Some(e) = glob::glob(&pattern) .expect("Failed to read glob pattern")