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:
16
src/infos.rs
16
src/infos.rs
@@ -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());
|
||||
|
||||
73
src/main.rs
73
src/main.rs
@@ -38,10 +38,6 @@ struct RustDoomLauncher {
|
||||
config_filename: PathBuf,
|
||||
config_file_loaded: bool,
|
||||
command_manager: CommandManager,
|
||||
warp_string: String,
|
||||
difficulty: Difficulty,
|
||||
fast_monsters: bool,
|
||||
respawning_monsters: bool,
|
||||
display_command: bool,
|
||||
add_stuff_window_displayed: bool,
|
||||
selected_file_type: FileType,
|
||||
@@ -58,10 +54,6 @@ impl Default for RustDoomLauncher {
|
||||
add_name: "".to_string(),
|
||||
config_filename: default_save_filename(),
|
||||
config_file_loaded: false,
|
||||
warp_string: String::new(),
|
||||
difficulty: Difficulty::None,
|
||||
fast_monsters: false,
|
||||
respawning_monsters: false,
|
||||
display_command: false,
|
||||
add_stuff_window_displayed: false,
|
||||
selected_file_type: FileType::Pwad,
|
||||
@@ -267,42 +259,65 @@ impl eframe::App for RustDoomLauncher {
|
||||
});
|
||||
let mut text = "Placeholder for WAD info stuffs";
|
||||
let window_size = frame.info().window_info.size;
|
||||
ui.add(egui::TextEdit::multiline(&mut text).desired_width(window_size[0]/1.6).desired_rows(20));
|
||||
ui.add(
|
||||
egui::TextEdit::multiline(&mut text)
|
||||
.desired_width(window_size[0] / 1.6)
|
||||
.desired_rows(20),
|
||||
);
|
||||
});
|
||||
ui.separator();
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
ui.horizontal(|ui| {
|
||||
ui.set_max_width(180.0);
|
||||
let warp_label = ui.label("warp");
|
||||
ui.text_edit_singleline(&mut self.warp_string)
|
||||
let r = ui.text_edit_singleline(&mut self.command_manager.warp)
|
||||
.labelled_by(warp_label.id);
|
||||
if r.changed() {
|
||||
let _ = self.command_manager.generate_command_str();
|
||||
}
|
||||
});
|
||||
ui.separator();
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("difficulty");
|
||||
eframe::egui::ComboBox::new("difficulty", "")
|
||||
.selected_text(format!("{}", self.difficulty))
|
||||
.show_ui(ui, |ui| {
|
||||
for diff in Difficulty::iterator() {
|
||||
ui.selectable_value(&mut self.difficulty, *diff, diff.to_string());
|
||||
}
|
||||
});
|
||||
});
|
||||
ui.separator();
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("fast");
|
||||
ui.checkbox(&mut self.fast_monsters, "");
|
||||
});
|
||||
ui.separator();
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("respawn");
|
||||
ui.checkbox(&mut self.respawning_monsters, "");
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("difficulty");
|
||||
ui.set_max_width(180.0);
|
||||
eframe::egui::ComboBox::new("difficulty", "")
|
||||
.selected_text(format!("{}", self.command_manager.difficulty))
|
||||
.show_ui(ui, |ui| {
|
||||
for diff in Difficulty::iterator() {
|
||||
let r = ui.selectable_value(
|
||||
&mut self.command_manager.difficulty,
|
||||
*diff,
|
||||
diff.to_string(),
|
||||
);
|
||||
if r.clicked() {
|
||||
let _ = self.command_manager.generate_command_str();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
ui.separator();
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("fast");
|
||||
let r = ui.add(egui::Checkbox::without_text(&mut self.command_manager.fast_monsters));
|
||||
if r.clicked() {
|
||||
let _ = self.command_manager.generate_command_str();
|
||||
}
|
||||
});
|
||||
ui.separator();
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("respawn");
|
||||
let r = ui.add(egui::Checkbox::without_text(&mut self.command_manager.respawning_monsters));
|
||||
if r.clicked() {
|
||||
let _ = self.command_manager.generate_command_str();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
ui.separator();
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Command");
|
||||
ui.checkbox(&mut self.display_command, "");
|
||||
ui.add(egui::Checkbox::without_text(&mut self.display_command));
|
||||
});
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
if let Some(l) = self.launcher_manager.get_current() {
|
||||
|
||||
Reference in New Issue
Block a user