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`
This commit is contained in:
Observer KRypt0n_ 2022-12-07 11:24:57 +02:00
parent 755a4aeece
commit 9fa5f9e306
7 changed files with 35 additions and 18 deletions

3
Cargo.lock generated
View file

@ -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",

View file

@ -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"] }

@ -1 +1 @@
Subproject commit 73d3644761bef06cfc16e4e4bc4f9b9af3c50139
Subproject commit f6e64a259f438ec34db1e987779f3fa9d700d38c

@ -1 +1 @@
Subproject commit bc15ac9efbb762e9e960badb5bf35655e5d8603b
Subproject commit 00a31d87bbac71133a7080a027e02371b511bdef

@ -1 +1 @@
Subproject commit 72db38b8e868a17037a8f278264772629821a67a
Subproject commit 66d33ab5309335678ba5568561fba66919894e11

View file

@ -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::<InstallerUpdate>(glib::PRIORITY_DEFAULT);
enum UpdaterState {
State(anime_game_core::installer::installer::Update),
Finished
}
let (sender, receiver) = glib::MainContext::channel::<UpdaterState>(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();
});
},

View file

@ -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})")));