diff options
Diffstat (limited to 'src/utils.rs')
-rw-r--r-- | src/utils.rs | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/utils.rs b/src/utils.rs index f5a25c8..02732c9 100644 --- a/src/utils.rs +++ b/src/utils.rs | |||
@@ -10,28 +10,34 @@ use std::path::PathBuf; | |||
10 | 10 | ||
11 | pub const VIEW_WIDTH: usize = 25; | 11 | pub const VIEW_WIDTH: usize = 25; |
12 | pub const VIEW_HEIGHT: usize = 8; | 12 | pub const VIEW_HEIGHT: usize = 8; |
13 | pub const GRID_WIDTH: usize = 3; | ||
14 | 13 | ||
15 | #[derive(Serialize, Deserialize)] | 14 | #[derive(Serialize, Deserialize)] |
16 | pub struct Characters { | 15 | pub struct Look { |
17 | #[serde(default = "base_char")] | 16 | #[serde(default = "base_char")] |
18 | pub true_chr: char, | 17 | pub true_chr: char, |
19 | #[serde(default = "base_char")] | 18 | #[serde(default = "base_char")] |
20 | pub false_chr: char, | 19 | pub false_chr: char, |
21 | #[serde(default = "base_char")] | 20 | #[serde(default = "base_char")] |
22 | pub future_chr: char, | 21 | pub future_chr: char, |
22 | #[serde(default = "grid_size")] | ||
23 | pub grid_size: usize, | ||
23 | } | 24 | } |
24 | 25 | ||
25 | fn base_char() -> char { | 26 | fn base_char() -> char { |
26 | '·' | 27 | '·' |
27 | } | 28 | } |
28 | 29 | ||
29 | impl Default for Characters { | 30 | fn grid_size() -> usize { |
31 | 3 | ||
32 | } | ||
33 | |||
34 | impl Default for Look { | ||
30 | fn default() -> Self { | 35 | fn default() -> Self { |
31 | Characters { | 36 | Look { |
32 | true_chr: '·', | 37 | true_chr: '·', |
33 | false_chr: '·', | 38 | false_chr: '·', |
34 | future_chr: '·', | 39 | future_chr: '·', |
40 | grid_size: 3, | ||
35 | } | 41 | } |
36 | } | 42 | } |
37 | } | 43 | } |
@@ -69,7 +75,7 @@ impl Default for Colors { | |||
69 | #[derive(Serialize, Deserialize)] | 75 | #[derive(Serialize, Deserialize)] |
70 | pub struct AppConfig { | 76 | pub struct AppConfig { |
71 | #[serde(default)] | 77 | #[serde(default)] |
72 | pub look: Characters, | 78 | pub look: Look, |
73 | 79 | ||
74 | #[serde(default)] | 80 | #[serde(default)] |
75 | pub colors: Colors, | 81 | pub colors: Colors, |
@@ -87,13 +93,16 @@ impl Default for AppConfig { | |||
87 | impl AppConfig { | 93 | impl AppConfig { |
88 | // TODO: implement string parsing from config.json | 94 | // TODO: implement string parsing from config.json |
89 | pub fn reached_color(&self) -> Color { | 95 | pub fn reached_color(&self) -> Color { |
90 | return Color::parse(&self.colors.reached).unwrap_or(Color::Dark(BaseColor::Cyan)); | 96 | Color::parse(&self.colors.reached).unwrap_or(Color::Dark(BaseColor::Cyan)) |
91 | } | 97 | } |
92 | pub fn todo_color(&self) -> Color { | 98 | pub fn todo_color(&self) -> Color { |
93 | return Color::parse(&self.colors.todo).unwrap_or(Color::Dark(BaseColor::Magenta)); | 99 | Color::parse(&self.colors.todo).unwrap_or(Color::Dark(BaseColor::Magenta)) |
94 | } | 100 | } |
95 | pub fn inactive_color(&self) -> Color { | 101 | pub fn inactive_color(&self) -> Color { |
96 | return Color::parse(&self.colors.inactive).unwrap_or(Color::Light(BaseColor::Black)); | 102 | Color::parse(&self.colors.inactive).unwrap_or(Color::Light(BaseColor::Black)) |
103 | } | ||
104 | pub fn grid_size(&self) -> usize { | ||
105 | self.look.grid_size | ||
97 | } | 106 | } |
98 | } | 107 | } |
99 | 108 | ||