diff options
author | GeckoEidechse <gecko.eidechse+git@pm.me> | 2023-08-03 13:55:19 +0200 |
---|---|---|
committer | GeckoEidechse <gecko.eidechse+git@pm.me> | 2023-08-03 13:55:19 +0200 |
commit | 4187ef1c82b2a4bf78b8731afaadfeab25f69ff4 (patch) | |
tree | 1bb9e54881e9bcf81c0b2b0ab6a9b99b325bd159 | |
parent | e621728fbbc6a3a65b8a989a098bfbc2c186cbd6 (diff) | |
parent | 52b8d87d02e14812fd49cd70f574fa81bc437eb4 (diff) | |
download | FlightCore-4187ef1c82b2a4bf78b8731afaadfeab25f69ff4.tar.gz FlightCore-4187ef1c82b2a4bf78b8731afaadfeab25f69ff4.zip |
Merge branch 'main' into feat/launch-parameters
-rw-r--r-- | src-tauri/Cargo.lock | 2 | ||||
-rw-r--r-- | src-tauri/Cargo.toml | 2 | ||||
-rw-r--r-- | src-tauri/src/development/mod.rs | 2 | ||||
-rw-r--r-- | src-tauri/src/github/pull_requests.rs | 2 | ||||
-rw-r--r-- | src-tauri/src/main.rs | 14 | ||||
-rw-r--r-- | src-tauri/src/mod_management/legacy.rs | 2 | ||||
-rw-r--r-- | src-tauri/src/mod_management/mod.rs | 39 | ||||
-rw-r--r-- | src-tauri/src/northstar/install.rs | 54 | ||||
-rw-r--r-- | src-tauri/src/northstar/mod.rs | 20 | ||||
-rw-r--r-- | src-tauri/src/repair_and_verify/mod.rs | 36 | ||||
-rw-r--r-- | src-tauri/src/util.rs | 62 | ||||
-rw-r--r-- | src-tauri/tauri.conf.json | 2 | ||||
-rw-r--r-- | src-vue/src/plugins/store.ts | 14 | ||||
-rw-r--r-- | src-vue/src/utils/GameInstall.ts | 1 | ||||
-rw-r--r-- | src-vue/src/views/DeveloperView.vue | 30 | ||||
-rw-r--r-- | src-vue/src/views/RepairView.vue | 2 |
16 files changed, 213 insertions, 71 deletions
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 17ec2deb..f4d1faab 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -81,7 +81,7 @@ checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" [[package]] name = "app" -version = "2.2.0" +version = "2.4.0" dependencies = [ "anyhow", "async-recursion", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 72cac7f3..6341d9a1 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "app" -version = "2.2.0" +version = "2.4.0" description = "A Tauri App" authors = ["you"] license = "" diff --git a/src-tauri/src/development/mod.rs b/src-tauri/src/development/mod.rs index be02966d..7184904c 100644 --- a/src-tauri/src/development/mod.rs +++ b/src-tauri/src/development/mod.rs @@ -25,7 +25,7 @@ pub async fn install_git_main(game_install_path: &str) -> Result<String, String> }; let extract_directory = format!( - "{}/___flightcore-temp-download-dir/launcher-pr-{}", + "{}/___flightcore-temp/download-dir/launcher-pr-{}", game_install_path, latest_commit_sha ); match std::fs::create_dir_all(extract_directory.clone()) { diff --git a/src-tauri/src/github/pull_requests.rs b/src-tauri/src/github/pull_requests.rs index 44b41638..c3079cfd 100644 --- a/src-tauri/src/github/pull_requests.rs +++ b/src-tauri/src/github/pull_requests.rs @@ -253,7 +253,7 @@ pub async fn apply_launcher_pr( }; let extract_directory = format!( - "{}/___flightcore-temp-download-dir/launcher-pr-{}", + "{}/___flightcore-temp/download-dir/launcher-pr-{}", game_install_path, pull_request.number ); match std::fs::create_dir_all(extract_directory.clone()) { diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 1067f5d3..9e812683 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -142,6 +142,7 @@ fn main() { github::release_notes::get_newest_flightcore_version, mod_management::delete_northstar_mod, util::get_server_player_count, + util::kill_northstar, mod_management::delete_thunderstore_mod, install_northstar_proton_wrapper, uninstall_northstar_proton_wrapper, @@ -234,7 +235,7 @@ pub fn convert_release_candidate_number(version_number: String) -> String { /// true -> Northstar install is outdated #[tauri::command] async fn check_is_northstar_outdated( - game_path: String, + game_install: GameInstall, northstar_package_name: Option<String>, ) -> Result<bool, String> { let northstar_package_name = match northstar_package_name { @@ -258,7 +259,7 @@ async fn check_is_northstar_outdated( .expect("Couldn't find Northstar on thunderstore???"); // .ok_or_else(|| anyhow!("Couldn't find Northstar on thunderstore???"))?; - let version_number = match northstar::get_northstar_version_number(&game_path) { + let version_number = match northstar::get_northstar_version_number(game_install) { Ok(version_number) => version_number, Err(err) => { log::warn!("{}", err); @@ -295,7 +296,7 @@ async fn verify_install_location(game_path: String) -> bool { #[tauri::command] async fn install_northstar_caller( window: tauri::Window, - game_path: String, + game_install: GameInstall, northstar_package_name: Option<String>, version_number: Option<String>, ) -> Result<bool, String> { @@ -314,7 +315,7 @@ async fn install_northstar_caller( match northstar::install::install_northstar( window, - &game_path, + game_install, northstar_package_name, version_number, ) @@ -332,13 +333,13 @@ async fn install_northstar_caller( #[tauri::command] async fn update_northstar( window: tauri::Window, - game_path: String, + game_install: GameInstall, northstar_package_name: Option<String>, ) -> Result<bool, String> { log::info!("Updating Northstar"); // Simply re-run install with up-to-date version for upate - install_northstar_caller(window, game_path, northstar_package_name, None).await + install_northstar_caller(window, game_install, northstar_package_name, None).await } /// Installs the specified mod @@ -467,6 +468,7 @@ pub enum InstallType { #[derive(Serialize, Deserialize, Debug, Clone)] pub struct GameInstall { pub game_path: String, + pub profile: String, pub install_type: InstallType, } diff --git a/src-tauri/src/mod_management/legacy.rs b/src-tauri/src/mod_management/legacy.rs index 91463250..1e9f90f5 100644 --- a/src-tauri/src/mod_management/legacy.rs +++ b/src-tauri/src/mod_management/legacy.rs @@ -45,7 +45,7 @@ fn parse_for_thunderstore_mod_string(nsmod_path: &str) -> Result<String, anyhow: pub fn parse_installed_mods( game_install: &GameInstall, ) -> Result<Vec<NorthstarMod>, anyhow::Error> { - let ns_mods_folder = format!("{}/R2Northstar/mods/", game_install.game_path); + let ns_mods_folder = format!("{}/{}/mods/", game_install.game_path, game_install.profile); let paths = match std::fs::read_dir(ns_mods_folder) { Ok(paths) => paths, diff --git a/src-tauri/src/mod_management/mod.rs b/src-tauri/src/mod_management/mod.rs index 879d3b04..ff3a09ed 100644 --- a/src-tauri/src/mod_management/mod.rs +++ b/src-tauri/src/mod_management/mod.rs @@ -91,7 +91,10 @@ impl std::ops::Deref for TempFile { /// Returns a serde json object of the parsed `enabledmods.json` file pub fn get_enabled_mods(game_install: &GameInstall) -> Result<serde_json::value::Value, String> { - let enabledmods_json_path = format!("{}/R2Northstar/enabledmods.json", game_install.game_path); + let enabledmods_json_path = format!( + "{}/{}/enabledmods.json", + game_install.game_path, game_install.profile + ); // Check for JSON file if !std::path::Path::new(&enabledmods_json_path).exists() { @@ -116,7 +119,10 @@ pub fn get_enabled_mods(game_install: &GameInstall) -> Result<serde_json::value: /// Gets all currently installed and enabled/disabled mods to rebuild `enabledmods.json` pub fn rebuild_enabled_mods_json(game_install: &GameInstall) -> Result<(), String> { - let enabledmods_json_path = format!("{}/R2Northstar/enabledmods.json", game_install.game_path); + let enabledmods_json_path = format!( + "{}/{}/enabledmods.json", + game_install.game_path, game_install.profile + ); let mods_and_properties = get_installed_mods_and_properties(game_install.clone())?; // Create new mapping @@ -147,7 +153,10 @@ pub fn set_mod_enabled_status( mod_name: String, is_enabled: bool, ) -> Result<(), String> { - let enabledmods_json_path = format!("{}/R2Northstar/enabledmods.json", game_install.game_path); + let enabledmods_json_path = format!( + "{}/{}/enabledmods.json", + game_install.game_path, game_install.profile + ); // Parse JSON let mut res: serde_json::Value = match get_enabled_mods(&game_install) { @@ -260,7 +269,10 @@ pub fn parse_installed_package_mods( ) -> Result<Vec<NorthstarMod>, anyhow::Error> { let mut collected_mods: Vec<NorthstarMod> = Vec::new(); - let packages_folder = format!("{}/R2Northstar/packages/", game_install.game_path); + let packages_folder = format!( + "{}/{}/packages/", + game_install.game_path, game_install.profile + ); let packages_dir = match fs::read_dir(packages_folder) { Ok(res) => res, @@ -420,7 +432,10 @@ fn delete_older_versions( "Deleting other versions of {}", thunderstore_mod_string.to_string() ); - let packages_folder = format!("{}/R2Northstar/packages", game_install.game_path); + let packages_folder = format!( + "{}/{}/packages", + game_install.game_path, game_install.profile + ); // Get folders in packages dir let paths = match std::fs::read_dir(&packages_folder) { @@ -522,7 +537,7 @@ pub async fn fc_download_mod_and_install( log::info!("Attempting to install \"{thunderstore_mod_string}\" to {game_install:?}"); // Get mods and download directories let download_directory = format!( - "{}/___flightcore-temp-download-dir/", + "{}/___flightcore-temp/download-dir/", game_install.game_path ); @@ -569,7 +584,7 @@ pub async fn fc_download_mod_and_install( }; let path = format!( - "{}/___flightcore-temp-download-dir/{thunderstore_mod_string}.zip", + "{}/___flightcore-temp/download-dir/{thunderstore_mod_string}.zip", game_install.game_path ); @@ -590,7 +605,10 @@ pub async fn fc_download_mod_and_install( }; // Get directory to install to made up of packages directory and Thunderstore mod string - let install_directory = format!("{}/R2Northstar/packages/", game_install.game_path); + let install_directory = format!( + "{}/{}/packages/", + game_install.game_path, game_install.profile + ); // Extract the mod to the mods directory match thermite::core::manage::install_with_sanity( @@ -703,7 +721,10 @@ pub fn delete_thunderstore_mod( thunderstore_mod_string: String, ) -> Result<(), String> { // Check packages - let packages_folder = format!("{}/R2Northstar/packages", game_install.game_path); + let packages_folder = format!( + "{}/{}/packages", + game_install.game_path, game_install.profile + ); if std::path::Path::new(&packages_folder).exists() { for entry in fs::read_dir(packages_folder).unwrap() { let entry = entry.unwrap(); diff --git a/src-tauri/src/northstar/install.rs b/src-tauri/src/northstar/install.rs index c77fd538..80425c56 100644 --- a/src-tauri/src/northstar/install.rs +++ b/src-tauri/src/northstar/install.rs @@ -5,7 +5,10 @@ use std::{cell::RefCell, time::Instant}; use ts_rs::TS; use crate::constants::TITANFALL2_STEAM_ID; -use crate::{util::extract, GameInstall, InstallType}; +use crate::{ + util::{extract, move_dir_all}, + GameInstall, InstallType, +}; #[cfg(target_os = "windows")] use crate::platform_specific::windows; @@ -33,16 +36,16 @@ struct InstallProgress { async fn do_install( window: tauri::Window, nmod: &thermite::model::ModVersion, - game_path: &std::path::Path, + game_install: GameInstall, ) -> Result<()> { let filename = format!("northstar-{}.zip", nmod.version); - let download_directory = format!("{}/___flightcore-temp-download-dir/", game_path.display()); + 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); - log::info!( - "Attempting to create temporary directory {}", - download_directory - ); + 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); log::info!("Download path: {download_path}"); @@ -91,11 +94,29 @@ async fn do_install( .unwrap(); log::info!("Extracting Northstar..."); - extract(nfile, game_path)?; + extract(nfile, std::path::Path::new(&extract_directory))?; + + log::info!("Installing Northstar..."); + + for entry in std::fs::read_dir(extract_directory).unwrap() { + let entry = entry.unwrap(); + let destination = format!( + "{}/{}", + game_install.game_path, + entry.path().file_name().unwrap().to_str().unwrap() + ); + + log::info!("Installing {}", entry.path().display()); + if !entry.file_type().unwrap().is_dir() { + std::fs::rename(entry.path(), destination)?; + } else { + move_dir_all(entry.path(), destination)?; + } + } // Delete old copy - log::info!("Delete temp folder again"); - std::fs::remove_dir_all(download_directory).unwrap(); + log::info!("Delete temporary directory"); + std::fs::remove_dir_all(temp_dir).unwrap(); log::info!("Done installing Northstar!"); window @@ -114,7 +135,7 @@ async fn do_install( pub async fn install_northstar( window: tauri::Window, - game_path: &str, + game_install: GameInstall, northstar_package_name: String, version_number: Option<String>, ) -> Result<String, String> { @@ -134,15 +155,10 @@ pub async fn install_northstar( // Use passed version or latest if no version was passed let version = version_number.as_ref().unwrap_or(&nmod.latest); + let game_path = game_install.game_path.clone(); log::info!("Install path \"{}\"", game_path); - match do_install( - window, - nmod.versions.get(version).unwrap(), - std::path::Path::new(game_path), - ) - .await - { + match do_install(window, nmod.versions.get(version).unwrap(), game_install).await { Ok(_) => (), Err(err) => { if game_path @@ -190,6 +206,7 @@ pub fn find_game_install_location() -> Result<GameInstall, String> { // println!("{:#?}", app); let game_install = GameInstall { game_path: app.path.to_str().unwrap().to_string(), + profile: "R2Northstar".to_string(), install_type: InstallType::STEAM, }; return Ok(game_install); @@ -206,6 +223,7 @@ pub fn find_game_install_location() -> Result<GameInstall, String> { Ok(game_path) => { let game_install = GameInstall { game_path, + profile: "R2Northstar".to_string(), install_type: InstallType::ORIGIN, }; return Ok(game_install); diff --git a/src-tauri/src/northstar/mod.rs b/src-tauri/src/northstar/mod.rs index 86e50d5f..18a707b0 100644 --- a/src-tauri/src/northstar/mod.rs +++ b/src-tauri/src/northstar/mod.rs @@ -26,15 +26,14 @@ pub fn check_mod_version_number(path_to_mod_folder: &str) -> Result<String, anyh /// Returns the current Northstar version number as a string #[tauri::command] -pub fn get_northstar_version_number(game_path: &str) -> Result<String, String> { - log::info!("{}", game_path); +pub fn get_northstar_version_number(game_install: GameInstall) -> Result<String, String> { + log::info!("{}", game_install.game_path); // TODO: // Check if NorthstarLauncher.exe exists and check its version number - let profile_folder = "R2Northstar"; let initial_version_number = match check_mod_version_number(&format!( - "{game_path}/{profile_folder}/mods/{}", - CORE_MODS[0] + "{}/{}/mods/{}", + game_install.game_path, game_install.profile, CORE_MODS[0] )) { Ok(version_number) => version_number, Err(err) => return Err(err.to_string()), @@ -42,7 +41,8 @@ pub fn get_northstar_version_number(game_path: &str) -> Result<String, String> { for core_mod in CORE_MODS { let current_version_number = match check_mod_version_number(&format!( - "{game_path}/{profile_folder}/mods/{core_mod}", + "{}/{}/mods/{}", + game_install.game_path, game_install.profile, core_mod )) { Ok(version_number) => version_number, Err(err) => return Err(err.to_string()), @@ -86,7 +86,7 @@ pub fn launch_northstar( // Only check guards if bypassing checks is not enabled if !bypass_checks { // Some safety checks before, should have more in the future - if get_northstar_version_number(&game_install.game_path).is_err() { + if get_northstar_version_number(game_install.clone()).is_err() { return Err(anyhow!("Not all checks were met").to_string()); } @@ -115,12 +115,14 @@ pub fn launch_northstar( let ns_exe_path = format!("{}/NorthstarLauncher.exe", game_install.game_path); let mut args = vec!["/C", "start", "", &ns_exe_path]; + let ns_profile_arg = format!("-profile={}", game_install.profile); // We cannot add the params directly because of limitations with cmd.exe // https://stackoverflow.com/questions/9964865/c-system-not-working-when-there-are-spaces-in-two-different-parameters/9965141#9965141 let launch_parameters = launch_parameters.unwrap_or_default(); let ns_params: Vec<&str> = launch_parameters.split_whitespace().collect(); dbg!(ns_params.clone()); + args.extend(vec![ns_profile_arg]); args.extend(ns_params); let _output = std::process::Command::new("C:\\Windows\\System32\\cmd.exe") .args(args) @@ -186,8 +188,8 @@ pub fn launch_northstar_steam( let launch_parameters = launch_parameters.unwrap_or_default(); match open::that(format!( - "steam://run/{}//--northstar {}/", - TITANFALL2_STEAM_ID, launch_parameters + "steam://run/{}//-profile={} --northstar {}/", + TITANFALL2_STEAM_ID, game_install.profile, launch_parameters )) { Ok(()) => Ok("Started game".to_string()), Err(_err) => Err("Failed to launch Titanfall 2 via Steam".to_string()), diff --git a/src-tauri/src/repair_and_verify/mod.rs b/src-tauri/src/repair_and_verify/mod.rs index 92835a4e..29cc9613 100644 --- a/src-tauri/src/repair_and_verify/mod.rs +++ b/src-tauri/src/repair_and_verify/mod.rs @@ -40,33 +40,37 @@ pub fn clean_up_download_folder( game_install: &GameInstall, force: bool, ) -> Result<(), anyhow::Error> { - // Get download directory - let download_directory = format!( - "{}/___flightcore-temp-download-dir/", - game_install.game_path - ); + const TEMPORARY_DIRECTORIES: [&str; 3] = [ + "___flightcore-temp-download-dir", + "___flightcore-temp/download-dir", + "___flightcore-temp", + ]; - // Check if files in folder - let download_dir_contents = std::fs::read_dir(download_directory.clone())?; - // dbg!(download_dir_contents); + for directory in TEMPORARY_DIRECTORIES { + // Get download directory + let download_directory = format!("{}/{}/", game_install.game_path, directory); - let mut count = 0; - download_dir_contents.for_each(|_| count += 1); + // Check if files in folder + let download_dir_contents = std::fs::read_dir(download_directory.clone())?; + // dbg!(download_dir_contents); - if count > 0 && !force { - return Err(anyhow!("Folder not empty, not deleting")); - } + let mut count = 0; + download_dir_contents.for_each(|_| count += 1); - // Delete folder - std::fs::remove_dir_all(download_directory)?; + if count > 0 && !force { + return Err(anyhow!("Folder not empty, not deleting")); + } + // Delete folder + std::fs::remove_dir_all(download_directory)?; + } Ok(()) } /// Get list of Northstar logs #[tauri::command] pub fn get_log_list(game_install: GameInstall) -> Result<Vec<std::path::PathBuf>, String> { - let ns_log_folder = format!("{}/R2Northstar/logs", game_install.game_path); + let ns_log_folder = format!("{}/{}/logs", game_install.game_path, game_install.profile); // List files in logs folder let paths = match std::fs::read_dir(ns_log_folder) { diff --git a/src-tauri/src/util.rs b/src-tauri/src/util.rs index 0f32ecb5..b21b2208 100644 --- a/src-tauri/src/util.rs +++ b/src-tauri/src/util.rs @@ -2,7 +2,7 @@ use anyhow::{Context, Result}; use serde::{Deserialize, Serialize}; -use sysinfo::SystemExt; +use sysinfo::{ProcessExt, SystemExt}; use zip::ZipArchive; use crate::constants::{APP_USER_AGENT, MASTER_SERVER_URL, SERVER_BROWSER_ENDPOINT}; @@ -64,6 +64,27 @@ pub async fn get_server_player_count() -> Result<(i32, usize), String> { Ok((total_player_count, server_count)) } +#[tauri::command] +pub async fn kill_northstar() -> Result<(), String> { + if !check_northstar_running() { + return Err("Northstar is not running".to_string()); + } + + let s = sysinfo::System::new_all(); + + for process in s.processes_by_exact_name("Titanfall2.exe") { + log::info!("Killing Process {}", process.pid()); + process.kill(); + } + + for process in s.processes_by_exact_name("NorthstarLauncher.exe") { + log::info!("Killing Process {}", process.pid()); + process.kill(); + } + + Ok(()) +} + /// Copied from `papa` source code and modified ///Extract N* zip file to target game path // fn extract(ctx: &Ctx, zip_file: File, target: &Path) -> Result<()> { @@ -122,3 +143,42 @@ pub fn check_northstar_running() -> bool { || s.processes_by_name("Titanfall2.exe").next().is_some(); x } + +/// Copies a folder and all its contents to a new location +#[allow(dead_code)] +pub fn copy_dir_all( + src: impl AsRef<std::path::Path>, + dst: impl AsRef<std::path::Path>, +) -> std::io::Result<()> { + std::fs::create_dir_all(&dst)?; + for entry in std::fs::read_dir(src)? { + let entry = entry?; + let ty = entry.file_type()?; + if ty.is_dir() { + copy_dir_all(entry.path(), dst.as_ref().join(entry.file_name()))?; + } else { + std::fs::copy(entry.path(), dst.as_ref().join(entry.file_name()))?; + } + } + Ok(()) +} + +/// Moves a folders file structure to a new location +/// Old folders are not removed +pub fn move_dir_all( + src: impl AsRef<std::path::Path>, + dst: impl AsRef<std::path::Path>, +) -> std::io::Result<()> { + std::fs::create_dir_all(&dst)?; + for entry in std::fs::read_dir(src)? { + let entry = entry?; + let ty = entry.file_type()?; + if ty.is_dir() { + move_dir_all(entry.path(), dst.as_ref().join(entry.file_name()))?; + std::fs::remove_dir(entry.path())?; + } else { + std::fs::rename(entry.path(), dst.as_ref().join(entry.file_name()))?; + } + } + Ok(()) +} diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 245915f0..b5b5b6f7 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -8,7 +8,7 @@ }, "package": { "productName": "FlightCore", - "version": "2.2.0" + "version": "2.4.0" }, "tauri": { "allowlist": { diff --git a/src-vue/src/plugins/store.ts b/src-vue/src/plugins/store.ts index c2664b6b..b28dd5a8 100644 --- a/src-vue/src/plugins/store.ts +++ b/src-vue/src/plugins/store.ts @@ -181,7 +181,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_install.game_path, northstarPackageName: state.northstar_release_canal }); + let install_northstar_result = invoke("install_northstar_caller", { gameInstall: state.game_install, northstarPackageName: state.northstar_release_canal }); state.northstar_state = NorthstarState.INSTALLING; await install_northstar_result.then((message) => { @@ -198,7 +198,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_install.game_path, northstarPackageName: state.northstar_release_canal }); + let reinstall_northstar_result = invoke("install_northstar_caller", { gameInstall: state.game_install, northstarPackageName: state.northstar_release_canal }); state.northstar_state = NorthstarState.UPDATING; await reinstall_northstar_result.then((message) => { @@ -374,6 +374,12 @@ async function _initializeApp(state: any) { && persistent_game_install.value.game_path !== undefined && persistent_game_install.value.install_type !== undefined ) { // For some reason, the plugin-store doesn't throw an eror but simply returns `null` when key not found + + // Add profile to existing storage + if (persistent_game_install.value.profile === undefined) { + persistent_game_install.value.profile = "R2Northstar" + } + let game_install = persistent_game_install.value as GameInstall; // check if valid path let is_valid_titanfall2_install = await invoke("verify_install_location", { gamePath: game_install.game_path }) as boolean; @@ -463,13 +469,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_install.game_path }) + await invoke("get_northstar_version_number", { gameInstall: state.game_install }) .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_install.game_path, northstarPackageName: state.northstar_release_canal }) + invoke("check_is_northstar_outdated", { gameInstall: state.game_install, northstarPackageName: state.northstar_release_canal }) .then((message) => { if (message) { state.northstar_state = NorthstarState.MUST_UPDATE; diff --git a/src-vue/src/utils/GameInstall.ts b/src-vue/src/utils/GameInstall.ts index 07358f6c..162d2860 100644 --- a/src-vue/src/utils/GameInstall.ts +++ b/src-vue/src/utils/GameInstall.ts @@ -1,4 +1,5 @@ export interface GameInstall { game_path: string; + profile: string, install_type: string; } diff --git a/src-vue/src/views/DeveloperView.vue b/src-vue/src/views/DeveloperView.vue index 188dc7a3..8adc7587 100644 --- a/src-vue/src/views/DeveloperView.vue +++ b/src-vue/src/views/DeveloperView.vue @@ -89,6 +89,10 @@ Get installed mods </el-button> + <el-button type="primary" @click="killNorthstar"> + Kill Northstar + </el-button> + <h3>Testing</h3> <pull-requests-selector /> @@ -134,6 +138,10 @@ Compare Tags </el-button> + <el-button type="primary" @click="copyReleaseNotesToClipboard"> + Copy to clipboard + </el-button> + <el-input v-model="release_notes_text" type="textarea" @@ -243,6 +251,16 @@ export default defineComponent({ showErrorNotification(error); }); }, + async killNorthstar() { + await invoke("kill_northstar") + .then((message) => { + // Just a visual indicator that it worked + showNotification('Success'); + }) + .catch((error) => { + showErrorNotification(error); + }); + }, async installMod() { let mod_to_install = this.mod_to_install_field_string; await invoke<string>("install_mod_caller", { gameInstall: this.$store.state.game_install, thunderstoreModString: mod_to_install }).then((message) => { @@ -271,6 +289,7 @@ export default defineComponent({ .then((message) => { this.release_notes_text = message; showNotification("Done", "Generated release notes"); + this.copyReleaseNotesToClipboard(); }) .catch((error) => { showErrorNotification(error); @@ -312,7 +331,7 @@ export default defineComponent({ 0 ); - 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 }); + let install_northstar_result = invoke("install_northstar_caller", { gameInstall: this.$store.state.game_install, northstarPackageName: this.selected_ns_version.value.package, versionNumber: this.selected_ns_version.value.version }); await install_northstar_result .then((message) => { @@ -345,6 +364,15 @@ export default defineComponent({ .then((message) => { showNotification(`NSProton Version`, message as string); }) .catch((error) => { showNotification(`Error`, error, "error"); }) }, + async copyReleaseNotesToClipboard() { + navigator.clipboard.writeText(this.release_notes_text) + .then(() => { + showNotification("Copied to clipboard"); + }) + .catch(() => { + showErrorNotification("Failed copying to clipboard"); + }); + }, } }); </script> diff --git a/src-vue/src/views/RepairView.vue b/src-vue/src/views/RepairView.vue index 614c1e56..65c533d2 100644 --- a/src-vue/src/views/RepairView.vue +++ b/src-vue/src/views/RepairView.vue @@ -71,7 +71,7 @@ export default defineComponent({ 0 ); - let install_northstar_result = invoke("install_northstar_caller", { gamePath: this.$store.state.game_install.game_path, northstarPackageName: ReleaseCanal.RELEASE }); + let install_northstar_result = invoke("install_northstar_caller", { gameInstall: this.$store.state.game_install, northstarPackageName: ReleaseCanal.RELEASE }); appWindow.listen<InstallProgress>( 'northstar-install-download-progress', |