Added initial updates pre-downloading support (from 1.0.3 core)

This commit is contained in:
Observer KRypt0n_ 2022-09-10 22:05:46 +02:00
parent 57c36ae52d
commit 1eedbb52a3
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
6 changed files with 55 additions and 15 deletions

6
Cargo.lock generated
View file

@ -31,7 +31,7 @@ dependencies = [
[[package]]
name = "anime-game-core"
version = "1.0.2"
version = "1.0.3"
dependencies = [
"anyhow",
"bzip2",
@ -157,9 +157,9 @@ dependencies = [
[[package]]
name = "cached"
version = "0.38.0"
version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27e6092f8c7ba6e65a46f6f26d7d7997201d3a6f0e69ff5d2440b930d7c0513a"
checksum = "f3e27085975166ffaacbd04527132e1cf5906fa612991f9b4fea08e787da2961"
dependencies = [
"async-trait",
"async_once",

@ -1 +1 @@
Subproject commit 12541266d567f3459430ba37e12b0d809d12733d
Subproject commit a32856db7dcb66f5d61ceab20e3bf3716b9ed6fa

@ -1 +1 @@
Subproject commit 9f2247a8200add10b7da738c257bd824832fa3c6
Subproject commit e1ad703e01dd77dbe107150a93cdb9934b2b286d

View file

@ -8,6 +8,13 @@ use crate::lib::wine_prefix::WinePrefix;
#[derive(Debug, Clone)]
pub enum LauncherState {
Launch,
/// Always contains `VersionDiff::Predownload`
PredownloadAvailable {
game: VersionDiff,
voices: Vec<VersionDiff>
},
PatchAvailable(Patch),
WineNotInstalled,
@ -59,9 +66,11 @@ impl LauncherState {
let diff = game.try_get_diff()?;
Ok(match diff {
VersionDiff::Latest(_) => {
VersionDiff::Latest(_) | VersionDiff::Predownload { .. } => {
status("Updating voice info...");
let mut predownload_voice = Vec::new();
for voice_package in &config.game.voices {
let mut voice_package = VoicePackage::with_locale(match VoiceLocale::from_str(voice_package) {
Some(locale) => locale,
@ -82,7 +91,9 @@ impl LauncherState {
let diff = voice_package.try_get_diff()?;
match diff {
VersionDiff::Latest(_) => continue,
VersionDiff::Latest(_) => (),
VersionDiff::Predownload { .. } => predownload_voice.push(diff),
VersionDiff::Diff { .. } => return Ok(Self::VoiceUpdateAvailable(diff)),
VersionDiff::Outdated { .. } => return Ok(Self::VoiceOutdated(diff)),
VersionDiff::NotInstalled { .. } => return Ok(Self::VoiceNotInstalled(diff))
@ -94,8 +105,17 @@ impl LauncherState {
let patch = Patch::try_fetch(config.patch.servers.clone(), consts::PATCH_FETCHING_TIMEOUT)?;
if patch.is_applied(&config.game.path)? {
if let VersionDiff::Predownload { .. } = diff {
Self::PredownloadAvailable {
game: diff,
voices: predownload_voice
}
}
else {
Self::Launch
}
}
else {
Self::PatchAvailable(patch)

View file

@ -310,6 +310,7 @@ impl App {
Ok(mut config) => {
match state {
LauncherState::PatchAvailable(Patch::NotAvailable) |
LauncherState::PredownloadAvailable { .. } |
LauncherState::Launch => {
let this = this.clone();
@ -812,6 +813,11 @@ impl App {
self.widgets.launch_game.set_label("Launch");
}
// TODO
LauncherState::PredownloadAvailable { .. } => {
self.widgets.launch_game.set_label("Launch");
}
LauncherState::PatchAvailable(patch) => {
match patch {
Patch::NotAvailable => {

View file

@ -625,19 +625,29 @@ impl App {
match game.try_get_diff()? {
VersionDiff::Latest(version) => {
self.widgets.game_version.set_label(&version.to_string());
},
}
VersionDiff::Predownload { current, latest, .. } => {
self.widgets.game_version.set_label(&current.to_string());
self.widgets.game_version.set_css_classes(&["accent"]);
self.widgets.game_version.set_tooltip_text(Some(&format!("Game update pre-downloading available: {} -> {}", current, latest)));
}
VersionDiff::Diff { current, latest, .. } => {
self.widgets.game_version.set_label(&current.to_string());
self.widgets.game_version.set_css_classes(&["warning"]);
self.widgets.game_version.set_tooltip_text(Some(&format!("Game update available: {} -> {}", current, latest)));
},
}
VersionDiff::Outdated { current, latest } => {
self.widgets.game_version.set_label(&current.to_string());
self.widgets.game_version.set_css_classes(&["error"]);
self.widgets.game_version.set_tooltip_text(Some(&format!("Game is too outdated and can't be updated. Latest version: {latest}")));
},
}
VersionDiff::NotInstalled { .. } => {
self.widgets.game_version.set_label("not installed");
self.widgets.game_version.set_css_classes(&[]);
@ -655,25 +665,29 @@ impl App {
self.widgets.patch_version.set_css_classes(&["error"]);
self.widgets.patch_version.set_tooltip_text(Some("Patch is not available"));
},
}
Patch::Outdated { current, latest, .. } => {
self.widgets.patch_version.set_label("outdated");
self.widgets.patch_version.set_css_classes(&["warning"]);
self.widgets.patch_version.set_tooltip_text(Some(&format!("Patch is outdated ({current} -> {latest})")));
},
}
Patch::Preparation { .. } => {
self.widgets.patch_version.set_label("preparation");
self.widgets.patch_version.set_css_classes(&["warning"]);
self.widgets.patch_version.set_tooltip_text(Some("Patch is in preparation state and will be available later"));
},
}
Patch::Testing { version, .. } => {
self.widgets.patch_version.set_label(&version.to_string());
self.widgets.patch_version.set_css_classes(&["warning"]);
self.widgets.patch_version.set_tooltip_text(Some("Patch is in testing phase"));
},
}
Patch::Available { version, .. } => {
self.widgets.patch_version.set_label(&version.to_string());