paiagram/
settings.rs

1use bevy::prelude::*;
2use serde::{Deserialize, Serialize};
3use strum_macros::EnumIter;
4pub use crate::i18n::Language;
5
6pub struct SettingsPlugin;
7impl Plugin for SettingsPlugin {
8    fn build(&self, app: &mut App) {
9        app.insert_resource(ApplicationSettings::default());
10    }
11}
12
13#[derive(Serialize, Deserialize, Clone, Copy, Debug, EnumIter, PartialEq, Eq)]
14pub enum TerminologyScheme {
15    Paiagram,
16    ChineseRailway,
17    JapaneseRailway,
18}
19
20impl TerminologyScheme {
21    pub fn name(self) -> &'static str {
22        match self {
23            Self::Paiagram => "Paiagram",
24            Self::ChineseRailway => "Chinese Railway",
25            Self::JapaneseRailway => "Japanese Railway",
26        }
27    }
28}
29
30#[derive(Serialize, Deserialize, Clone, Copy, Debug, EnumIter, PartialEq, Eq)]
31pub enum PinyinScheme {
32    Sogou,
33    Microsoft,
34}
35
36#[derive(Resource, Serialize, Deserialize)]
37pub struct ApplicationSettings {
38    pub enable_romaji_search: bool,
39    pub show_performance_stats: bool,
40    pub pinyin_scheme: Vec<String>,
41    pub terminology_scheme: TerminologyScheme,
42    pub language: Language,
43}
44
45impl Default for ApplicationSettings {
46    fn default() -> Self {
47        Self {
48            enable_romaji_search: false,
49            show_performance_stats: false,
50            pinyin_scheme: vec!["quanpin".into(), "diletter_microsoft".into()],
51            terminology_scheme: TerminologyScheme::Paiagram,
52            language: Language::EnCA,
53        }
54    }
55}