feat(honkai): added multi-regional support
This commit is contained in:
parent
1669dceafc
commit
d72eb796cf
4 changed files with 19 additions and 7 deletions
|
@ -9,7 +9,7 @@ edition = "2021"
|
|||
|
||||
[dependencies.anime-game-core]
|
||||
git = "https://github.com/an-anime-team/anime-game-core"
|
||||
tag = "1.13.5"
|
||||
tag = "1.14.0"
|
||||
features = ["all"]
|
||||
|
||||
# path = "../anime-game-core" # ! for dev purposes only
|
||||
|
|
|
@ -5,12 +5,14 @@ use serde_json::Value as JsonValue;
|
|||
|
||||
use enum_ordinalize::Ordinalize;
|
||||
|
||||
#[cfg(feature = "discord-rpc")]
|
||||
pub mod discord_rpc;
|
||||
use anime_game_core::honkai::consts::GameEdition;
|
||||
|
||||
use crate::config::schema_blanks::prelude::*;
|
||||
use crate::honkai::consts::launcher_dir;
|
||||
|
||||
#[cfg(feature = "discord-rpc")]
|
||||
pub mod discord_rpc;
|
||||
|
||||
pub mod prelude {
|
||||
pub use super::{
|
||||
Launcher,
|
||||
|
@ -54,6 +56,7 @@ impl Default for LauncherBehavior {
|
|||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Launcher {
|
||||
pub language: String,
|
||||
pub edition: GameEdition,
|
||||
pub style: LauncherStyle,
|
||||
pub temp: Option<PathBuf>,
|
||||
pub repairer: Repairer,
|
||||
|
@ -69,6 +72,7 @@ impl Default for Launcher {
|
|||
fn default() -> Self {
|
||||
Self {
|
||||
language: String::from("en-us"),
|
||||
edition: GameEdition::from_system_lang(),
|
||||
style: LauncherStyle::default(),
|
||||
temp: launcher_dir().ok(),
|
||||
repairer: Repairer::default(),
|
||||
|
@ -91,6 +95,11 @@ impl From<&JsonValue> for Launcher {
|
|||
None => default.language
|
||||
},
|
||||
|
||||
edition: match value.get("edition") {
|
||||
Some(value) => serde_json::from_value(value.clone()).unwrap_or(default.edition),
|
||||
None => default.edition
|
||||
},
|
||||
|
||||
style: match value.get("style") {
|
||||
Some(value) => serde_json::from_value(value.to_owned()).unwrap_or_default(),
|
||||
None => default.style
|
||||
|
|
|
@ -69,7 +69,7 @@ pub fn run() -> anyhow::Result<()> {
|
|||
|
||||
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}"));
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ use anime_game_core::prelude::*;
|
|||
use anime_game_core::honkai::prelude::*;
|
||||
|
||||
use crate::config::ConfigExt;
|
||||
use crate::honkai::config::Config;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum LauncherState {
|
||||
|
@ -42,6 +43,7 @@ pub enum StateUpdating {
|
|||
pub struct LauncherStateParams<F: Fn(StateUpdating)> {
|
||||
pub wine_prefix: PathBuf,
|
||||
pub game_path: PathBuf,
|
||||
pub game_edition: GameEdition,
|
||||
|
||||
pub patch_folder: PathBuf,
|
||||
pub apply_mfplat: bool,
|
||||
|
@ -61,7 +63,7 @@ impl LauncherState {
|
|||
// Check game installation status
|
||||
(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()?;
|
||||
|
||||
|
@ -88,7 +90,7 @@ impl LauncherState {
|
|||
}
|
||||
|
||||
// Check telemetry servers
|
||||
let disabled = telemetry::is_disabled()
|
||||
let disabled = telemetry::is_disabled(params.game_edition)
|
||||
|
||||
// Return true if there's no domain name resolved, or false otherwise
|
||||
.map(|result| result.is_none())
|
||||
|
@ -123,7 +125,7 @@ impl LauncherState {
|
|||
pub fn get_from_config<T: Fn(StateUpdating)>(status_updater: T) -> anyhow::Result<Self> {
|
||||
tracing::debug!("Trying to get launcher state");
|
||||
|
||||
let config = crate::honkai::config::Config::get()?;
|
||||
let config = Config::get()?;
|
||||
|
||||
match &config.game.wine.selected {
|
||||
#[cfg(feature = "components")]
|
||||
|
@ -137,6 +139,7 @@ impl LauncherState {
|
|||
Self::get(LauncherStateParams {
|
||||
wine_prefix: config.get_wine_prefix_path(),
|
||||
game_path: config.game.path,
|
||||
game_edition: config.launcher.edition,
|
||||
|
||||
patch_folder: config.patch.path,
|
||||
apply_mfplat: config.patch.apply_mfplat,
|
||||
|
|
Loading…
Reference in a new issue