- added `LauncherState::XluaPatchAvailable`
- added `patch.apply_xlua` flag to config
This commit is contained in:
Observer KRypt0n_ 2023-03-22 20:21:18 +02:00
parent 544bd95233
commit e492ba69a2
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
4 changed files with 40 additions and 23 deletions

View file

@ -1,6 +1,6 @@
[package]
name = "anime-launcher-sdk"
version = "0.5.4"
version = "0.5.5"
authors = ["Nikita Podvirnyy <suimin.tu.mu.ga.mi@gmail.com>"]
license = "GPL-3.0"
readme = "README.md"

@ -1 +1 @@
Subproject commit 160053e6c9b8f55826ba724d5e68e448dad3cd0e
Subproject commit 70725c34c8620686e20099e0c655fe8bd4aebed0

View file

@ -9,6 +9,7 @@ use crate::consts::launcher_dir;
pub struct Patch {
pub path: PathBuf,
pub servers: Vec<String>,
pub apply_xlua: bool,
pub root: bool
}
@ -18,11 +19,14 @@ impl Default for Patch {
Self {
path: launcher_dir.join("patch"),
servers: vec![
"https://notabug.org/Krock/dawn".to_string(),
"https://codespace.gay/Maroxy/dawnin".to_string()
String::from("https://notabug.org/Krock/dawn"),
String::from("https://codespace.gay/Maroxy/dawnin")
],
apply_xlua: false,
// Disable root requirement for patching if we're running launcher in flatpak
root: !Path::new("/.flatpak-info").exists()
}
@ -60,6 +64,11 @@ impl From<&JsonValue> for Patch {
None => default.servers
},
apply_xlua: match value.get("apply_xlua") {
Some(value) => value.as_bool().unwrap_or(default.apply_xlua),
None => default.apply_xlua
},
root: match value.get("root") {
Some(value) => value.as_bool().unwrap_or(default.root),
None => default.root

View file

@ -19,7 +19,8 @@ pub enum LauncherState {
voices: Vec<VersionDiff>
},
MainPatchAvailable(UnityPlayerPatch),
UnityPlayerPatchAvailable(UnityPlayerPatch),
XluaPatchAvailable(XluaPatch),
#[cfg(feature = "components")]
WineNotInstalled,
@ -87,7 +88,7 @@ impl LauncherState {
let game = Game::new(&params.game_path);
let diff = game.try_get_diff()?;
Ok(match diff {
match diff {
VersionDiff::Latest(_) | VersionDiff::Predownload { .. } => {
let mut predownload_voice = Vec::new();
@ -132,32 +133,39 @@ impl LauncherState {
}
// Check UnityPlayer patch
let main_patch = patch.unity_player_patch()?;
let player_patch = patch.unity_player_patch()?;
if main_patch.is_applied(&params.game_path)? {
// TODO: add Xlua patch check
if !player_patch.is_applied(&params.game_path)? {
return Ok(Self::UnityPlayerPatchAvailable(player_patch));
}
if let VersionDiff::Predownload { .. } = diff {
Self::PredownloadAvailable {
game: diff,
voices: predownload_voice
}
}
// Check xlua patch
if params.use_xlua_patch {
let xlua_patch = patch.xlua_patch()?;
else {
Self::Launch
if !xlua_patch.is_applied(&params.game_path)? {
return Ok(Self::XluaPatchAvailable(xlua_patch));
}
}
// Check if update predownload available
if let VersionDiff::Predownload { .. } = diff {
Ok(Self::PredownloadAvailable {
game: diff,
voices: predownload_voice
})
}
// Otherwise we can launch the game
else {
Self::MainPatchAvailable(main_patch)
Ok(Self::Launch)
}
}
VersionDiff::Diff { .. } => Self::GameUpdateAvailable(diff),
VersionDiff::Outdated { .. } => Self::GameOutdated(diff),
VersionDiff::NotInstalled { .. } => Self::GameNotInstalled(diff)
})
VersionDiff::Diff { .. } => Ok(Self::GameUpdateAvailable(diff)),
VersionDiff::Outdated { .. } => Ok(Self::GameOutdated(diff)),
VersionDiff::NotInstalled { .. } => Ok(Self::GameNotInstalled(diff))
}
}
#[cfg(feature = "config")]
@ -214,7 +222,7 @@ impl LauncherState {
patch_servers: config.patch.servers,
patch_folder: config.patch.path,
use_xlua_patch: false, // TODO
use_xlua_patch: config.patch.xlua_patch,
status_updater
})