forked from processing/libprocessing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.rs
More file actions
47 lines (40 loc) · 855 Bytes
/
config.rs
File metadata and controls
47 lines (40 loc) · 855 Bytes
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
use bevy::prelude::Resource;
use std::collections::HashMap;
#[derive(Clone, Hash, Eq, PartialEq)]
pub enum ConfigKey {
AssetRootPath,
SketchRootPath,
SketchFileName,
LogLevel,
}
// TODO: Consider Box<dyn Any> instead of String
#[derive(Resource)]
pub struct Config {
map: HashMap<ConfigKey, String>,
}
impl Clone for Config {
fn clone(&self) -> Self {
Config {
map: self.map.clone(),
}
}
}
impl Config {
pub fn new() -> Self {
// TODO consider defaults
Config {
map: HashMap::new(),
}
}
pub fn get(&self, k: ConfigKey) -> Option<&String> {
self.map.get(&k)
}
pub fn set(&mut self, k: ConfigKey, v: String) {
self.map.insert(k, v);
}
}
impl Default for Config {
fn default() -> Self {
Self::new()
}
}