feat(star-rail): added game.voices config

This commit is contained in:
Observer KRypt0n_ 2023-11-13 18:02:58 +02:00
parent ea5a501a0f
commit 59a95e4814
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2

View file

@ -26,6 +26,7 @@ use prelude::*;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Game {
pub path: Paths,
pub voices: Vec<String>,
pub wine: Wine,
pub dxvk: Dxvk,
pub enhancements: Enhancements,
@ -38,6 +39,9 @@ impl Default for Game {
fn default() -> Self {
Self {
path: Paths::default(),
voices: vec![
String::from("en-us")
],
wine: Wine::default(),
dxvk: Dxvk::default(),
enhancements: Enhancements::default(),
@ -56,6 +60,24 @@ impl From<&JsonValue> for Game {
.map(Paths::from)
.unwrap_or(default.path),
voices: match value.get("voices") {
Some(value) => match value.as_array() {
Some(values) => {
let mut voices = Vec::new();
for value in values {
if let Some(voice) = value.as_str() {
voices.push(voice.to_string());
}
}
voices
},
None => default.voices
},
None => default.voices
},
wine: value.get("wine")
.map(Wine::from)
.unwrap_or(default.wine),