feat(honkai): added mfplat patch

This commit is contained in:
Observer KRypt0n_ 2023-04-17 00:52:35 +02:00
parent b1255ff965
commit fdef611ea9
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
4 changed files with 20 additions and 6 deletions

View file

@ -1,6 +1,6 @@
[package]
name = "anime-launcher-sdk"
version = "1.0.2"
version = "1.0.3"
authors = ["Nikita Podvirnyy <suimin.tu.mu.ga.mi@gmail.com>"]
license = "GPL-3.0"
readme = "README.md"
@ -8,7 +8,7 @@ edition = "2021"
[dependencies.anime-game-core]
git = "https://github.com/an-anime-team/anime-game-core"
tag = "1.7.0"
tag = "1.7.1"
features = ["all"]
# path = "../anime-game-core" # ! for dev purposes only

View file

@ -9,6 +9,7 @@ use crate::honkai::consts::launcher_dir;
pub struct Patch {
pub path: PathBuf,
pub servers: Vec<String>,
pub apply_mfplat: bool,
pub root: bool
}
@ -24,6 +25,8 @@ impl Default for Patch {
String::from("https://notabug.org/mkrsym1/dusk")
],
apply_mfplat: true,
// Disable root requirement for patching if we're running launcher in flatpak
root: !PathBuf::from("/.flatpak-info").exists()
}
@ -61,6 +64,11 @@ impl From<&JsonValue> for Patch {
None => default.servers
},
apply_mfplat: match value.get("apply_mfplat") {
Some(value) => value.as_bool().unwrap_or(default.apply_mfplat),
None => default.apply_mfplat
},
root: match value.get("root") {
Some(value) => value.as_bool().unwrap_or(default.root),
None => default.root

View file

@ -71,8 +71,6 @@ pub fn run() -> anyhow::Result<()> {
bash_command += "gamemoderun ";
}
let wine_build = config.game.wine.builds.join(&wine.name);
let run_command = features.command
.map(|command| replace_keywords(command, &folders))
.unwrap_or(folders.wine.join(wine.files.wine64.unwrap_or(wine.files.wine)).to_string_lossy().to_string());

View file

@ -16,7 +16,8 @@ pub enum LauncherState {
/// Always contains `VersionDiff::Predownload`
PredownloadAvailable(VersionDiff),
PatchAvailable(MainPatch),
MfplatPatchAvailable,
MainPatchAvailable(MainPatch),
#[cfg(feature = "components")]
WineNotInstalled,
@ -47,6 +48,7 @@ pub struct LauncherStateParams<F: Fn(StateUpdating)> {
pub patch_servers: Vec<String>,
pub patch_folder: PathBuf,
pub apply_mfplat: bool,
pub status_updater: F
}
@ -72,6 +74,11 @@ impl LauncherState {
// Check game patch status
(params.status_updater)(StateUpdating::Patch);
// Check if mfplat patch is needed
if params.apply_mfplat && !MfplatPatch::is_applied(&params.wine_prefix)? {
return Ok(Self::MfplatPatchAvailable);
}
let patch = Patch::new(&params.patch_folder);
// Sync local patch folder with remote if needed
@ -88,7 +95,7 @@ impl LauncherState {
let player_patch = patch.main_patch()?;
if !player_patch.is_applied(&params.game_path)? {
return Ok(Self::PatchAvailable(player_patch));
return Ok(Self::MainPatchAvailable(player_patch));
}
// Check if update predownload available
@ -151,6 +158,7 @@ impl LauncherState {
patch_servers: config.patch.servers,
patch_folder: config.patch.path,
apply_mfplat: config.patch.apply_mfplat,
status_updater
})