feat: replaced xlua patch by "disable mhypbase" option

This commit is contained in:
Observer KRypt0n_ 2023-06-18 00:33:27 +02:00
parent a1962a5267
commit d00dee3ec0
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
13 changed files with 71 additions and 209 deletions

View file

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Changed
- Replaced xlua patch by "disable mhypbase" option
## [3.7.2] - 14.06.2023 ## [3.7.2] - 14.06.2023
### Fixed ### Fixed

8
Cargo.lock generated
View file

@ -48,8 +48,8 @@ dependencies = [
[[package]] [[package]]
name = "anime-game-core" name = "anime-game-core"
version = "1.12.6" version = "1.13.0"
source = "git+https://github.com/an-anime-team/anime-game-core?tag=1.12.6#704c7fb4741fa1c90596d5862f963653cd0ddbbd" source = "git+https://github.com/an-anime-team/anime-game-core?tag=1.13.0#440dca2cca2e5109468751033c566ab0777324e2"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bzip2", "bzip2",
@ -96,8 +96,8 @@ dependencies = [
[[package]] [[package]]
name = "anime-launcher-sdk" name = "anime-launcher-sdk"
version = "1.7.8" version = "1.8.0"
source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=1.7.8#e46f42674d9c9d7923759cbd01f41c86ea61ce91" source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=1.8.0#01486e00a49c1ee7c78eaf81290136ae3ba69520"
dependencies = [ dependencies = [
"anime-game-core", "anime-game-core",
"anyhow", "anyhow",

View file

@ -17,7 +17,7 @@ glib-build-tools = "0.17"
[dependencies.anime-launcher-sdk] [dependencies.anime-launcher-sdk]
git = "https://github.com/an-anime-team/anime-launcher-sdk" git = "https://github.com/an-anime-team/anime-launcher-sdk"
tag = "1.7.8" tag = "1.8.0"
features = ["all", "genshin", "genshin-patch"] features = ["all", "genshin", "genshin-patch"]
# path = "../anime-launcher-sdk" # ! for dev purposes only # path = "../anime-launcher-sdk" # ! for dev purposes only

View file

@ -197,8 +197,7 @@ fn main() {
} }
LauncherState::PredownloadAvailable { .. } | LauncherState::PredownloadAvailable { .. } |
LauncherState::UnityPlayerPatchAvailable(UnityPlayerPatch { status: PatchStatus::NotAvailable, .. }) | LauncherState::PlayerPatchAvailable { patch: PlayerPatch { status: PatchStatus::NotAvailable, .. }, .. } => {
LauncherState::XluaPatchAvailable(XluaPatch { status: PatchStatus::NotAvailable, .. }) => {
if just_run_game { if just_run_game {
anime_launcher_sdk::genshin::game::run().expect("Failed to run the game"); anime_launcher_sdk::genshin::game::run().expect("Failed to run the game");

View file

@ -5,7 +5,7 @@ use crate::i18n::*;
use super::{App, AppMsg}; use super::{App, AppMsg};
pub fn apply_patch<T: PatchExt + Send + Sync + 'static>(sender: ComponentSender<App>, patch: T) { pub fn apply_patch(sender: ComponentSender<App>, patch: PlayerPatch, rename_mhypbase: bool) {
match patch.status() { match patch.status() {
PatchStatus::NotAvailable | PatchStatus::NotAvailable |
PatchStatus::Outdated { .. } | PatchStatus::Outdated { .. } |
@ -18,8 +18,6 @@ pub fn apply_patch<T: PatchExt + Send + Sync + 'static>(sender: ComponentSender<
let config = Config::get().unwrap(); let config = Config::get().unwrap();
std::thread::spawn(move || { std::thread::spawn(move || {
let mut apply_patch_if_needed = true;
if let Err(err) = patch.apply(config.game.path.for_edition(config.launcher.edition), config.patch.root) { if let Err(err) = patch.apply(config.game.path.for_edition(config.launcher.edition), config.patch.root) {
tracing::error!("Failed to patch the game"); tracing::error!("Failed to patch the game");
@ -27,16 +25,29 @@ pub fn apply_patch<T: PatchExt + Send + Sync + 'static>(sender: ComponentSender<
title: tr("game-patching-error"), title: tr("game-patching-error"),
description: Some(err.to_string()) description: Some(err.to_string())
}); });
}
// Don't try to apply the patch after state updating else if rename_mhypbase {
// because we just failed to do it let game_folder = config.game.path.for_edition(patch.edition);
apply_patch_if_needed = false;
let mhypbase = game_folder.join("mhypbase.dll");
let mhypbase_bak = game_folder.join("mhypbase.dll.bak");
if mhypbase.exists() {
if let Err(err) = std::fs::rename(mhypbase, mhypbase_bak) {
tracing::error!("Failed to rename mhypbase file");
sender.input(AppMsg::Toast {
title: tr("game-patching-error"),
description: Some(err.to_string())
});
}
}
} }
sender.input(AppMsg::DisableButtons(false)); sender.input(AppMsg::DisableButtons(false));
sender.input(AppMsg::UpdateLauncherState { sender.input(AppMsg::UpdateLauncherState {
perform_on_download_needed: false, perform_on_download_needed: false,
apply_patch_if_needed,
show_status_page: true show_status_page: true
}); });
}); });

View file

@ -35,7 +35,6 @@ pub fn create_prefix(sender: ComponentSender<App>) {
sender.input(AppMsg::DisableButtons(false)); sender.input(AppMsg::DisableButtons(false));
sender.input(AppMsg::UpdateLauncherState { sender.input(AppMsg::UpdateLauncherState {
perform_on_download_needed: false, perform_on_download_needed: false,
apply_patch_if_needed: false,
show_status_page: true show_status_page: true
}); });
}); });

View file

@ -68,7 +68,6 @@ pub fn download_diff(sender: ComponentSender<App>, progress_bar_input: Sender<Pr
sender.input(AppMsg::SetDownloading(false)); sender.input(AppMsg::SetDownloading(false));
sender.input(AppMsg::UpdateLauncherState { sender.input(AppMsg::UpdateLauncherState {
perform_on_download_needed, perform_on_download_needed,
apply_patch_if_needed: false,
show_status_page: false show_status_page: false
}); });
}); });

View file

@ -26,7 +26,6 @@ pub fn download_wine(sender: ComponentSender<App>, progress_bar_input: Sender<Pr
sender.input(AppMsg::UpdateLauncherState { sender.input(AppMsg::UpdateLauncherState {
perform_on_download_needed: false, perform_on_download_needed: false,
apply_patch_if_needed: false,
show_status_page: true show_status_page: true
}); });
} }
@ -90,7 +89,6 @@ pub fn download_wine(sender: ComponentSender<App>, progress_bar_input: Sender<Pr
sender.input(AppMsg::SetDownloading(false)); sender.input(AppMsg::SetDownloading(false));
sender.input(AppMsg::UpdateLauncherState { sender.input(AppMsg::UpdateLauncherState {
perform_on_download_needed: false, perform_on_download_needed: false,
apply_patch_if_needed: false,
show_status_page: true show_status_page: true
}); });
})); }));

View file

@ -19,7 +19,6 @@ pub fn migrate_folder(sender: ComponentSender<App>, from: PathBuf, to: PathBuf,
sender.input(AppMsg::DisableButtons(false)); sender.input(AppMsg::DisableButtons(false));
sender.input(AppMsg::UpdateLauncherState { sender.input(AppMsg::UpdateLauncherState {
perform_on_download_needed: false, perform_on_download_needed: false,
apply_patch_if_needed: false,
show_status_page: true show_status_page: true
}); });
}); });

View file

@ -69,9 +69,6 @@ pub enum AppMsg {
/// Needed for chained executions (e.g. update one voice after another) /// Needed for chained executions (e.g. update one voice after another)
perform_on_download_needed: bool, perform_on_download_needed: bool,
/// Automatically start patch applying if possible and needed
apply_patch_if_needed: bool,
/// Show status gathering progress page /// Show status gathering progress page
show_status_page: bool show_status_page: bool
}, },
@ -82,11 +79,7 @@ pub enum AppMsg {
/// Supposed to be called automatically on app's run when the latest UnityPlayer patch version /// Supposed to be called automatically on app's run when the latest UnityPlayer patch version
/// was retrieved from remote repos /// was retrieved from remote repos
SetUnityPlayerPatch(Option<UnityPlayerPatch>), SetPlayerPatch(Option<PlayerPatch>),
/// Supposed to be called automatically on app's run when the latest xlua patch version
/// was retrieved from remote repos
SetXluaPatch(Option<XluaPatch>),
/// Supposed to be called automatically on app's run when the launcher state was chosen /// Supposed to be called automatically on app's run when the launcher state was chosen
SetLauncherState(Option<LauncherState>), SetLauncherState(Option<LauncherState>),
@ -392,8 +385,7 @@ impl SimpleComponent for App {
Some(LauncherState::VoiceUpdateAvailable(_)) | Some(LauncherState::VoiceUpdateAvailable(_)) |
Some(LauncherState::VoiceNotInstalled(_)) => "document-save-symbolic", Some(LauncherState::VoiceNotInstalled(_)) => "document-save-symbolic",
Some(LauncherState::UnityPlayerPatchAvailable(UnityPlayerPatch { status, .. })) | Some(LauncherState::PlayerPatchAvailable { patch: PlayerPatch { status, .. }, .. }) => match status {
Some(LauncherState::XluaPatchAvailable(XluaPatch { status, .. })) => match status {
PatchStatus::NotAvailable | PatchStatus::NotAvailable |
PatchStatus::Outdated { .. } | PatchStatus::Outdated { .. } |
PatchStatus::Preparation { .. } => "window-close-symbolic", PatchStatus::Preparation { .. } => "window-close-symbolic",
@ -413,9 +405,7 @@ impl SimpleComponent for App {
Some(LauncherState::PredownloadAvailable { .. }) => tr("launch"), Some(LauncherState::PredownloadAvailable { .. }) => tr("launch"),
Some(LauncherState::FolderMigrationRequired { .. }) => tr("migrate-folders"), Some(LauncherState::FolderMigrationRequired { .. }) => tr("migrate-folders"),
Some(LauncherState::PlayerPatchAvailable { .. }) => tr("apply-patch"),
Some(LauncherState::UnityPlayerPatchAvailable(_)) |
Some(LauncherState::XluaPatchAvailable(_)) => tr("apply-patch"),
Some(LauncherState::WineNotInstalled) => tr("download-wine"), Some(LauncherState::WineNotInstalled) => tr("download-wine"),
Some(LauncherState::PrefixNotExists) => tr("create-prefix"), Some(LauncherState::PrefixNotExists) => tr("create-prefix"),
@ -453,8 +443,7 @@ impl SimpleComponent for App {
Some(LauncherState::GameOutdated { .. }) | Some(LauncherState::GameOutdated { .. }) |
Some(LauncherState::VoiceOutdated(_)) => false, Some(LauncherState::VoiceOutdated(_)) => false,
Some(LauncherState::UnityPlayerPatchAvailable(UnityPlayerPatch { status, .. })) | Some(LauncherState::PlayerPatchAvailable { patch: PlayerPatch { status, .. }, .. }) => match status {
Some(LauncherState::XluaPatchAvailable(XluaPatch { status, .. })) => match status {
PatchStatus::NotAvailable | PatchStatus::NotAvailable |
PatchStatus::Outdated { .. } | PatchStatus::Outdated { .. } |
PatchStatus::Preparation { .. } => false, PatchStatus::Preparation { .. } => false,
@ -473,8 +462,7 @@ impl SimpleComponent for App {
Some(LauncherState::GameOutdated { .. }) | Some(LauncherState::GameOutdated { .. }) |
Some(LauncherState::VoiceOutdated(_)) => &["warning", "pill"], Some(LauncherState::VoiceOutdated(_)) => &["warning", "pill"],
Some(LauncherState::UnityPlayerPatchAvailable(UnityPlayerPatch { status, .. })) | Some(LauncherState::PlayerPatchAvailable { patch: PlayerPatch { status, .. }, .. }) => match status {
Some(LauncherState::XluaPatchAvailable(XluaPatch { status, .. })) => match status {
PatchStatus::NotAvailable | PatchStatus::NotAvailable |
PatchStatus::Outdated { .. } | PatchStatus::Outdated { .. } |
PatchStatus::Preparation { .. } => &["error", "pill"], PatchStatus::Preparation { .. } => &["error", "pill"],
@ -495,8 +483,7 @@ impl SimpleComponent for App {
Some(LauncherState::FolderMigrationRequired { .. }) => tr("migrate-folders-tooltip"), Some(LauncherState::FolderMigrationRequired { .. }) => tr("migrate-folders-tooltip"),
Some(LauncherState::UnityPlayerPatchAvailable(UnityPlayerPatch { status, .. })) | Some(LauncherState::PlayerPatchAvailable { patch: PlayerPatch { status, .. }, .. }) => match status {
Some(LauncherState::XluaPatchAvailable(XluaPatch { status, .. })) => match status {
PatchStatus::NotAvailable => tr("main-window--patch-unavailable-tooltip"), PatchStatus::NotAvailable => tr("main-window--patch-unavailable-tooltip"),
PatchStatus::Outdated { .. } | PatchStatus::Outdated { .. } |
@ -831,27 +818,11 @@ impl SimpleComponent for App {
} }
// Get main UnityPlayer patch status // Get main UnityPlayer patch status
sender.input(AppMsg::SetUnityPlayerPatch(match patch.unity_player_patch() { sender.input(AppMsg::SetPlayerPatch(match patch.player_patch() {
Ok(patch) => Some(patch), Ok(patch) => Some(patch),
Err(err) => { Err(err) => {
tracing::error!("Failed to fetch unity player patch info: {err}"); tracing::error!("Failed to fetch player patch info: {err}");
sender.input(AppMsg::Toast {
title: tr("patch-info-fetching-error"),
description: Some(err.to_string())
});
None
}
}));
// Get additional xlua patch status
sender.input(AppMsg::SetXluaPatch(match patch.xlua_patch() {
Ok(patch) => Some(patch),
Err(err) => {
tracing::error!("Failed to fetch xlua patch info: {err}");
sender.input(AppMsg::Toast { sender.input(AppMsg::Toast {
title: tr("patch-info-fetching-error"), title: tr("patch-info-fetching-error"),
@ -893,7 +864,6 @@ impl SimpleComponent for App {
// Update launcher state // Update launcher state
sender.input(AppMsg::UpdateLauncherState { sender.input(AppMsg::UpdateLauncherState {
perform_on_download_needed: false, perform_on_download_needed: false,
apply_patch_if_needed: false,
show_status_page: true show_status_page: true
}); });
@ -913,7 +883,7 @@ impl SimpleComponent for App {
match msg { match msg {
// TODO: make function from this message like with toast // TODO: make function from this message like with toast
AppMsg::UpdateLauncherState { perform_on_download_needed, apply_patch_if_needed, show_status_page } => { AppMsg::UpdateLauncherState { perform_on_download_needed, show_status_page } => {
if show_status_page { if show_status_page {
sender.input(AppMsg::SetLoadingStatus(Some(Some(tr("loading-launcher-state"))))); sender.input(AppMsg::SetLoadingStatus(Some(Some(tr("loading-launcher-state")))));
} else { } else {
@ -968,11 +938,6 @@ impl SimpleComponent for App {
sender.input(AppMsg::PerformAction); sender.input(AppMsg::PerformAction);
} }
LauncherState::UnityPlayerPatchAvailable(_) |
LauncherState::XluaPatchAvailable(_) if apply_patch_if_needed => {
sender.input(AppMsg::PerformAction);
}
_ => () _ => ()
} }
} }
@ -984,13 +949,8 @@ impl SimpleComponent for App {
} }
#[allow(unused_must_use)] #[allow(unused_must_use)]
AppMsg::SetUnityPlayerPatch(patch) => unsafe { AppMsg::SetPlayerPatch(patch) => unsafe {
PREFERENCES_WINDOW.as_ref().unwrap_unchecked().sender().send(PreferencesAppMsg::SetUnityPlayerPatch(patch)); PREFERENCES_WINDOW.as_ref().unwrap_unchecked().sender().send(PreferencesAppMsg::SetPlayerPatch(patch));
}
#[allow(unused_must_use)]
AppMsg::SetXluaPatch(patch) => unsafe {
PREFERENCES_WINDOW.as_ref().unwrap_unchecked().sender().send(PreferencesAppMsg::SetXluaPatch(patch));
} }
AppMsg::SetLauncherState(state) => { AppMsg::SetLauncherState(state) => {
@ -1055,7 +1015,6 @@ impl SimpleComponent for App {
sender.input(AppMsg::SetDownloading(false)); sender.input(AppMsg::SetDownloading(false));
sender.input(AppMsg::UpdateLauncherState { sender.input(AppMsg::UpdateLauncherState {
perform_on_download_needed: false, perform_on_download_needed: false,
apply_patch_if_needed: false,
show_status_page: true show_status_page: true
}); });
}); });
@ -1064,20 +1023,18 @@ impl SimpleComponent for App {
AppMsg::PerformAction => unsafe { AppMsg::PerformAction => unsafe {
match self.state.as_ref().unwrap_unchecked() { match self.state.as_ref().unwrap_unchecked() {
LauncherState::UnityPlayerPatchAvailable(UnityPlayerPatch { status: PatchStatus::NotAvailable, .. }) | LauncherState::PlayerPatchAvailable { patch: PlayerPatch { status: PatchStatus::NotAvailable, .. }, .. } |
LauncherState::XluaPatchAvailable(XluaPatch { status: PatchStatus::NotAvailable, .. }) |
LauncherState::PredownloadAvailable { .. } | LauncherState::PredownloadAvailable { .. } |
LauncherState::Launch => launch::launch(sender), LauncherState::Launch => launch::launch(sender),
LauncherState::FolderMigrationRequired { from, to, cleanup_folder } => LauncherState::FolderMigrationRequired { from, to, cleanup_folder } =>
migrate_folder::migrate_folder(sender, from.to_owned(), to.to_owned(), cleanup_folder.to_owned()), migrate_folder::migrate_folder(sender, from.to_owned(), to.to_owned(), cleanup_folder.to_owned()),
LauncherState::UnityPlayerPatchAvailable(patch) => apply_patch::apply_patch(sender, patch.to_owned()), LauncherState::PlayerPatchAvailable { patch, disable_mhypbase } =>
LauncherState::XluaPatchAvailable(patch) => apply_patch::apply_patch(sender, patch.to_owned()), apply_patch::apply_patch(sender, patch.to_owned(), *disable_mhypbase),
LauncherState::WineNotInstalled => download_wine::download_wine(sender, self.progress_bar.sender().to_owned()), LauncherState::WineNotInstalled => download_wine::download_wine(sender, self.progress_bar.sender().to_owned()),
LauncherState::PrefixNotExists => create_prefix::create_prefix(sender),
LauncherState::PrefixNotExists => create_prefix::create_prefix(sender),
LauncherState::VoiceUpdateAvailable(diff) | LauncherState::VoiceUpdateAvailable(diff) |
LauncherState::VoiceNotInstalled(diff) | LauncherState::VoiceNotInstalled(diff) |

View file

@ -108,27 +108,17 @@ pub fn repair_game(sender: ComponentSender<App>, progress_bar_input: Sender<Prog
// Get main patch status // Get main patch status
let player_patch = UnityPlayerPatch::from_folder(&config.patch.path, config.launcher.edition) let player_patch = PlayerPatch::from_folder(&config.patch.path, config.launcher.edition)
.and_then(|patch| patch.is_applied(&game_path)) .and_then(|patch| patch.is_applied(&game_path))
.unwrap_or_else(|err| { .unwrap_or_else(|err| {
tracing::warn!("Failed to get player patch status: {err}. Used config value instead: {}", config.patch.apply_main); tracing::warn!("Failed to get player patch status: {err}. Used config value instead: {}", config.patch.apply);
config.patch.apply_main config.patch.apply
}); });
// Get xlua patch status tracing::debug!("Patch status: {player_patch}. Disable mhypbase: {}", config.patch.disable_mhypbase);
let xlua_patch = XluaPatch::from_folder(&config.patch.path, config.launcher.edition) fn should_ignore(path: &Path, player_patch: bool, disable_mhypbase: bool) -> bool {
.and_then(|patch| patch.is_applied(&game_path))
.unwrap_or_else(|err| {
tracing::warn!("Failed to get xlua patch status: {err}. Used config value instead: {}", config.patch.apply_xlua);
config.patch.apply_xlua
});
tracing::debug!("Patches status: player({player_patch}), xlua({xlua_patch})");
fn should_ignore(path: &Path, player_patch: bool, xlua_patch: bool) -> bool {
// Files managed by launch.bat file // Files managed by launch.bat file
for part in ["crashreport.exe", "upload_crash.exe"] { for part in ["crashreport.exe", "upload_crash.exe"] {
if path.ends_with(part) { if path.ends_with(part) {
@ -145,20 +135,16 @@ pub fn repair_game(sender: ComponentSender<App>, progress_bar_input: Sender<Prog
} }
} }
// Xlua patch related files // If mhypbase should be disabled
if xlua_patch { if disable_mhypbase && path.ends_with("mhypbase.dll") {
for part in ["xlua.dll", "mhypbase.dll"] { return true;
if path.ends_with(part) {
return true;
}
}
} }
false false
} }
for (i, file) in broken.into_iter().enumerate() { for (i, file) in broken.into_iter().enumerate() {
if !should_ignore(&file.path, player_patch, xlua_patch) { if !should_ignore(&file.path, player_patch, config.patch.disable_mhypbase) {
tracing::debug!("Repairing file: {}", file.path.to_string_lossy()); tracing::debug!("Repairing file: {}", file.path.to_string_lossy());
if let Err(err) = file.repair(&game_path) { if let Err(err) = file.repair(&game_path) {

View file

@ -111,8 +111,7 @@ pub struct GeneralApp {
components_page: AsyncController<ComponentsPage>, components_page: AsyncController<ComponentsPage>,
game_diff: Option<VersionDiff>, game_diff: Option<VersionDiff>,
unity_player_patch: Option<UnityPlayerPatch>, player_patch: Option<PlayerPatch>,
xlua_patch: Option<XluaPatch>,
style: LauncherStyle, style: LauncherStyle,
@ -127,11 +126,7 @@ pub enum GeneralAppMsg {
/// Supposed to be called automatically on app's run when the latest UnityPlayer patch version /// Supposed to be called automatically on app's run when the latest UnityPlayer patch version
/// was retrieved from remote repos /// was retrieved from remote repos
SetUnityPlayerPatch(Option<UnityPlayerPatch>), SetPlayerPatch(Option<PlayerPatch>),
/// Supposed to be called automatically on app's run when the latest xlua patch version
/// was retrieved from remote repos
SetXluaPatch(Option<XluaPatch>),
// If one ever wish to change it to accept VoiceLocale // If one ever wish to change it to accept VoiceLocale
// I'd recommend to use clone!(@strong self.locale as locale => move |_| { .. }) // I'd recommend to use clone!(@strong self.locale as locale => move |_| { .. })
@ -441,7 +436,7 @@ impl SimpleAsyncComponent for GeneralApp {
add_suffix = &gtk::Label { add_suffix = &gtk::Label {
#[watch] #[watch]
set_text: &match model.unity_player_patch.as_ref() { set_text: &match model.player_patch.as_ref() {
Some(patch) => match patch.status() { Some(patch) => match patch.status() {
PatchStatus::NotAvailable => tr("patch-not-available"), PatchStatus::NotAvailable => tr("patch-not-available"),
PatchStatus::Outdated { current, .. } => tr_args("patch-outdated", [("current", current.to_string().into())]), PatchStatus::Outdated { current, .. } => tr_args("patch-outdated", [("current", current.to_string().into())]),
@ -454,7 +449,7 @@ impl SimpleAsyncComponent for GeneralApp {
}, },
#[watch] #[watch]
set_css_classes: match model.unity_player_patch.as_ref() { set_css_classes: match model.player_patch.as_ref() {
Some(patch) => match patch.status() { Some(patch) => match patch.status() {
PatchStatus::NotAvailable => &["error"], PatchStatus::NotAvailable => &["error"],
PatchStatus::Outdated { .. } | PatchStatus::Outdated { .. } |
@ -466,7 +461,7 @@ impl SimpleAsyncComponent for GeneralApp {
Err(_) => CONFIG.game.path.for_edition(CONFIG.launcher.edition).to_path_buf(), Err(_) => CONFIG.game.path.for_edition(CONFIG.launcher.edition).to_path_buf(),
}; };
if let Ok(true) = model.unity_player_patch.as_ref().unwrap_unchecked().is_applied(path) { if let Ok(true) = model.player_patch.as_ref().unwrap_unchecked().is_applied(path) {
&["success"] &["success"]
} else { } else {
&["warning"] &["warning"]
@ -478,7 +473,7 @@ impl SimpleAsyncComponent for GeneralApp {
}, },
#[watch] #[watch]
set_tooltip_text: Some(&match model.unity_player_patch.as_ref() { set_tooltip_text: Some(&match model.player_patch.as_ref() {
Some(patch) => match patch.status() { Some(patch) => match patch.status() {
PatchStatus::NotAvailable => tr("patch-not-available-tooltip"), PatchStatus::NotAvailable => tr("patch-not-available-tooltip"),
PatchStatus::Outdated { current, latest, .. } => tr_args("patch-outdated-tooltip", [ PatchStatus::Outdated { current, latest, .. } => tr_args("patch-outdated-tooltip", [
@ -493,78 +488,7 @@ impl SimpleAsyncComponent for GeneralApp {
Err(_) => CONFIG.game.path.for_edition(CONFIG.launcher.edition).to_path_buf(), Err(_) => CONFIG.game.path.for_edition(CONFIG.launcher.edition).to_path_buf(),
}; };
if let Ok(true) = model.unity_player_patch.as_ref().unwrap_unchecked().is_applied(path) { if let Ok(true) = model.player_patch.as_ref().unwrap_unchecked().is_applied(path) {
String::new()
} else {
tr("patch-not-applied-tooltip")
}
}
}
None => String::new()
})
}
},
adw::ActionRow {
set_title: &tr("xlua-patch-version"),
set_subtitle: &tr("xlua-patch-version-description"),
add_suffix = &gtk::Label {
#[watch]
set_text: &match model.xlua_patch.as_ref() {
Some(patch) => match patch.status() {
PatchStatus::NotAvailable => tr("patch-not-available"),
PatchStatus::Outdated { current, .. } => tr_args("patch-outdated", [("current", current.to_string().into())]),
PatchStatus::Preparation { .. } => tr("patch-preparation"),
PatchStatus::Testing { version, .. } |
PatchStatus::Available { version, .. } => version.to_string()
}
None => String::from("?")
},
#[watch]
set_css_classes: match model.xlua_patch.as_ref() {
Some(patch) => match patch.status() {
PatchStatus::NotAvailable => &["error"],
PatchStatus::Outdated { .. } |
PatchStatus::Preparation { .. } |
PatchStatus::Testing { .. } => &["warning"],
PatchStatus::Available { .. } => unsafe {
let path = match Config::get() {
Ok(config) => config.game.path.for_edition(config.launcher.edition).to_path_buf(),
Err(_) => CONFIG.game.path.for_edition(CONFIG.launcher.edition).to_path_buf(),
};
if let Ok(true) = model.xlua_patch.as_ref().unwrap_unchecked().is_applied(path) {
&["success"]
} else {
&["warning"]
}
}
}
None => &[]
},
#[watch]
set_tooltip_text: Some(&match model.xlua_patch.as_ref() {
Some(patch) => match patch.status() {
PatchStatus::NotAvailable => tr("patch-not-available-tooltip"),
PatchStatus::Outdated { current, latest, .. } => tr_args("patch-outdated-tooltip", [
("current", current.to_string().into()),
("latest", latest.to_string().into())
]),
PatchStatus::Preparation { .. } => tr("patch-preparation-tooltip"),
PatchStatus::Testing { .. } => tr("patch-testing-tooltip"),
PatchStatus::Available { .. } => unsafe {
let path = match Config::get() {
Ok(config) => config.game.path.for_edition(config.launcher.edition).to_path_buf(),
Err(_) => CONFIG.game.path.for_edition(CONFIG.launcher.edition).to_path_buf(),
};
if let Ok(true) = model.xlua_patch.as_ref().unwrap_unchecked().is_applied(path) {
String::new() String::new()
} else { } else {
tr("patch-not-applied-tooltip") tr("patch-not-applied-tooltip")
@ -586,13 +510,13 @@ impl SimpleAsyncComponent for GeneralApp {
add_suffix = &gtk::Switch { add_suffix = &gtk::Switch {
set_valign: gtk::Align::Center, set_valign: gtk::Align::Center,
set_state: CONFIG.patch.apply_main, set_state: CONFIG.patch.apply,
connect_state_notify[sender] => move |switch| { connect_state_notify[sender] => move |switch| {
if is_ready() { if is_ready() {
#[allow(unused_must_use)] #[allow(unused_must_use)]
if let Ok(mut config) = Config::get() { if let Ok(mut config) = Config::get() {
config.patch.apply_main = switch.state(); config.patch.apply = switch.state();
Config::update(config); Config::update(config);
@ -604,18 +528,19 @@ impl SimpleAsyncComponent for GeneralApp {
}, },
adw::ActionRow { adw::ActionRow {
set_title: &tr("apply-xlua-patch"), set_title: "Disable mhypbase", // TODO: add localization
set_subtitle: "Experimental. If enabled, launcher will disable mhypbase.dll during the main patch applying, which is currently an equivalent to the xlua patch. Improves performance on low-end PCs",
add_suffix = &gtk::Switch { add_suffix = &gtk::Switch {
set_valign: gtk::Align::Center, set_valign: gtk::Align::Center,
set_state: CONFIG.patch.apply_xlua, set_state: CONFIG.patch.disable_mhypbase,
connect_state_notify[sender] => move |switch| { connect_state_notify[sender] => move |switch| {
if is_ready() { if is_ready() {
#[allow(unused_must_use)] #[allow(unused_must_use)]
if let Ok(mut config) = Config::get() { if let Ok(mut config) = Config::get() {
config.patch.apply_xlua = switch.state(); config.patch.disable_mhypbase = switch.state();
Config::update(config); Config::update(config);
@ -747,8 +672,7 @@ impl SimpleAsyncComponent for GeneralApp {
.forward(sender.input_sender(), std::convert::identity), .forward(sender.input_sender(), std::convert::identity),
game_diff: None, game_diff: None,
unity_player_patch: None, player_patch: None,
xlua_patch: None,
style: CONFIG.launcher.style, style: CONFIG.launcher.style,
@ -778,12 +702,8 @@ impl SimpleAsyncComponent for GeneralApp {
self.game_diff = diff; self.game_diff = diff;
} }
GeneralAppMsg::SetUnityPlayerPatch(patch) => { GeneralAppMsg::SetPlayerPatch(patch) => {
self.unity_player_patch = patch; self.player_patch = patch;
}
GeneralAppMsg::SetXluaPatch(patch) => {
self.xlua_patch = patch;
} }
#[allow(unused_must_use)] #[allow(unused_must_use)]

View file

@ -31,11 +31,7 @@ pub enum PreferencesAppMsg {
/// Supposed to be called automatically on app's run when the latest UnityPlayer patch version /// Supposed to be called automatically on app's run when the latest UnityPlayer patch version
/// was retrieved from remote repos /// was retrieved from remote repos
SetUnityPlayerPatch(Option<UnityPlayerPatch>), SetPlayerPatch(Option<PlayerPatch>),
/// Supposed to be called automatically on app's run when the latest xlua patch version
/// was retrieved from remote repos
SetXluaPatch(Option<XluaPatch>),
SetLauncherStyle(LauncherStyle), SetLauncherStyle(LauncherStyle),
@ -124,13 +120,8 @@ impl SimpleAsyncComponent for PreferencesApp {
} }
#[allow(unused_must_use)] #[allow(unused_must_use)]
PreferencesAppMsg::SetUnityPlayerPatch(patch) => { PreferencesAppMsg::SetPlayerPatch(patch) => {
self.general.sender().send(GeneralAppMsg::SetUnityPlayerPatch(patch)); self.general.sender().send(GeneralAppMsg::SetPlayerPatch(patch));
}
#[allow(unused_must_use)]
PreferencesAppMsg::SetXluaPatch(patch) => {
self.general.sender().send(GeneralAppMsg::SetXluaPatch(patch));
} }
#[allow(unused_must_use)] #[allow(unused_must_use)]
@ -142,7 +133,6 @@ impl SimpleAsyncComponent for PreferencesApp {
PreferencesAppMsg::UpdateLauncherState => { PreferencesAppMsg::UpdateLauncherState => {
sender.output(Self::Output::UpdateLauncherState { sender.output(Self::Output::UpdateLauncherState {
perform_on_download_needed: false, perform_on_download_needed: false,
apply_patch_if_needed: false,
show_status_page: false show_status_page: false
}); });
} }