Shuffled around the layout

This commit is contained in:
2023-06-02 17:19:52 +01:00
parent 29eed3aad6
commit 757867754e

View File

@@ -50,14 +50,10 @@ impl eframe::App for RustDoomLauncher {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::containers::panel::CentralPanel::default().show(ctx, |ui| { egui::containers::panel::CentralPanel::default().show(ctx, |ui| {
ui.heading("RustDoomLauncher"); ui.heading("RustDoomLauncher");
ui.horizontal(|ui| { ui.horizontal_wrapped(|ui| {
ui.vertical(|ui| {
ui.label("Launchers"); 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());
}
}
});
for launcher in &self.all_launchers { for launcher in &self.all_launchers {
if ui if ui
.add(egui::SelectableLabel::new( .add(egui::SelectableLabel::new(
@@ -70,16 +66,11 @@ impl eframe::App for RustDoomLauncher {
self.selected_launcher = Some(launcher.to_string()); self.selected_launcher = Some(launcher.to_string());
} }
} }
});
ui.vertical(|ui| {
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.label("IWADs"); 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,
});
}
}
}); });
for (pos, iwad) in self.all_iwads.iter().enumerate() { for (pos, iwad) in self.all_iwads.iter().enumerate() {
if ui if ui
@@ -93,17 +84,9 @@ impl eframe::App for RustDoomLauncher {
self.selected_iwad = Some(pos); self.selected_iwad = Some(pos);
} }
} }
ui.horizontal(|ui| { });
ui.vertical(|ui| {
ui.label("PWADs and Mods"); 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(),
});
}
}
});
for (pos, pwad) in self.all_pwads.iter().enumerate() { for (pos, pwad) in self.all_pwads.iter().enumerate() {
if ui if ui
.add(egui::SelectableLabel::new( .add(egui::SelectableLabel::new(
@@ -115,8 +98,34 @@ impl eframe::App for RustDoomLauncher {
self.selected_pwads.push(pos); 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(),
});
}
}
});
});
ui.label("Command"); ui.label("Command");
ui.horizontal(|ui| { ui.horizontal_wrapped(|ui| {
// I don't actually think using SelectableLabel is correct here - // I don't actually think using SelectableLabel is correct here -
// but it'll at least do the highlighting when hovered nicely // but it'll at least do the highlighting when hovered nicely
if let Some(l) = &self.selected_launcher { if let Some(l) = &self.selected_launcher {
@@ -141,12 +150,17 @@ impl eframe::App for RustDoomLauncher {
ui.label("Select an iwad plz"); ui.label("Select an iwad plz");
} }
// This feels ver much more C-like, but I think it works? // 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; let mut pos = 0_usize;
while pos < self.selected_pwads.len() { while pos < self.selected_pwads.len() {
if ui if ui
.add(egui::SelectableLabel::new( .add(egui::SelectableLabel::new(
false, 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() .clicked()
{ {