From e492ba69a28c49220f2b89f96a0c3a5dc55f5228 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Wed, 22 Mar 2023 20:21:18 +0200 Subject: [PATCH] 0.5.5 - added `LauncherState::XluaPatchAvailable` - added `patch.apply_xlua` flag to config --- Cargo.toml | 2 +- anime-game-core | 2 +- src/config/patch.rs | 13 +++++++++++-- src/states.rs | 46 ++++++++++++++++++++++++++------------------- 4 files changed, 40 insertions(+), 23 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 82f8602..08744c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "anime-launcher-sdk" -version = "0.5.4" +version = "0.5.5" authors = ["Nikita Podvirnyy "] license = "GPL-3.0" readme = "README.md" diff --git a/anime-game-core b/anime-game-core index 160053e..70725c3 160000 --- a/anime-game-core +++ b/anime-game-core @@ -1 +1 @@ -Subproject commit 160053e6c9b8f55826ba724d5e68e448dad3cd0e +Subproject commit 70725c34c8620686e20099e0c655fe8bd4aebed0 diff --git a/src/config/patch.rs b/src/config/patch.rs index 91bb9bc..f95430a 100644 --- a/src/config/patch.rs +++ b/src/config/patch.rs @@ -9,6 +9,7 @@ use crate::consts::launcher_dir; pub struct Patch { pub path: PathBuf, pub servers: Vec, + pub apply_xlua: bool, pub root: bool } @@ -18,11 +19,14 @@ impl Default for Patch { Self { path: launcher_dir.join("patch"), + servers: vec![ - "https://notabug.org/Krock/dawn".to_string(), - "https://codespace.gay/Maroxy/dawnin".to_string() + String::from("https://notabug.org/Krock/dawn"), + String::from("https://codespace.gay/Maroxy/dawnin") ], + apply_xlua: false, + // Disable root requirement for patching if we're running launcher in flatpak root: !Path::new("/.flatpak-info").exists() } @@ -60,6 +64,11 @@ impl From<&JsonValue> for Patch { None => default.servers }, + apply_xlua: match value.get("apply_xlua") { + Some(value) => value.as_bool().unwrap_or(default.apply_xlua), + None => default.apply_xlua + }, + root: match value.get("root") { Some(value) => value.as_bool().unwrap_or(default.root), None => default.root diff --git a/src/states.rs b/src/states.rs index 4c7a02b..d26e14d 100644 --- a/src/states.rs +++ b/src/states.rs @@ -19,7 +19,8 @@ pub enum LauncherState { voices: Vec }, - MainPatchAvailable(UnityPlayerPatch), + UnityPlayerPatchAvailable(UnityPlayerPatch), + XluaPatchAvailable(XluaPatch), #[cfg(feature = "components")] WineNotInstalled, @@ -87,7 +88,7 @@ impl LauncherState { let game = Game::new(¶ms.game_path); let diff = game.try_get_diff()?; - Ok(match diff { + match diff { VersionDiff::Latest(_) | VersionDiff::Predownload { .. } => { let mut predownload_voice = Vec::new(); @@ -132,32 +133,39 @@ impl LauncherState { } // Check UnityPlayer patch - let main_patch = patch.unity_player_patch()?; + let player_patch = patch.unity_player_patch()?; - if main_patch.is_applied(¶ms.game_path)? { - // TODO: add Xlua patch check + if !player_patch.is_applied(¶ms.game_path)? { + return Ok(Self::UnityPlayerPatchAvailable(player_patch)); + } - if let VersionDiff::Predownload { .. } = diff { - Self::PredownloadAvailable { - game: diff, - voices: predownload_voice - } - } + // Check xlua patch + if params.use_xlua_patch { + let xlua_patch = patch.xlua_patch()?; - else { - Self::Launch + if !xlua_patch.is_applied(¶ms.game_path)? { + return Ok(Self::XluaPatchAvailable(xlua_patch)); } } + // Check if update predownload available + if let VersionDiff::Predownload { .. } = diff { + Ok(Self::PredownloadAvailable { + game: diff, + voices: predownload_voice + }) + } + + // Otherwise we can launch the game else { - Self::MainPatchAvailable(main_patch) + Ok(Self::Launch) } } - VersionDiff::Diff { .. } => Self::GameUpdateAvailable(diff), - VersionDiff::Outdated { .. } => Self::GameOutdated(diff), - VersionDiff::NotInstalled { .. } => Self::GameNotInstalled(diff) - }) + VersionDiff::Diff { .. } => Ok(Self::GameUpdateAvailable(diff)), + VersionDiff::Outdated { .. } => Ok(Self::GameOutdated(diff)), + VersionDiff::NotInstalled { .. } => Ok(Self::GameNotInstalled(diff)) + } } #[cfg(feature = "config")] @@ -214,7 +222,7 @@ impl LauncherState { patch_servers: config.patch.servers, patch_folder: config.patch.path, - use_xlua_patch: false, // TODO + use_xlua_patch: config.patch.xlua_patch, status_updater })