1.4.0
- updated core library, got rid of `GameEdition::current()`
This commit is contained in:
parent
72f2c9699b
commit
1ecc5ec822
5 changed files with 23 additions and 19 deletions
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "anime-launcher-sdk"
|
name = "anime-launcher-sdk"
|
||||||
version = "1.3.0"
|
version = "1.4.0"
|
||||||
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"
|
||||||
|
@ -8,7 +8,7 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies.anime-game-core]
|
[dependencies.anime-game-core]
|
||||||
git = "https://github.com/an-anime-team/anime-game-core"
|
git = "https://github.com/an-anime-team/anime-game-core"
|
||||||
tag = "1.9.0"
|
tag = "1.10.0"
|
||||||
features = ["all"]
|
features = ["all"]
|
||||||
|
|
||||||
# path = "../anime-game-core" # ! for dev purposes only
|
# path = "../anime-game-core" # ! for dev purposes only
|
||||||
|
@ -30,8 +30,8 @@ discord-rich-presence = { version = "0.2.3", optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
genshin = ["anime-game-core/genshin"]
|
genshin = ["anime-game-core/genshin"]
|
||||||
honkai = ["anime-game-core/honkai"]
|
|
||||||
star-rail = ["anime-game-core/star-rail"]
|
star-rail = ["anime-game-core/star-rail"]
|
||||||
|
honkai = ["anime-game-core/honkai"]
|
||||||
|
|
||||||
# Common features
|
# Common features
|
||||||
states = []
|
states = []
|
||||||
|
|
|
@ -71,7 +71,7 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
|
|
||||||
tracing::info!("Checking telemetry");
|
tracing::info!("Checking telemetry");
|
||||||
|
|
||||||
if let Ok(Some(server)) = telemetry::is_disabled() {
|
if let Ok(Some(server)) = telemetry::is_disabled(config.launcher.edition) {
|
||||||
return Err(anyhow::anyhow!("Telemetry server is not disabled: {server}"));
|
return Err(anyhow::anyhow!("Telemetry server is not disabled: {server}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
// Generate `config.ini` if environment emulation feature is presented
|
// Generate `config.ini` if environment emulation feature is presented
|
||||||
|
|
||||||
#[cfg(feature = "environment-emulation")] {
|
#[cfg(feature = "environment-emulation")] {
|
||||||
let game = Game::new(game_path);
|
let game = Game::new(game_path, config.launcher.edition);
|
||||||
|
|
||||||
std::fs::write(
|
std::fs::write(
|
||||||
game_path.join("config.ini"),
|
game_path.join("config.ini"),
|
||||||
|
|
|
@ -60,9 +60,10 @@ pub enum StateUpdating {
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct LauncherStateParams<F: Fn(StateUpdating)> {
|
pub struct LauncherStateParams<F: Fn(StateUpdating)> {
|
||||||
pub wine_prefix: PathBuf,
|
|
||||||
pub game_path: PathBuf,
|
pub game_path: PathBuf,
|
||||||
|
pub game_edition: GameEdition,
|
||||||
|
|
||||||
|
pub wine_prefix: PathBuf,
|
||||||
pub selected_voices: Vec<VoiceLocale>,
|
pub selected_voices: Vec<VoiceLocale>,
|
||||||
|
|
||||||
pub patch_servers: Vec<String>,
|
pub patch_servers: Vec<String>,
|
||||||
|
@ -84,11 +85,11 @@ impl LauncherState {
|
||||||
// Check game installation status
|
// Check game installation status
|
||||||
(params.status_updater)(StateUpdating::Game);
|
(params.status_updater)(StateUpdating::Game);
|
||||||
|
|
||||||
let game = Game::new(¶ms.game_path);
|
let game = Game::new(¶ms.game_path, params.game_edition);
|
||||||
|
|
||||||
// Check if game is installed
|
// Check if game is installed
|
||||||
if game.is_installed() {
|
if game.is_installed() {
|
||||||
let data_folder = params.game_path.join(GameEdition::selected().data_folder());
|
let data_folder = params.game_path.join(params.game_edition.data_folder());
|
||||||
|
|
||||||
let old_audio_folder_base = data_folder.join("StreamingAssets/Audio");
|
let old_audio_folder_base = data_folder.join("StreamingAssets/Audio");
|
||||||
let old_audio_folder = old_audio_folder_base.join("GeneratedSoundBanks/Windows");
|
let old_audio_folder = old_audio_folder_base.join("GeneratedSoundBanks/Windows");
|
||||||
|
@ -106,18 +107,18 @@ impl LauncherState {
|
||||||
let diff = game.try_get_diff()?;
|
let diff = game.try_get_diff()?;
|
||||||
|
|
||||||
match diff {
|
match diff {
|
||||||
VersionDiff::Latest(_) | VersionDiff::Predownload { .. } => {
|
VersionDiff::Latest { .. } | VersionDiff::Predownload { .. } => {
|
||||||
let mut predownload_voice = Vec::new();
|
let mut predownload_voice = Vec::new();
|
||||||
|
|
||||||
for locale in params.selected_voices {
|
for locale in params.selected_voices {
|
||||||
let mut voice_package = VoicePackage::with_locale(locale)?;
|
let mut voice_package = VoicePackage::with_locale(locale, params.game_edition)?;
|
||||||
|
|
||||||
(params.status_updater)(StateUpdating::Voice(voice_package.locale()));
|
(params.status_updater)(StateUpdating::Voice(voice_package.locale()));
|
||||||
|
|
||||||
// Replace voice package struct with the one constructed in the game's folder
|
// Replace voice package struct with the one constructed in the game's folder
|
||||||
// so it'll properly calculate its difference instead of saying "not installed"
|
// so it'll properly calculate its difference instead of saying "not installed"
|
||||||
if voice_package.is_installed_in(¶ms.game_path) {
|
if voice_package.is_installed_in(¶ms.game_path) {
|
||||||
voice_package = match VoicePackage::new(get_voice_package_path(¶ms.game_path, voice_package.locale())) {
|
voice_package = match VoicePackage::new(get_voice_package_path(¶ms.game_path, params.game_edition, voice_package.locale()), params.game_edition) {
|
||||||
Some(locale) => locale,
|
Some(locale) => locale,
|
||||||
None => return Err(anyhow::anyhow!("Failed to load {} voice package", voice_package.locale().to_name()))
|
None => return Err(anyhow::anyhow!("Failed to load {} voice package", voice_package.locale().to_name()))
|
||||||
};
|
};
|
||||||
|
@ -126,7 +127,7 @@ impl LauncherState {
|
||||||
let diff = voice_package.try_get_diff()?;
|
let diff = voice_package.try_get_diff()?;
|
||||||
|
|
||||||
match diff {
|
match diff {
|
||||||
VersionDiff::Latest(_) => (),
|
VersionDiff::Latest { .. } => (),
|
||||||
VersionDiff::Predownload { .. } => predownload_voice.push(diff),
|
VersionDiff::Predownload { .. } => predownload_voice.push(diff),
|
||||||
|
|
||||||
VersionDiff::Diff { .. } => return Ok(Self::VoiceUpdateAvailable(diff)),
|
VersionDiff::Diff { .. } => return Ok(Self::VoiceUpdateAvailable(diff)),
|
||||||
|
@ -138,7 +139,7 @@ impl LauncherState {
|
||||||
// Check game patch status
|
// Check game patch status
|
||||||
(params.status_updater)(StateUpdating::Patch);
|
(params.status_updater)(StateUpdating::Patch);
|
||||||
|
|
||||||
let patch = Patch::new(¶ms.patch_folder);
|
let patch = Patch::new(¶ms.patch_folder, params.game_edition);
|
||||||
|
|
||||||
// Sync local patch folder with remote if needed
|
// Sync local patch folder with remote if needed
|
||||||
// TODO: maybe I shouldn't do it here?
|
// TODO: maybe I shouldn't do it here?
|
||||||
|
@ -212,9 +213,10 @@ impl LauncherState {
|
||||||
}
|
}
|
||||||
|
|
||||||
Self::get(LauncherStateParams {
|
Self::get(LauncherStateParams {
|
||||||
wine_prefix: config.get_wine_prefix_path(),
|
|
||||||
game_path: config.game.path.for_edition(config.launcher.edition).to_path_buf(),
|
game_path: config.game.path.for_edition(config.launcher.edition).to_path_buf(),
|
||||||
|
game_edition: config.launcher.edition,
|
||||||
|
|
||||||
|
wine_prefix: config.get_wine_prefix_path(),
|
||||||
selected_voices: voices,
|
selected_voices: voices,
|
||||||
|
|
||||||
patch_servers: config.patch.servers,
|
patch_servers: config.patch.servers,
|
||||||
|
|
|
@ -65,7 +65,7 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
|
|
||||||
tracing::info!("Checking telemetry");
|
tracing::info!("Checking telemetry");
|
||||||
|
|
||||||
if let Ok(Some(server)) = telemetry::is_disabled() {
|
if let Ok(Some(server)) = telemetry::is_disabled(config.launcher.edition) {
|
||||||
return Err(anyhow::anyhow!("Telemetry server is not disabled: {server}"));
|
return Err(anyhow::anyhow!("Telemetry server is not disabled: {server}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,10 +40,11 @@ pub enum StateUpdating {
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct LauncherStateParams<F: Fn(StateUpdating)> {
|
pub struct LauncherStateParams<F: Fn(StateUpdating)> {
|
||||||
pub wine_prefix: PathBuf,
|
|
||||||
pub game_path: PathBuf,
|
pub game_path: PathBuf,
|
||||||
pub game_edition: GameEdition,
|
pub game_edition: GameEdition,
|
||||||
|
|
||||||
|
pub wine_prefix: PathBuf,
|
||||||
|
|
||||||
pub patch_servers: Vec<String>,
|
pub patch_servers: Vec<String>,
|
||||||
pub patch_folder: PathBuf,
|
pub patch_folder: PathBuf,
|
||||||
|
|
||||||
|
@ -62,11 +63,11 @@ impl LauncherState {
|
||||||
// Check game installation status
|
// Check game installation status
|
||||||
(params.status_updater)(StateUpdating::Game);
|
(params.status_updater)(StateUpdating::Game);
|
||||||
|
|
||||||
let game = Game::new(¶ms.game_path);
|
let game = Game::new(¶ms.game_path, params.game_edition);
|
||||||
let diff = game.try_get_diff()?;
|
let diff = game.try_get_diff()?;
|
||||||
|
|
||||||
match diff {
|
match diff {
|
||||||
VersionDiff::Latest(_) | VersionDiff::Predownload { .. } => {
|
VersionDiff::Latest { .. } | VersionDiff::Predownload { .. } => {
|
||||||
// Check game patch status
|
// Check game patch status
|
||||||
(params.status_updater)(StateUpdating::Patch);
|
(params.status_updater)(StateUpdating::Patch);
|
||||||
|
|
||||||
|
@ -123,10 +124,11 @@ impl LauncherState {
|
||||||
}
|
}
|
||||||
|
|
||||||
Self::get(LauncherStateParams {
|
Self::get(LauncherStateParams {
|
||||||
wine_prefix: config.get_wine_prefix_path(),
|
|
||||||
game_path: config.game.path.for_edition(config.launcher.edition).to_path_buf(),
|
game_path: config.game.path.for_edition(config.launcher.edition).to_path_buf(),
|
||||||
game_edition: config.launcher.edition,
|
game_edition: config.launcher.edition,
|
||||||
|
|
||||||
|
wine_prefix: config.get_wine_prefix_path(),
|
||||||
|
|
||||||
patch_servers: config.patch.servers,
|
patch_servers: config.patch.servers,
|
||||||
patch_folder: config.patch.path,
|
patch_folder: config.patch.path,
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue