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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
//! Configuration structures for the game client
use ggez::conf::{FullscreenType, NumSamples};
use std::path::PathBuf;
pub fn default() -> GameSettings {
GameSettings {
assets: None,
window: WindowSettings {
width: 1280,
height: 720,
window_mode: WindowMode::Windowed,
},
graphics: GraphicsSettings {
samples: Samples(8),
vsync: true,
},
}
}
/// Complete tree of basic game client settings
pub struct GameSettings {
pub assets: Option<PathBuf>,
pub window: WindowSettings,
pub graphics: GraphicsSettings,
}
/// Window setup specific settings
pub struct WindowSettings {
pub width: u16,
pub height: u16,
pub window_mode: WindowMode,
}
/// Graphic settings
pub struct GraphicsSettings {
pub samples: Samples,
pub vsync: bool,
}
pub struct Samples(pub u8);
impl<'s> From<&'s Samples> for NumSamples {
fn from(s: &'s Samples) -> Self {
match s.0 {
1 => Self::One,
2 => Self::Two,
4 => Self::Four,
8 => Self::Eight,
// 16 => Self::Sixteen, // currently broken
_ => panic!("Invalid multisampling value: {}", s.0),
}
}
}
pub enum WindowMode {
Windowed,
Fullscreen,
}
impl WindowMode {
pub fn maximized(&self) -> bool {
match self {
Self::Fullscreen => true,
_ => false,
}
}
pub fn _type(&self) -> FullscreenType {
match self {
Self::Fullscreen => FullscreenType::Desktop,
Self::Windowed => FullscreenType::Windowed,
}
}
}
|