1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! The configuration format for the program container

use typedef::*;

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct DisplayConfig {
    #[serde(default)]
    pub resolution: DisplayResolution,
    pub default_scale: Float,
    #[serde(default)]
    pub hide_cursor: bool,
}

impl Default for DisplayConfig {
    fn default() -> Self {
        DisplayConfig {
            resolution: Default::default(),
            default_scale: 4.0,
            hide_cursor: true,
        }
    }
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct DisplayResolution {
    pub width: usize,
    pub height: usize,
}

impl Default for DisplayResolution {
    fn default() -> Self {
        DisplayResolution {
            width: 160,
            height: 100,
        }
    }
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Config {
    #[serde(default)]
    pub title: String,
    #[serde(default)]
    pub display: DisplayConfig,
    #[serde(default)]
    pub input_enabled: bool,
}

impl Default for Config {
    fn default() -> Self {
        Config {
            title: "bakerVM".into(),
            display: Default::default(),
            input_enabled: true,
        }
    }
}