diff --git a/Cargo.lock b/Cargo.lock index ba92d25..8bac0b3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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", diff --git a/anime-game-core b/anime-game-core index 1254126..a32856d 160000 --- a/anime-game-core +++ b/anime-game-core @@ -1 +1 @@ -Subproject commit 12541266d567f3459430ba37e12b0d809d12733d +Subproject commit a32856db7dcb66f5d61ceab20e3bf3716b9ed6fa diff --git a/components b/components index 9f2247a..e1ad703 160000 --- a/components +++ b/components @@ -1 +1 @@ -Subproject commit 9f2247a8200add10b7da738c257bd824832fa3c6 +Subproject commit e1ad703e01dd77dbe107150a93cdb9934b2b286d diff --git a/src/lib/launcher/states.rs b/src/lib/launcher/states.rs index 3a23301..7d2e218 100644 --- a/src/lib/launcher/states.rs +++ b/src/lib/launcher/states.rs @@ -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 + }, + 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,7 +105,16 @@ impl LauncherState { let patch = Patch::try_fetch(config.patch.servers.clone(), consts::PATCH_FETCHING_TIMEOUT)?; if patch.is_applied(&config.game.path)? { - Self::Launch + if let VersionDiff::Predownload { .. } = diff { + Self::PredownloadAvailable { + game: diff, + voices: predownload_voice + } + } + + else { + Self::Launch + } } else { diff --git a/src/ui/main.rs b/src/ui/main.rs index 49a6682..e0c93f8 100644 --- a/src/ui/main.rs +++ b/src/ui/main.rs @@ -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 => { diff --git a/src/ui/preferences/general.rs b/src/ui/preferences/general.rs index 0b9e7ff..700abfa 100644 --- a/src/ui/preferences/general.rs +++ b/src/ui/preferences/general.rs @@ -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(¤t.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(¤t.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(¤t.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());