Fixed the flag/command line stuff

Also added it all into the command_manager thing so the App struct
doesn't look quite so busy
This commit is contained in:
2023-07-04 23:34:34 +01:00
parent 061a987060
commit 6004df73f7
2 changed files with 54 additions and 35 deletions

View File

@@ -4,13 +4,12 @@ use std::path::PathBuf;
use std::slice::Iter;
use std::cmp::Ordering;
#[derive(Default)]
pub struct CommandManager {
pub launcher: Option<PathBuf>,
pub iwad: Option<PathBuf>,
pub pwads: Vec<PathBuf>,
pub warp: String,
pub difficulty: Option<Difficulty>,
pub difficulty: Difficulty,
pub fast_monsters: bool,
pub respawning_monsters: bool,
pub command_string: String,
@@ -28,7 +27,7 @@ impl CommandManager {
iwad: None,
pwads: Vec::new(),
warp: "".to_string(),
difficulty: None,
difficulty: Difficulty::None,
fast_monsters: false,
respawning_monsters: false,
command_string: "".to_string(),
@@ -73,13 +72,18 @@ impl CommandManager {
command.push("-file".to_string());
command.push(pwad.clone().into_os_string().into_string().unwrap());
}
if let Some(d) = self.difficulty {
if self.difficulty != Difficulty::None {
command.push("-skill".to_string());
command.push(d.flag_number().to_string());
command.push(self.difficulty.flag_number().to_string());
}
if !self.warp.is_empty() {
command.push("-warp".to_string());
command.push(self.warp.to_string());
// Again, feel like there's must be a _much_ better way than this...
let warp_string = self.warp.to_string();
let strings: Vec<&str> = warp_string.split_whitespace().collect();
for string in strings {
command.push(string.to_string());
}
}
if self.respawning_monsters {
command.push("-respawn".to_string());