0.5.5
- added `LauncherState::XluaPatchAvailable` - added `patch.apply_xlua` flag to config
This commit is contained in:
parent
544bd95233
commit
e492ba69a2
4 changed files with 40 additions and 23 deletions
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "anime-launcher-sdk"
|
name = "anime-launcher-sdk"
|
||||||
version = "0.5.4"
|
version = "0.5.5"
|
||||||
authors = ["Nikita Podvirnyy <suimin.tu.mu.ga.mi@gmail.com>"]
|
authors = ["Nikita Podvirnyy <suimin.tu.mu.ga.mi@gmail.com>"]
|
||||||
license = "GPL-3.0"
|
license = "GPL-3.0"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 160053e6c9b8f55826ba724d5e68e448dad3cd0e
|
Subproject commit 70725c34c8620686e20099e0c655fe8bd4aebed0
|
|
@ -9,6 +9,7 @@ use crate::consts::launcher_dir;
|
||||||
pub struct Patch {
|
pub struct Patch {
|
||||||
pub path: PathBuf,
|
pub path: PathBuf,
|
||||||
pub servers: Vec<String>,
|
pub servers: Vec<String>,
|
||||||
|
pub apply_xlua: bool,
|
||||||
pub root: bool
|
pub root: bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,11 +19,14 @@ impl Default for Patch {
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
path: launcher_dir.join("patch"),
|
path: launcher_dir.join("patch"),
|
||||||
|
|
||||||
servers: vec![
|
servers: vec![
|
||||||
"https://notabug.org/Krock/dawn".to_string(),
|
String::from("https://notabug.org/Krock/dawn"),
|
||||||
"https://codespace.gay/Maroxy/dawnin".to_string()
|
String::from("https://codespace.gay/Maroxy/dawnin")
|
||||||
],
|
],
|
||||||
|
|
||||||
|
apply_xlua: false,
|
||||||
|
|
||||||
// Disable root requirement for patching if we're running launcher in flatpak
|
// Disable root requirement for patching if we're running launcher in flatpak
|
||||||
root: !Path::new("/.flatpak-info").exists()
|
root: !Path::new("/.flatpak-info").exists()
|
||||||
}
|
}
|
||||||
|
@ -60,6 +64,11 @@ impl From<&JsonValue> for Patch {
|
||||||
None => default.servers
|
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") {
|
root: match value.get("root") {
|
||||||
Some(value) => value.as_bool().unwrap_or(default.root),
|
Some(value) => value.as_bool().unwrap_or(default.root),
|
||||||
None => default.root
|
None => default.root
|
||||||
|
|
|
@ -19,7 +19,8 @@ pub enum LauncherState {
|
||||||
voices: Vec<VersionDiff>
|
voices: Vec<VersionDiff>
|
||||||
},
|
},
|
||||||
|
|
||||||
MainPatchAvailable(UnityPlayerPatch),
|
UnityPlayerPatchAvailable(UnityPlayerPatch),
|
||||||
|
XluaPatchAvailable(XluaPatch),
|
||||||
|
|
||||||
#[cfg(feature = "components")]
|
#[cfg(feature = "components")]
|
||||||
WineNotInstalled,
|
WineNotInstalled,
|
||||||
|
@ -87,7 +88,7 @@ impl LauncherState {
|
||||||
let game = Game::new(¶ms.game_path);
|
let game = Game::new(¶ms.game_path);
|
||||||
let diff = game.try_get_diff()?;
|
let diff = game.try_get_diff()?;
|
||||||
|
|
||||||
Ok(match diff {
|
match diff {
|
||||||
VersionDiff::Latest(_) | VersionDiff::Predownload { .. } => {
|
VersionDiff::Latest(_) | VersionDiff::Predownload { .. } => {
|
||||||
let mut predownload_voice = Vec::new();
|
let mut predownload_voice = Vec::new();
|
||||||
|
|
||||||
|
@ -132,34 +133,41 @@ impl LauncherState {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check UnityPlayer patch
|
// Check UnityPlayer patch
|
||||||
let main_patch = patch.unity_player_patch()?;
|
let player_patch = patch.unity_player_patch()?;
|
||||||
|
|
||||||
if main_patch.is_applied(¶ms.game_path)? {
|
if !player_patch.is_applied(¶ms.game_path)? {
|
||||||
// TODO: add Xlua patch check
|
return Ok(Self::UnityPlayerPatchAvailable(player_patch));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check xlua patch
|
||||||
|
if params.use_xlua_patch {
|
||||||
|
let xlua_patch = patch.xlua_patch()?;
|
||||||
|
|
||||||
|
if !xlua_patch.is_applied(¶ms.game_path)? {
|
||||||
|
return Ok(Self::XluaPatchAvailable(xlua_patch));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if update predownload available
|
||||||
if let VersionDiff::Predownload { .. } = diff {
|
if let VersionDiff::Predownload { .. } = diff {
|
||||||
Self::PredownloadAvailable {
|
Ok(Self::PredownloadAvailable {
|
||||||
game: diff,
|
game: diff,
|
||||||
voices: predownload_voice
|
voices: predownload_voice
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
Self::Launch
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
Self::MainPatchAvailable(main_patch)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
VersionDiff::Diff { .. } => Self::GameUpdateAvailable(diff),
|
|
||||||
VersionDiff::Outdated { .. } => Self::GameOutdated(diff),
|
|
||||||
VersionDiff::NotInstalled { .. } => Self::GameNotInstalled(diff)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Otherwise we can launch the game
|
||||||
|
else {
|
||||||
|
Ok(Self::Launch)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VersionDiff::Diff { .. } => Ok(Self::GameUpdateAvailable(diff)),
|
||||||
|
VersionDiff::Outdated { .. } => Ok(Self::GameOutdated(diff)),
|
||||||
|
VersionDiff::NotInstalled { .. } => Ok(Self::GameNotInstalled(diff))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "config")]
|
#[cfg(feature = "config")]
|
||||||
#[tracing::instrument(level = "debug", skip(status_updater), ret)]
|
#[tracing::instrument(level = "debug", skip(status_updater), ret)]
|
||||||
pub fn get_from_config<T: Fn(StateUpdating)>(status_updater: T) -> anyhow::Result<Self> {
|
pub fn get_from_config<T: Fn(StateUpdating)>(status_updater: T) -> anyhow::Result<Self> {
|
||||||
|
@ -214,7 +222,7 @@ impl LauncherState {
|
||||||
|
|
||||||
patch_servers: config.patch.servers,
|
patch_servers: config.patch.servers,
|
||||||
patch_folder: config.patch.path,
|
patch_folder: config.patch.path,
|
||||||
use_xlua_patch: false, // TODO
|
use_xlua_patch: config.patch.xlua_patch,
|
||||||
|
|
||||||
status_updater
|
status_updater
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue