mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2024-11-24 22:06:18 +03:00
feat: replaced xlua patch by "disable mhypbase" option
This commit is contained in:
parent
a1962a5267
commit
d00dee3ec0
13 changed files with 71 additions and 209 deletions
|
@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
### Changed
|
||||
|
||||
- Replaced xlua patch by "disable mhypbase" option
|
||||
|
||||
## [3.7.2] - 14.06.2023
|
||||
|
||||
### Fixed
|
||||
|
|
8
Cargo.lock
generated
8
Cargo.lock
generated
|
@ -48,8 +48,8 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "anime-game-core"
|
||||
version = "1.12.6"
|
||||
source = "git+https://github.com/an-anime-team/anime-game-core?tag=1.12.6#704c7fb4741fa1c90596d5862f963653cd0ddbbd"
|
||||
version = "1.13.0"
|
||||
source = "git+https://github.com/an-anime-team/anime-game-core?tag=1.13.0#440dca2cca2e5109468751033c566ab0777324e2"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bzip2",
|
||||
|
@ -96,8 +96,8 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "anime-launcher-sdk"
|
||||
version = "1.7.8"
|
||||
source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=1.7.8#e46f42674d9c9d7923759cbd01f41c86ea61ce91"
|
||||
version = "1.8.0"
|
||||
source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=1.8.0#01486e00a49c1ee7c78eaf81290136ae3ba69520"
|
||||
dependencies = [
|
||||
"anime-game-core",
|
||||
"anyhow",
|
||||
|
|
|
@ -17,7 +17,7 @@ glib-build-tools = "0.17"
|
|||
|
||||
[dependencies.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"]
|
||||
|
||||
# path = "../anime-launcher-sdk" # ! for dev purposes only
|
||||
|
|
|
@ -197,8 +197,7 @@ fn main() {
|
|||
}
|
||||
|
||||
LauncherState::PredownloadAvailable { .. } |
|
||||
LauncherState::UnityPlayerPatchAvailable(UnityPlayerPatch { status: PatchStatus::NotAvailable, .. }) |
|
||||
LauncherState::XluaPatchAvailable(XluaPatch { status: PatchStatus::NotAvailable, .. }) => {
|
||||
LauncherState::PlayerPatchAvailable { patch: PlayerPatch { status: PatchStatus::NotAvailable, .. }, .. } => {
|
||||
if just_run_game {
|
||||
anime_launcher_sdk::genshin::game::run().expect("Failed to run the game");
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::i18n::*;
|
|||
|
||||
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() {
|
||||
PatchStatus::NotAvailable |
|
||||
PatchStatus::Outdated { .. } |
|
||||
|
@ -18,8 +18,6 @@ pub fn apply_patch<T: PatchExt + Send + Sync + 'static>(sender: ComponentSender<
|
|||
let config = Config::get().unwrap();
|
||||
|
||||
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) {
|
||||
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"),
|
||||
description: Some(err.to_string())
|
||||
});
|
||||
}
|
||||
|
||||
// Don't try to apply the patch after state updating
|
||||
// because we just failed to do it
|
||||
apply_patch_if_needed = false;
|
||||
else if rename_mhypbase {
|
||||
let game_folder = config.game.path.for_edition(patch.edition);
|
||||
|
||||
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::UpdateLauncherState {
|
||||
perform_on_download_needed: false,
|
||||
apply_patch_if_needed,
|
||||
show_status_page: true
|
||||
});
|
||||
});
|
||||
|
|
|
@ -35,7 +35,6 @@ pub fn create_prefix(sender: ComponentSender<App>) {
|
|||
sender.input(AppMsg::DisableButtons(false));
|
||||
sender.input(AppMsg::UpdateLauncherState {
|
||||
perform_on_download_needed: false,
|
||||
apply_patch_if_needed: false,
|
||||
show_status_page: true
|
||||
});
|
||||
});
|
||||
|
|
|
@ -68,7 +68,6 @@ pub fn download_diff(sender: ComponentSender<App>, progress_bar_input: Sender<Pr
|
|||
sender.input(AppMsg::SetDownloading(false));
|
||||
sender.input(AppMsg::UpdateLauncherState {
|
||||
perform_on_download_needed,
|
||||
apply_patch_if_needed: false,
|
||||
show_status_page: false
|
||||
});
|
||||
});
|
||||
|
|
|
@ -26,7 +26,6 @@ pub fn download_wine(sender: ComponentSender<App>, progress_bar_input: Sender<Pr
|
|||
|
||||
sender.input(AppMsg::UpdateLauncherState {
|
||||
perform_on_download_needed: false,
|
||||
apply_patch_if_needed: false,
|
||||
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::UpdateLauncherState {
|
||||
perform_on_download_needed: false,
|
||||
apply_patch_if_needed: false,
|
||||
show_status_page: true
|
||||
});
|
||||
}));
|
||||
|
|
|
@ -19,7 +19,6 @@ pub fn migrate_folder(sender: ComponentSender<App>, from: PathBuf, to: PathBuf,
|
|||
sender.input(AppMsg::DisableButtons(false));
|
||||
sender.input(AppMsg::UpdateLauncherState {
|
||||
perform_on_download_needed: false,
|
||||
apply_patch_if_needed: false,
|
||||
show_status_page: true
|
||||
});
|
||||
});
|
||||
|
|
|
@ -69,9 +69,6 @@ pub enum AppMsg {
|
|||
/// Needed for chained executions (e.g. update one voice after another)
|
||||
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_page: bool
|
||||
},
|
||||
|
@ -82,11 +79,7 @@ pub enum AppMsg {
|
|||
|
||||
/// Supposed to be called automatically on app's run when the latest UnityPlayer patch version
|
||||
/// was retrieved from remote repos
|
||||
SetUnityPlayerPatch(Option<UnityPlayerPatch>),
|
||||
|
||||
/// Supposed to be called automatically on app's run when the latest xlua patch version
|
||||
/// was retrieved from remote repos
|
||||
SetXluaPatch(Option<XluaPatch>),
|
||||
SetPlayerPatch(Option<PlayerPatch>),
|
||||
|
||||
/// Supposed to be called automatically on app's run when the launcher state was chosen
|
||||
SetLauncherState(Option<LauncherState>),
|
||||
|
@ -392,8 +385,7 @@ impl SimpleComponent for App {
|
|||
Some(LauncherState::VoiceUpdateAvailable(_)) |
|
||||
Some(LauncherState::VoiceNotInstalled(_)) => "document-save-symbolic",
|
||||
|
||||
Some(LauncherState::UnityPlayerPatchAvailable(UnityPlayerPatch { status, .. })) |
|
||||
Some(LauncherState::XluaPatchAvailable(XluaPatch { status, .. })) => match status {
|
||||
Some(LauncherState::PlayerPatchAvailable { patch: PlayerPatch { status, .. }, .. }) => match status {
|
||||
PatchStatus::NotAvailable |
|
||||
PatchStatus::Outdated { .. } |
|
||||
PatchStatus::Preparation { .. } => "window-close-symbolic",
|
||||
|
@ -413,9 +405,7 @@ impl SimpleComponent for App {
|
|||
Some(LauncherState::PredownloadAvailable { .. }) => tr("launch"),
|
||||
|
||||
Some(LauncherState::FolderMigrationRequired { .. }) => tr("migrate-folders"),
|
||||
|
||||
Some(LauncherState::UnityPlayerPatchAvailable(_)) |
|
||||
Some(LauncherState::XluaPatchAvailable(_)) => tr("apply-patch"),
|
||||
Some(LauncherState::PlayerPatchAvailable { .. }) => tr("apply-patch"),
|
||||
|
||||
Some(LauncherState::WineNotInstalled) => tr("download-wine"),
|
||||
Some(LauncherState::PrefixNotExists) => tr("create-prefix"),
|
||||
|
@ -453,8 +443,7 @@ impl SimpleComponent for App {
|
|||
Some(LauncherState::GameOutdated { .. }) |
|
||||
Some(LauncherState::VoiceOutdated(_)) => false,
|
||||
|
||||
Some(LauncherState::UnityPlayerPatchAvailable(UnityPlayerPatch { status, .. })) |
|
||||
Some(LauncherState::XluaPatchAvailable(XluaPatch { status, .. })) => match status {
|
||||
Some(LauncherState::PlayerPatchAvailable { patch: PlayerPatch { status, .. }, .. }) => match status {
|
||||
PatchStatus::NotAvailable |
|
||||
PatchStatus::Outdated { .. } |
|
||||
PatchStatus::Preparation { .. } => false,
|
||||
|
@ -473,8 +462,7 @@ impl SimpleComponent for App {
|
|||
Some(LauncherState::GameOutdated { .. }) |
|
||||
Some(LauncherState::VoiceOutdated(_)) => &["warning", "pill"],
|
||||
|
||||
Some(LauncherState::UnityPlayerPatchAvailable(UnityPlayerPatch { status, .. })) |
|
||||
Some(LauncherState::XluaPatchAvailable(XluaPatch { status, .. })) => match status {
|
||||
Some(LauncherState::PlayerPatchAvailable { patch: PlayerPatch { status, .. }, .. }) => match status {
|
||||
PatchStatus::NotAvailable |
|
||||
PatchStatus::Outdated { .. } |
|
||||
PatchStatus::Preparation { .. } => &["error", "pill"],
|
||||
|
@ -495,8 +483,7 @@ impl SimpleComponent for App {
|
|||
|
||||
Some(LauncherState::FolderMigrationRequired { .. }) => tr("migrate-folders-tooltip"),
|
||||
|
||||
Some(LauncherState::UnityPlayerPatchAvailable(UnityPlayerPatch { status, .. })) |
|
||||
Some(LauncherState::XluaPatchAvailable(XluaPatch { status, .. })) => match status {
|
||||
Some(LauncherState::PlayerPatchAvailable { patch: PlayerPatch { status, .. }, .. }) => match status {
|
||||
PatchStatus::NotAvailable => tr("main-window--patch-unavailable-tooltip"),
|
||||
|
||||
PatchStatus::Outdated { .. } |
|
||||
|
@ -831,27 +818,11 @@ impl SimpleComponent for App {
|
|||
}
|
||||
|
||||
// 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),
|
||||
|
||||
Err(err) => {
|
||||
tracing::error!("Failed to fetch unity 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}");
|
||||
tracing::error!("Failed to fetch player patch info: {err}");
|
||||
|
||||
sender.input(AppMsg::Toast {
|
||||
title: tr("patch-info-fetching-error"),
|
||||
|
@ -893,7 +864,6 @@ impl SimpleComponent for App {
|
|||
// Update launcher state
|
||||
sender.input(AppMsg::UpdateLauncherState {
|
||||
perform_on_download_needed: false,
|
||||
apply_patch_if_needed: false,
|
||||
show_status_page: true
|
||||
});
|
||||
|
||||
|
@ -913,7 +883,7 @@ impl SimpleComponent for App {
|
|||
|
||||
match msg {
|
||||
// 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 {
|
||||
sender.input(AppMsg::SetLoadingStatus(Some(Some(tr("loading-launcher-state")))));
|
||||
} else {
|
||||
|
@ -968,11 +938,6 @@ impl SimpleComponent for App {
|
|||
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)]
|
||||
AppMsg::SetUnityPlayerPatch(patch) => unsafe {
|
||||
PREFERENCES_WINDOW.as_ref().unwrap_unchecked().sender().send(PreferencesAppMsg::SetUnityPlayerPatch(patch));
|
||||
}
|
||||
|
||||
#[allow(unused_must_use)]
|
||||
AppMsg::SetXluaPatch(patch) => unsafe {
|
||||
PREFERENCES_WINDOW.as_ref().unwrap_unchecked().sender().send(PreferencesAppMsg::SetXluaPatch(patch));
|
||||
AppMsg::SetPlayerPatch(patch) => unsafe {
|
||||
PREFERENCES_WINDOW.as_ref().unwrap_unchecked().sender().send(PreferencesAppMsg::SetPlayerPatch(patch));
|
||||
}
|
||||
|
||||
AppMsg::SetLauncherState(state) => {
|
||||
|
@ -1055,7 +1015,6 @@ impl SimpleComponent for App {
|
|||
sender.input(AppMsg::SetDownloading(false));
|
||||
sender.input(AppMsg::UpdateLauncherState {
|
||||
perform_on_download_needed: false,
|
||||
apply_patch_if_needed: false,
|
||||
show_status_page: true
|
||||
});
|
||||
});
|
||||
|
@ -1064,20 +1023,18 @@ impl SimpleComponent for App {
|
|||
|
||||
AppMsg::PerformAction => unsafe {
|
||||
match self.state.as_ref().unwrap_unchecked() {
|
||||
LauncherState::UnityPlayerPatchAvailable(UnityPlayerPatch { status: PatchStatus::NotAvailable, .. }) |
|
||||
LauncherState::XluaPatchAvailable(XluaPatch { status: PatchStatus::NotAvailable, .. }) |
|
||||
LauncherState::PlayerPatchAvailable { patch: PlayerPatch { status: PatchStatus::NotAvailable, .. }, .. } |
|
||||
LauncherState::PredownloadAvailable { .. } |
|
||||
LauncherState::Launch => launch::launch(sender),
|
||||
|
||||
LauncherState::FolderMigrationRequired { from, to, cleanup_folder } =>
|
||||
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::XluaPatchAvailable(patch) => apply_patch::apply_patch(sender, patch.to_owned()),
|
||||
LauncherState::PlayerPatchAvailable { patch, disable_mhypbase } =>
|
||||
apply_patch::apply_patch(sender, patch.to_owned(), *disable_mhypbase),
|
||||
|
||||
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::VoiceNotInstalled(diff) |
|
||||
|
|
|
@ -108,27 +108,17 @@ pub fn repair_game(sender: ComponentSender<App>, progress_bar_input: Sender<Prog
|
|||
|
||||
// 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))
|
||||
.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)
|
||||
.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 {
|
||||
fn should_ignore(path: &Path, player_patch: bool, disable_mhypbase: bool) -> bool {
|
||||
// Files managed by launch.bat file
|
||||
for part in ["crashreport.exe", "upload_crash.exe"] {
|
||||
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 xlua_patch {
|
||||
for part in ["xlua.dll", "mhypbase.dll"] {
|
||||
if path.ends_with(part) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// If mhypbase should be disabled
|
||||
if disable_mhypbase && path.ends_with("mhypbase.dll") {
|
||||
return true;
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
if let Err(err) = file.repair(&game_path) {
|
||||
|
|
|
@ -111,8 +111,7 @@ pub struct GeneralApp {
|
|||
components_page: AsyncController<ComponentsPage>,
|
||||
|
||||
game_diff: Option<VersionDiff>,
|
||||
unity_player_patch: Option<UnityPlayerPatch>,
|
||||
xlua_patch: Option<XluaPatch>,
|
||||
player_patch: Option<PlayerPatch>,
|
||||
|
||||
style: LauncherStyle,
|
||||
|
||||
|
@ -127,11 +126,7 @@ pub enum GeneralAppMsg {
|
|||
|
||||
/// Supposed to be called automatically on app's run when the latest UnityPlayer patch version
|
||||
/// was retrieved from remote repos
|
||||
SetUnityPlayerPatch(Option<UnityPlayerPatch>),
|
||||
|
||||
/// Supposed to be called automatically on app's run when the latest xlua patch version
|
||||
/// was retrieved from remote repos
|
||||
SetXluaPatch(Option<XluaPatch>),
|
||||
SetPlayerPatch(Option<PlayerPatch>),
|
||||
|
||||
// If one ever wish to change it to accept VoiceLocale
|
||||
// I'd recommend to use clone!(@strong self.locale as locale => move |_| { .. })
|
||||
|
@ -441,7 +436,7 @@ impl SimpleAsyncComponent for GeneralApp {
|
|||
|
||||
add_suffix = >k::Label {
|
||||
#[watch]
|
||||
set_text: &match model.unity_player_patch.as_ref() {
|
||||
set_text: &match model.player_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())]),
|
||||
|
@ -454,7 +449,7 @@ impl SimpleAsyncComponent for GeneralApp {
|
|||
},
|
||||
|
||||
#[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() {
|
||||
PatchStatus::NotAvailable => &["error"],
|
||||
PatchStatus::Outdated { .. } |
|
||||
|
@ -466,7 +461,7 @@ impl SimpleAsyncComponent for GeneralApp {
|
|||
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"]
|
||||
} else {
|
||||
&["warning"]
|
||||
|
@ -478,7 +473,7 @@ impl SimpleAsyncComponent for GeneralApp {
|
|||
},
|
||||
|
||||
#[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() {
|
||||
PatchStatus::NotAvailable => tr("patch-not-available-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(),
|
||||
};
|
||||
|
||||
if let Ok(true) = model.unity_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 = >k::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) {
|
||||
if let Ok(true) = model.player_patch.as_ref().unwrap_unchecked().is_applied(path) {
|
||||
String::new()
|
||||
} else {
|
||||
tr("patch-not-applied-tooltip")
|
||||
|
@ -586,13 +510,13 @@ impl SimpleAsyncComponent for GeneralApp {
|
|||
add_suffix = >k::Switch {
|
||||
set_valign: gtk::Align::Center,
|
||||
|
||||
set_state: CONFIG.patch.apply_main,
|
||||
set_state: CONFIG.patch.apply,
|
||||
|
||||
connect_state_notify[sender] => move |switch| {
|
||||
if is_ready() {
|
||||
#[allow(unused_must_use)]
|
||||
if let Ok(mut config) = Config::get() {
|
||||
config.patch.apply_main = switch.state();
|
||||
config.patch.apply = switch.state();
|
||||
|
||||
Config::update(config);
|
||||
|
||||
|
@ -604,18 +528,19 @@ impl SimpleAsyncComponent for GeneralApp {
|
|||
},
|
||||
|
||||
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 = >k::Switch {
|
||||
set_valign: gtk::Align::Center,
|
||||
|
||||
set_state: CONFIG.patch.apply_xlua,
|
||||
set_state: CONFIG.patch.disable_mhypbase,
|
||||
|
||||
connect_state_notify[sender] => move |switch| {
|
||||
if is_ready() {
|
||||
#[allow(unused_must_use)]
|
||||
if let Ok(mut config) = Config::get() {
|
||||
config.patch.apply_xlua = switch.state();
|
||||
config.patch.disable_mhypbase = switch.state();
|
||||
|
||||
Config::update(config);
|
||||
|
||||
|
@ -747,8 +672,7 @@ impl SimpleAsyncComponent for GeneralApp {
|
|||
.forward(sender.input_sender(), std::convert::identity),
|
||||
|
||||
game_diff: None,
|
||||
unity_player_patch: None,
|
||||
xlua_patch: None,
|
||||
player_patch: None,
|
||||
|
||||
style: CONFIG.launcher.style,
|
||||
|
||||
|
@ -778,12 +702,8 @@ impl SimpleAsyncComponent for GeneralApp {
|
|||
self.game_diff = diff;
|
||||
}
|
||||
|
||||
GeneralAppMsg::SetUnityPlayerPatch(patch) => {
|
||||
self.unity_player_patch = patch;
|
||||
}
|
||||
|
||||
GeneralAppMsg::SetXluaPatch(patch) => {
|
||||
self.xlua_patch = patch;
|
||||
GeneralAppMsg::SetPlayerPatch(patch) => {
|
||||
self.player_patch = patch;
|
||||
}
|
||||
|
||||
#[allow(unused_must_use)]
|
||||
|
|
|
@ -31,11 +31,7 @@ pub enum PreferencesAppMsg {
|
|||
|
||||
/// Supposed to be called automatically on app's run when the latest UnityPlayer patch version
|
||||
/// was retrieved from remote repos
|
||||
SetUnityPlayerPatch(Option<UnityPlayerPatch>),
|
||||
|
||||
/// Supposed to be called automatically on app's run when the latest xlua patch version
|
||||
/// was retrieved from remote repos
|
||||
SetXluaPatch(Option<XluaPatch>),
|
||||
SetPlayerPatch(Option<PlayerPatch>),
|
||||
|
||||
SetLauncherStyle(LauncherStyle),
|
||||
|
||||
|
@ -124,13 +120,8 @@ impl SimpleAsyncComponent for PreferencesApp {
|
|||
}
|
||||
|
||||
#[allow(unused_must_use)]
|
||||
PreferencesAppMsg::SetUnityPlayerPatch(patch) => {
|
||||
self.general.sender().send(GeneralAppMsg::SetUnityPlayerPatch(patch));
|
||||
}
|
||||
|
||||
#[allow(unused_must_use)]
|
||||
PreferencesAppMsg::SetXluaPatch(patch) => {
|
||||
self.general.sender().send(GeneralAppMsg::SetXluaPatch(patch));
|
||||
PreferencesAppMsg::SetPlayerPatch(patch) => {
|
||||
self.general.sender().send(GeneralAppMsg::SetPlayerPatch(patch));
|
||||
}
|
||||
|
||||
#[allow(unused_must_use)]
|
||||
|
@ -142,7 +133,6 @@ impl SimpleAsyncComponent for PreferencesApp {
|
|||
PreferencesAppMsg::UpdateLauncherState => {
|
||||
sender.output(Self::Output::UpdateLauncherState {
|
||||
perform_on_download_needed: false,
|
||||
apply_patch_if_needed: false,
|
||||
show_status_page: false
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue