Files
rdl/src/infos.rs
2023-06-04 23:07:07 +01:00

59 lines
1.5 KiB
Rust

use serde_derive::{Deserialize, Serialize};
use std::fmt;
use std::path::PathBuf;
use std::slice::Iter;
// TODO - write some impl stuff in here so the main GUI stuff
// is a little bit more decoupled from this. I think a Display
// and perhaps the path to string conversion too could be
// removed from the GUI part
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct WadInfo {
pub path: PathBuf,
pub name: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct LauncherInfo {
pub path: PathBuf,
pub name: String,
}
#[derive(PartialEq, Clone, Copy)]
pub enum Difficulty {
None,
Baby,
Easy,
Medium,
Hard,
Nightmare,
}
impl fmt::Display for Difficulty {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Difficulty::Baby => write!(f, "I'm too young to die"),
Difficulty::Easy => write!(f, "Hey, not too rough"),
Difficulty::Medium => write!(f, "Hurt me plenty"),
Difficulty::Hard => write!(f, "Ultra-Violence"),
Difficulty::Nightmare => write!(f, "Nightmare!"),
Difficulty::None => write!(f, "None"),
}
}
}
impl Difficulty {
pub fn iterator() -> Iter<'static, Difficulty> {
static DIFFICULTIES: [Difficulty; 6] = [
Difficulty::None,
Difficulty::Baby,
Difficulty::Easy,
Difficulty::Medium,
Difficulty::Hard,
Difficulty::Nightmare,
];
DIFFICULTIES.iter()
}
}