Shuffled around the layout
This commit is contained in:
68
src/main.rs
68
src/main.rs
@@ -50,14 +50,10 @@ 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.horizontal_wrapped(|ui| {
|
||||
ui.vertical(|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());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
for launcher in &self.all_launchers {
|
||||
if ui
|
||||
.add(egui::SelectableLabel::new(
|
||||
@@ -70,16 +66,11 @@ impl eframe::App for RustDoomLauncher {
|
||||
self.selected_launcher = Some(launcher.to_string());
|
||||
}
|
||||
}
|
||||
});
|
||||
ui.vertical(|ui| {
|
||||
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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
for (pos, iwad) in self.all_iwads.iter().enumerate() {
|
||||
if ui
|
||||
@@ -93,17 +84,9 @@ impl eframe::App for RustDoomLauncher {
|
||||
self.selected_iwad = Some(pos);
|
||||
}
|
||||
}
|
||||
ui.horizontal(|ui| {
|
||||
});
|
||||
ui.vertical(|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(),
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
for (pos, pwad) in self.all_pwads.iter().enumerate() {
|
||||
if ui
|
||||
.add(egui::SelectableLabel::new(
|
||||
@@ -115,8 +98,34 @@ impl eframe::App for RustDoomLauncher {
|
||||
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.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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user