You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
1.7 KiB
77 lines
1.7 KiB
//! Configuration structures for the game client
|
|
|
|
use ggez::conf::{FullscreenType, NumSamples};
|
|
use std::path::PathBuf;
|
|
|
|
pub fn default() -> GameSettings {
|
|
GameSettings {
|
|
editor: false,
|
|
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 editor: bool,
|
|
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,
|
|
}
|
|
}
|
|
}
|
|
|