diff --git a/src/main.rs b/src/main.rs index d35361b..59e40f5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -50,73 +50,82 @@ impl eframe::App for RustDoomLauncher { fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { egui::containers::panel::CentralPanel::default().show(ctx, |ui| { ui.heading("RustDoomLauncher"); - ui.horizontal(|ui| { - ui.label("Launchers"); - if ui.button("Add Launcher").clicked() { - if let Some(path) = rfd::FileDialog::new().pick_file() { - self.all_launchers.push(path.display().to_string()); + ui.horizontal_wrapped(|ui| { + ui.vertical(|ui| { + ui.label("Launchers"); + + for launcher in &self.all_launchers { + if ui + .add(egui::SelectableLabel::new( + self.selected_launcher.is_some() + && self.selected_launcher.as_ref().unwrap() == launcher, + launcher, + )) + .clicked() + { + self.selected_launcher = Some(launcher.to_string()); + } } - } - }); - for launcher in &self.all_launchers { - if ui - .add(egui::SelectableLabel::new( - self.selected_launcher.is_some() - && self.selected_launcher.as_ref().unwrap() == launcher, - launcher, - )) - .clicked() - { - self.selected_launcher = Some(launcher.to_string()); - } - } - ui.horizontal(|ui| { - ui.label("IWADs"); - if ui.button("Add IWAD").clicked() { - if let Some(path) = rfd::FileDialog::new().pick_file() { - self.all_iwads.push(WadInfo { - name: path.display().to_string(), - path: path, - }); + }); + ui.vertical(|ui| { + ui.horizontal(|ui| { + ui.label("IWADs"); + + }); + for (pos, iwad) in self.all_iwads.iter().enumerate() { + if ui + .add(egui::SelectableLabel::new( + self.selected_iwad.is_some() + && *self.selected_iwad.as_ref().unwrap() == pos, + &iwad.name, + )) + .clicked() + { + self.selected_iwad = Some(pos); + } } - } - }); - for (pos, iwad) in self.all_iwads.iter().enumerate() { - if ui - .add(egui::SelectableLabel::new( - self.selected_iwad.is_some() - && *self.selected_iwad.as_ref().unwrap() == pos, - &iwad.name, - )) - .clicked() - { - self.selected_iwad = Some(pos); - } - } - ui.horizontal(|ui| { - ui.label("PWADs and Mods"); - if ui.button("Add PWAD or Mod").clicked() { - if let Some(path) = rfd::FileDialog::new().pick_file() { - self.all_pwads.push(WadInfo { - path: path.clone(), - name: path.display().to_string(), - }); + }); + ui.vertical(|ui| { + ui.label("PWADs and Mods"); + for (pos, pwad) in self.all_pwads.iter().enumerate() { + if ui + .add(egui::SelectableLabel::new( + self.selected_pwads.contains(&pos), + &pwad.name, + )) + .clicked() + { + self.selected_pwads.push(pos); + } } - } + }); + ui.vertical(|ui| { + ui.label("Add WADs etc"); + if ui.button("Add Launcher").clicked() { + if let Some(path) = rfd::FileDialog::new().pick_file() { + self.all_launchers.push(path.display().to_string()); + } + } + if ui.button("Add IWAD").clicked() { + if let Some(path) = rfd::FileDialog::new().pick_file() { + self.all_iwads.push(WadInfo { + name: path.display().to_string(), + path: path, + }); + } + } + if ui.button("Add PWAD or Mod").clicked() { + if let Some(path) = rfd::FileDialog::new().pick_file() { + self.all_pwads.push(WadInfo { + path: path.clone(), + name: path.display().to_string(), + }); + } + } + }); }); - for (pos, pwad) in self.all_pwads.iter().enumerate() { - if ui - .add(egui::SelectableLabel::new( - self.selected_pwads.contains(&pos), - &pwad.name, - )) - .clicked() - { - self.selected_pwads.push(pos); - } - } ui.label("Command"); - ui.horizontal(|ui| { + ui.horizontal_wrapped(|ui| { // I don't actually think using SelectableLabel is correct here - // but it'll at least do the highlighting when hovered nicely if let Some(l) = &self.selected_launcher { @@ -141,12 +150,17 @@ impl eframe::App for RustDoomLauncher { ui.label("Select an iwad plz"); } // This feels ver much more C-like, but I think it works? + // Probably should have a little bit more checking around the unwrap calls let mut pos = 0_usize; while pos < self.selected_pwads.len() { if ui .add(egui::SelectableLabel::new( false, - &self.all_pwads.get(*self.selected_pwads.get(pos).unwrap()).unwrap().name, + &self + .all_pwads + .get(*self.selected_pwads.get(pos).unwrap()) + .unwrap() + .name, )) .clicked() {