From 1ecc5ec822cd163042b9b50459067c924fcb5828 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sun, 21 May 2023 11:33:07 +0200 Subject: [PATCH] 1.4.0 - updated core library, got rid of `GameEdition::current()` --- Cargo.toml | 6 +++--- src/games/genshin/game.rs | 4 ++-- src/games/genshin/states.rs | 20 +++++++++++--------- src/games/star_rail/game.rs | 2 +- src/games/star_rail/states.rs | 10 ++++++---- 5 files changed, 23 insertions(+), 19 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4199ffb..48e06be 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "anime-launcher-sdk" -version = "1.3.0" +version = "1.4.0" authors = ["Nikita Podvirnyy "] license = "GPL-3.0" readme = "README.md" @@ -8,7 +8,7 @@ edition = "2021" [dependencies.anime-game-core] git = "https://github.com/an-anime-team/anime-game-core" -tag = "1.9.0" +tag = "1.10.0" features = ["all"] # path = "../anime-game-core" # ! for dev purposes only @@ -30,8 +30,8 @@ discord-rich-presence = { version = "0.2.3", optional = true } [features] genshin = ["anime-game-core/genshin"] -honkai = ["anime-game-core/honkai"] star-rail = ["anime-game-core/star-rail"] +honkai = ["anime-game-core/honkai"] # Common features states = [] diff --git a/src/games/genshin/game.rs b/src/games/genshin/game.rs index ba73af7..8281f2d 100644 --- a/src/games/genshin/game.rs +++ b/src/games/genshin/game.rs @@ -71,7 +71,7 @@ pub fn run() -> anyhow::Result<()> { tracing::info!("Checking telemetry"); - if let Ok(Some(server)) = telemetry::is_disabled() { + if let Ok(Some(server)) = telemetry::is_disabled(config.launcher.edition) { return Err(anyhow::anyhow!("Telemetry server is not disabled: {server}")); } @@ -120,7 +120,7 @@ pub fn run() -> anyhow::Result<()> { // Generate `config.ini` if environment emulation feature is presented #[cfg(feature = "environment-emulation")] { - let game = Game::new(game_path); + let game = Game::new(game_path, config.launcher.edition); std::fs::write( game_path.join("config.ini"), diff --git a/src/games/genshin/states.rs b/src/games/genshin/states.rs index 4fc7737..6b9b685 100644 --- a/src/games/genshin/states.rs +++ b/src/games/genshin/states.rs @@ -60,9 +60,10 @@ pub enum StateUpdating { #[derive(Debug, Clone, PartialEq, Eq)] pub struct LauncherStateParams { - pub wine_prefix: PathBuf, pub game_path: PathBuf, + pub game_edition: GameEdition, + pub wine_prefix: PathBuf, pub selected_voices: Vec, pub patch_servers: Vec, @@ -84,11 +85,11 @@ impl LauncherState { // Check game installation status (params.status_updater)(StateUpdating::Game); - let game = Game::new(¶ms.game_path); + let game = Game::new(¶ms.game_path, params.game_edition); // Check if game is installed if game.is_installed() { - let data_folder = params.game_path.join(GameEdition::selected().data_folder()); + let data_folder = params.game_path.join(params.game_edition.data_folder()); let old_audio_folder_base = data_folder.join("StreamingAssets/Audio"); let old_audio_folder = old_audio_folder_base.join("GeneratedSoundBanks/Windows"); @@ -106,18 +107,18 @@ impl LauncherState { let diff = game.try_get_diff()?; match diff { - VersionDiff::Latest(_) | VersionDiff::Predownload { .. } => { + VersionDiff::Latest { .. } | VersionDiff::Predownload { .. } => { let mut predownload_voice = Vec::new(); for locale in params.selected_voices { - let mut voice_package = VoicePackage::with_locale(locale)?; + let mut voice_package = VoicePackage::with_locale(locale, params.game_edition)?; (params.status_updater)(StateUpdating::Voice(voice_package.locale())); // Replace voice package struct with the one constructed in the game's folder // so it'll properly calculate its difference instead of saying "not installed" if voice_package.is_installed_in(¶ms.game_path) { - voice_package = match VoicePackage::new(get_voice_package_path(¶ms.game_path, voice_package.locale())) { + voice_package = match VoicePackage::new(get_voice_package_path(¶ms.game_path, params.game_edition, voice_package.locale()), params.game_edition) { Some(locale) => locale, None => return Err(anyhow::anyhow!("Failed to load {} voice package", voice_package.locale().to_name())) }; @@ -126,7 +127,7 @@ impl LauncherState { let diff = voice_package.try_get_diff()?; match diff { - VersionDiff::Latest(_) => (), + VersionDiff::Latest { .. } => (), VersionDiff::Predownload { .. } => predownload_voice.push(diff), VersionDiff::Diff { .. } => return Ok(Self::VoiceUpdateAvailable(diff)), @@ -138,7 +139,7 @@ impl LauncherState { // Check game patch status (params.status_updater)(StateUpdating::Patch); - let patch = Patch::new(¶ms.patch_folder); + let patch = Patch::new(¶ms.patch_folder, params.game_edition); // Sync local patch folder with remote if needed // TODO: maybe I shouldn't do it here? @@ -212,9 +213,10 @@ impl LauncherState { } Self::get(LauncherStateParams { - wine_prefix: config.get_wine_prefix_path(), game_path: config.game.path.for_edition(config.launcher.edition).to_path_buf(), + game_edition: config.launcher.edition, + wine_prefix: config.get_wine_prefix_path(), selected_voices: voices, patch_servers: config.patch.servers, diff --git a/src/games/star_rail/game.rs b/src/games/star_rail/game.rs index d81d37b..ac32b97 100644 --- a/src/games/star_rail/game.rs +++ b/src/games/star_rail/game.rs @@ -65,7 +65,7 @@ pub fn run() -> anyhow::Result<()> { tracing::info!("Checking telemetry"); - if let Ok(Some(server)) = telemetry::is_disabled() { + if let Ok(Some(server)) = telemetry::is_disabled(config.launcher.edition) { return Err(anyhow::anyhow!("Telemetry server is not disabled: {server}")); } diff --git a/src/games/star_rail/states.rs b/src/games/star_rail/states.rs index c780591..78c40be 100644 --- a/src/games/star_rail/states.rs +++ b/src/games/star_rail/states.rs @@ -40,10 +40,11 @@ pub enum StateUpdating { #[derive(Debug, Clone, PartialEq, Eq)] pub struct LauncherStateParams { - pub wine_prefix: PathBuf, pub game_path: PathBuf, pub game_edition: GameEdition, + pub wine_prefix: PathBuf, + pub patch_servers: Vec, pub patch_folder: PathBuf, @@ -62,11 +63,11 @@ impl LauncherState { // Check game installation status (params.status_updater)(StateUpdating::Game); - let game = Game::new(¶ms.game_path); + let game = Game::new(¶ms.game_path, params.game_edition); let diff = game.try_get_diff()?; match diff { - VersionDiff::Latest(_) | VersionDiff::Predownload { .. } => { + VersionDiff::Latest { .. } | VersionDiff::Predownload { .. } => { // Check game patch status (params.status_updater)(StateUpdating::Patch); @@ -123,10 +124,11 @@ impl LauncherState { } Self::get(LauncherStateParams { - wine_prefix: config.get_wine_prefix_path(), game_path: config.game.path.for_edition(config.launcher.edition).to_path_buf(), game_edition: config.launcher.edition, + wine_prefix: config.get_wine_prefix_path(), + patch_servers: config.patch.servers, patch_folder: config.patch.path,