config: added LauncherStyle param

- used in WIP Relm4 rewrite
- may not be useful in other launcher variants which will use this SDK,
  so would be a good idea to make a standard way
  for developers to integrate their own settings
  with ones provided by this SDK
This commit is contained in:
Observer KRypt0n_ 2023-02-21 17:32:00 +02:00
parent 8a32066c07
commit a62aeef9cd
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2

View file

@ -57,13 +57,26 @@ impl From<CoreGameEdition> for GameEdition {
} }
} }
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum LauncherStyle {
Modern,
Classic
}
impl Default for LauncherStyle {
fn default() -> Self {
Self::Modern
}
}
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Launcher { pub struct Launcher {
pub language: String, pub language: String,
pub temp: Option<PathBuf>, pub temp: Option<PathBuf>,
pub speed_limit: u64, pub speed_limit: u64,
pub repairer: Repairer, pub repairer: Repairer,
pub edition: GameEdition pub edition: GameEdition,
pub style: LauncherStyle
} }
impl Default for Launcher { impl Default for Launcher {
@ -73,7 +86,8 @@ impl Default for Launcher {
temp: launcher_dir(), temp: launcher_dir(),
speed_limit: 0, speed_limit: 0,
repairer: Repairer::default(), repairer: Repairer::default(),
edition: GameEdition::default() edition: GameEdition::default(),
style: LauncherStyle::default()
} }
} }
} }
@ -115,6 +129,11 @@ impl From<&JsonValue> for Launcher {
edition: match value.get("edition") { edition: match value.get("edition") {
Some(value) => serde_json::from_value(value.clone()).unwrap_or(default.edition), Some(value) => serde_json::from_value(value.clone()).unwrap_or(default.edition),
None => default.edition None => default.edition
},
style: match value.get("style") {
Some(value) => serde_json::from_value(value.clone()).unwrap_or(default.style),
None => default.style
} }
} }
} }