aboutsummaryrefslogtreecommitdiff
path: root/games/rstnode/rst-client/src/settings.rs
diff options
context:
space:
mode:
Diffstat (limited to 'games/rstnode/rst-client/src/settings.rs')
-rw-r--r--games/rstnode/rst-client/src/settings.rs73
1 files changed, 73 insertions, 0 deletions
diff --git a/games/rstnode/rst-client/src/settings.rs b/games/rstnode/rst-client/src/settings.rs
new file mode 100644
index 000000000000..971e8e6f50b7
--- /dev/null
+++ b/games/rstnode/rst-client/src/settings.rs
@@ -0,0 +1,73 @@
+//! Configuration structures for the game client
+
+use ggez::conf::{FullscreenType, NumSamples};
+
+pub fn default() -> GameSettings {
+ GameSettings {
+ window: WindowSettings {
+ width: 1280,
+ height: 720,
+ window_mode: WindowMode::Windowed,
+ },
+ graphics: GraphicsSettings {
+ samples: Samples(0),
+ vsync: true,
+ },
+ }
+}
+
+/// Complete tree of basic game client settings
+pub struct GameSettings {
+ 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 {
+ 0 => Self::Zero,
+ 1 => Self::One,
+ 2 => Self::Two,
+ 4 => Self::Four,
+ 8 => Self::Eight,
+ 16 => Self::Sixteen,
+ _ => 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,
+ }
+ }
+}