feat(star-rail): improved update pre-download state implementation

This commit is contained in:
Observer KRypt0n_ 2023-07-17 21:34:33 +02:00
parent 2740eae5b5
commit 69ec45d5a4
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
2 changed files with 24 additions and 16 deletions

View file

@ -9,7 +9,7 @@ edition = "2021"
[dependencies.anime-game-core]
git = "https://github.com/an-anime-team/anime-game-core"
tag = "1.13.2"
tag = "1.13.3"
features = ["all"]
# path = "../anime-game-core" # ! for dev purposes only

View file

@ -25,7 +25,10 @@ pub enum LauncherState {
PrefixNotExists,
/// Always contains `VersionDiff::Predownload`
PredownloadAvailable(VersionDiff),
PredownloadAvailable {
diff: VersionDiff,
patch: JadeitePatchStatusVariant
},
// Always contains `VersionDiff::Diff`
GameUpdateAvailable(VersionDiff),
@ -101,22 +104,27 @@ impl LauncherState {
return Ok(Self::TelemetryNotDisabled);
}
match jadeite::get_metadata()?.hsr.for_edition(params.game_edition).get_status(version) {
JadeitePatchStatusVariant::Verified => {
// Check if update predownload available
if let VersionDiff::Predownload { .. } = diff {
Ok(Self::PredownloadAvailable(diff))
}
// Request current patch status from the metadata file
let patch = jadeite::get_metadata()?.games.hsr
.for_edition(params.game_edition)
.get_status(version);
// Otherwise we can launch the game
else {
Ok(Self::Launch)
}
// Check if update predownload available
if let VersionDiff::Predownload { .. } = diff {
Ok(Self::PredownloadAvailable {
diff,
patch
})
}
// Otherwise we can launch the game or say that the patch is unstable
else {
match patch {
JadeitePatchStatusVariant::Verified => Ok(Self::Launch),
JadeitePatchStatusVariant::Unverified => Ok(Self::PatchNotVerified),
JadeitePatchStatusVariant::Broken => Ok(Self::PatchBroken),
JadeitePatchStatusVariant::Unsafe => Ok(Self::PatchUnsafe)
}
JadeitePatchStatusVariant::Unverified => Ok(Self::PatchNotVerified),
JadeitePatchStatusVariant::Broken => Ok(Self::PatchBroken),
JadeitePatchStatusVariant::Unsafe => Ok(Self::PatchUnsafe)
}
}