Fixed pointess generate_str function return
Also added a nice little helpful close window thingy
This commit is contained in:
64
src/main.rs
64
src/main.rs
@@ -42,6 +42,8 @@ struct RustDoomLauncher {
|
||||
add_stuff_window_displayed: bool,
|
||||
selected_file_type: FileType,
|
||||
selected_file_path: PathBuf,
|
||||
save_config_window_displayed: bool,
|
||||
close_application: bool,
|
||||
}
|
||||
|
||||
impl Default for RustDoomLauncher {
|
||||
@@ -58,6 +60,8 @@ impl Default for RustDoomLauncher {
|
||||
add_stuff_window_displayed: false,
|
||||
selected_file_type: FileType::Pwad,
|
||||
selected_file_path: PathBuf::new(),
|
||||
save_config_window_displayed: false,
|
||||
close_application: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -128,13 +132,8 @@ impl RustDoomLauncher {
|
||||
|
||||
impl eframe::App for RustDoomLauncher {
|
||||
fn on_close_event(&mut self) -> bool {
|
||||
let config = Config {
|
||||
iwads: Some(self.iwad_manager.selectable.clone()),
|
||||
pwads: Some(self.pwad_manager.selectable.clone()),
|
||||
launchers: Some(self.launcher_manager.selectable.clone()),
|
||||
};
|
||||
save_config(&self.config_filename, &config).unwrap();
|
||||
true
|
||||
self.save_config_window_displayed = true;
|
||||
self.close_application
|
||||
}
|
||||
|
||||
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
|
||||
@@ -270,19 +269,20 @@ impl eframe::App for RustDoomLauncher {
|
||||
ui.horizontal(|ui| {
|
||||
ui.set_max_width(180.0);
|
||||
let warp_label = ui.label("warp");
|
||||
let r = ui.text_edit_singleline(&mut self.command_manager.warp)
|
||||
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();
|
||||
self.command_manager.update_command();
|
||||
}
|
||||
});
|
||||
ui.separator();
|
||||
ui.horizontal(|ui| {
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("difficulty");
|
||||
ui.set_max_width(180.0);
|
||||
eframe::egui::ComboBox::new("difficulty", "")
|
||||
.selected_text(format!("{}", self.command_manager.difficulty))
|
||||
.width(140.0)
|
||||
.show_ui(ui, |ui| {
|
||||
for diff in Difficulty::iterator() {
|
||||
let r = ui.selectable_value(
|
||||
@@ -291,7 +291,7 @@ impl eframe::App for RustDoomLauncher {
|
||||
diff.to_string(),
|
||||
);
|
||||
if r.clicked() {
|
||||
let _ = self.command_manager.generate_command_str();
|
||||
self.command_manager.update_command();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -299,17 +299,21 @@ impl eframe::App for RustDoomLauncher {
|
||||
ui.separator();
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("fast");
|
||||
let r = ui.add(egui::Checkbox::without_text(&mut self.command_manager.fast_monsters));
|
||||
let r = ui.add(egui::Checkbox::without_text(
|
||||
&mut self.command_manager.fast_monsters,
|
||||
));
|
||||
if r.clicked() {
|
||||
let _ = self.command_manager.generate_command_str();
|
||||
self.command_manager.update_command();
|
||||
}
|
||||
});
|
||||
ui.separator();
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("respawn");
|
||||
let r = ui.add(egui::Checkbox::without_text(&mut self.command_manager.respawning_monsters));
|
||||
let r = ui.add(egui::Checkbox::without_text(
|
||||
&mut self.command_manager.respawning_monsters,
|
||||
));
|
||||
if r.clicked() {
|
||||
let _ = self.command_manager.generate_command_str();
|
||||
self.command_manager.update_command();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -365,6 +369,36 @@ impl eframe::App for RustDoomLauncher {
|
||||
}
|
||||
});
|
||||
|
||||
if self.save_config_window_displayed {
|
||||
egui::Window::new("Save WADs?")
|
||||
.collapsible(false)
|
||||
.resizable(false)
|
||||
.show(ctx, |ui| {
|
||||
ui.vertical(|ui| {
|
||||
ui.label("Would you like to save the WADs you've added/deleted?");
|
||||
ui.horizontal(|ui| {
|
||||
if ui.button("Yes").clicked() {
|
||||
self.close_application = true;
|
||||
let config = Config {
|
||||
iwads: Some(self.iwad_manager.selectable.clone()),
|
||||
pwads: Some(self.pwad_manager.selectable.clone()),
|
||||
launchers: Some(self.launcher_manager.selectable.clone()),
|
||||
};
|
||||
save_config(&self.config_filename, &config).unwrap();
|
||||
frame.close();
|
||||
}
|
||||
if ui.button("No").clicked() {
|
||||
self.close_application = true;
|
||||
frame.close();
|
||||
};
|
||||
if ui.button("Don't Quit").clicked() {
|
||||
self.save_config_window_displayed = false;
|
||||
};
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
egui::Window::new("Add WAD or Launcher")
|
||||
.open(&mut self.add_stuff_window_displayed)
|
||||
.show(ctx, |ui| {
|
||||
|
||||
Reference in New Issue
Block a user