From 9fa5f9e306f5b44aa20603e202d1bf777775183f Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Wed, 7 Dec 2022 11:24:57 +0200 Subject: [PATCH] Several changes - updated core library with a few fixes - improved gamer updater. Now it will not start to download next update before the previous one was properly applied (hdiff and so on) Core library changes: - updated `VOICE_PACKAGES_SIZES` - added version prediction based on the `.version` file for voiceovers - fixed redownloading of downloaded files in `Downloader::download_to` --- Cargo.lock | 3 +-- Cargo.toml | 5 ++--- anime-game-core | 2 +- blueprint-compiler | 2 +- components | 2 +- src/ui/main.rs | 37 ++++++++++++++++++++++++++--------- src/ui/preferences/general.rs | 2 +- 7 files changed, 35 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d97765b..0e1faf2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -31,7 +31,7 @@ dependencies = [ [[package]] name = "anime-game-core" -version = "1.2.3" +version = "1.3.0" dependencies = [ "anyhow", "bzip2", @@ -63,7 +63,6 @@ dependencies = [ "lazy_static", "libadwaita", "md5", - "regex", "rfd", "serde", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index d8fddee..4cfc26c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ lto = true opt-level = 3 [build-dependencies] -glib-build-tools = { version = "0.16" } +glib-build-tools = "0.16" [dependencies] gtk = { package = "gtk4", version = "0.5", features = ["v4_8"] } @@ -28,8 +28,7 @@ serde_json = "1.0" dirs = "4.0.0" wait_not_await = "0.2.1" -regex = "1.6.0" lazy_static = "1.4.0" anyhow = "1.0" md5 = "0.7" -cached = { version = "0.40", features = ["proc_macro"]} +cached = { version = "0.40", features = ["proc_macro"] } diff --git a/anime-game-core b/anime-game-core index 73d3644..f6e64a2 160000 --- a/anime-game-core +++ b/anime-game-core @@ -1 +1 @@ -Subproject commit 73d3644761bef06cfc16e4e4bc4f9b9af3c50139 +Subproject commit f6e64a259f438ec34db1e987779f3fa9d700d38c diff --git a/blueprint-compiler b/blueprint-compiler index bc15ac9..00a31d8 160000 --- a/blueprint-compiler +++ b/blueprint-compiler @@ -1 +1 @@ -Subproject commit bc15ac9efbb762e9e960badb5bf35655e5d8603b +Subproject commit 00a31d87bbac71133a7080a027e02371b511bdef diff --git a/components b/components index 72db38b..66d33ab 160000 --- a/components +++ b/components @@ -1 +1 @@ -Subproject commit 72db38b8e868a17037a8f278264772629821a67a +Subproject commit 66d33ab5309335678ba5568561fba66919894e11 diff --git a/src/ui/main.rs b/src/ui/main.rs index e98458b..7b32ffc 100644 --- a/src/ui/main.rs +++ b/src/ui/main.rs @@ -439,7 +439,7 @@ impl App { } } - if config.game.wine.selected == None { + if config.game.wine.selected.is_none() { match WineVersion::latest() { Ok(wine) => { match Installer::new(wine.uri) { @@ -536,7 +536,12 @@ impl App { LauncherState::VoiceNotInstalled(diff) | LauncherState::GameUpdateAvailable(diff) | LauncherState::GameNotInstalled(diff) => { - let (sender, receiver) = glib::MainContext::channel::(glib::PRIORITY_DEFAULT); + enum UpdaterState { + State(anime_game_core::installer::installer::Update), + Finished + } + + let (sender, receiver) = glib::MainContext::channel::(glib::PRIORITY_DEFAULT); let this = this.clone(); let this_copy = this.clone(); @@ -546,16 +551,24 @@ impl App { // Download diff // We need to update components from the main thread receiver.attach(None, move |state| { - match this.widgets.progress_bar.update_from_state(state) { - ProgressUpdateResult::Updated => (), + match state { + UpdaterState::State(state) => { + match this.widgets.progress_bar.update_from_state(state) { + ProgressUpdateResult::Updated => (), - ProgressUpdateResult::Error(msg, err) => { - this.widgets.progress_bar.hide(); + ProgressUpdateResult::Error(msg, err) => { + this.widgets.progress_bar.hide(); - this.toast(msg, err); + this.toast(msg, err); + } + + ProgressUpdateResult::Finished => { + this.widgets.progress_bar.update(1.0, Some("Applying patches...")); + } + } } - ProgressUpdateResult::Finished => { + UpdaterState::Finished => { this.widgets.progress_bar.hide(); let this = this.clone(); @@ -573,6 +586,8 @@ impl App { } } }); + + return glib::Continue(false); } } @@ -581,8 +596,10 @@ impl App { // Download diff in separate thread to not to freeze the main one std::thread::spawn(move || { + let updater_sender = sender.clone(); + let result = diff.install_to_by(config.game.path, config.launcher.temp, move |state| { - sender.send(state).unwrap(); + updater_sender.send(UpdaterState::State(state)).unwrap(); }); if let Err(err) = result { @@ -592,6 +609,8 @@ impl App { String::from("Downloading failed"), err.to_string() )))).unwrap(); } + + sender.send(UpdaterState::Finished).unwrap(); }); }, diff --git a/src/ui/preferences/general.rs b/src/ui/preferences/general.rs index 1157d1a..80657f3 100644 --- a/src/ui/preferences/general.rs +++ b/src/ui/preferences/general.rs @@ -659,7 +659,7 @@ impl App { } Patch::Outdated { current, latest, .. } => { - self.widgets.patch_version.set_label("outdated"); + self.widgets.patch_version.set_label(&format!("outdated ({})", current)); self.widgets.patch_version.set_css_classes(&["warning"]); self.widgets.patch_version.set_tooltip_text(Some(&format!("Patch is outdated ({current} -> {latest})")));