Updated core library; added support for Chinese version

This commit is contained in:
Observer KRypt0n_ 2022-08-06 10:42:21 +02:00
parent 59b50afa63
commit cd76c22812
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
4 changed files with 49 additions and 5 deletions

2
Cargo.lock generated
View file

@ -31,7 +31,7 @@ dependencies = [
[[package]]
name = "anime-game-core"
version = "0.3.4"
version = "0.4.0"
dependencies = [
"bzip2",
"curl",

@ -1 +1 @@
Subproject commit ea6d8638d8167badf2ef1753621560003412e3c8
Subproject commit ebbbad1d13a09a64495ab5ac18d306e48ba8564a

View file

@ -1,6 +1,8 @@
use serde::{Serialize, Deserialize};
use serde_json::Value as JsonValue;
use anime_game_core::consts::GameEdition as CoreGameEdition;
use crate::lib::consts::launcher_dir;
pub mod repairer;
@ -12,11 +14,42 @@ pub mod prelude {
use prelude::*;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum GameEdition {
Global,
China
}
impl Default for GameEdition {
fn default() -> Self {
Self::Global
}
}
impl Into<CoreGameEdition> for GameEdition {
fn into(self) -> CoreGameEdition {
match self {
Self::Global => CoreGameEdition::Global,
Self::China => CoreGameEdition::China
}
}
}
impl From<CoreGameEdition> for GameEdition {
fn from(edition: CoreGameEdition) -> Self {
match edition {
CoreGameEdition::Global => Self::Global,
CoreGameEdition::China => Self::China
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Launcher {
pub language: String,
pub temp: Option<String>,
pub repairer: Repairer
pub repairer: Repairer,
pub edition: GameEdition
}
impl Default for Launcher {
@ -24,7 +57,8 @@ impl Default for Launcher {
Self {
language: String::from("en-us"),
temp: launcher_dir(),
repairer: Repairer::default()
repairer: Repairer::default(),
edition: GameEdition::default()
}
}
}
@ -56,6 +90,11 @@ impl From<&JsonValue> for Launcher {
repairer: match value.get("repairer") {
Some(value) => Repairer::from(value),
None => default.repairer
},
edition: match value.get("edition") {
Some(value) => serde_json::from_value(value.clone()).unwrap_or(default.edition),
None => default.edition
}
}
}

View file

@ -59,8 +59,13 @@ fn main() {
first_run.show();
}
// Load main window and show it
else {
// Set game edition
let config = lib::config::get().expect("Failed to load config");
anime_game_core::consts::set_game_edition(config.launcher.edition.into());
// Load and show main window
let main = MainApp::new(app).expect("Failed to init MainApp");
main.show();