Shuffled around the layout
This commit is contained in:
140
src/main.rs
140
src/main.rs
@@ -50,73 +50,82 @@ 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.label("Launchers");
|
ui.vertical(|ui| {
|
||||||
if ui.button("Add Launcher").clicked() {
|
ui.label("Launchers");
|
||||||
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(
|
||||||
|
self.selected_launcher.is_some()
|
||||||
|
&& self.selected_launcher.as_ref().unwrap() == launcher,
|
||||||
|
launcher,
|
||||||
|
))
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
self.selected_launcher = Some(launcher.to_string());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
ui.vertical(|ui| {
|
||||||
for launcher in &self.all_launchers {
|
ui.horizontal(|ui| {
|
||||||
if ui
|
ui.label("IWADs");
|
||||||
.add(egui::SelectableLabel::new(
|
|
||||||
self.selected_launcher.is_some()
|
});
|
||||||
&& self.selected_launcher.as_ref().unwrap() == launcher,
|
for (pos, iwad) in self.all_iwads.iter().enumerate() {
|
||||||
launcher,
|
if ui
|
||||||
))
|
.add(egui::SelectableLabel::new(
|
||||||
.clicked()
|
self.selected_iwad.is_some()
|
||||||
{
|
&& *self.selected_iwad.as_ref().unwrap() == pos,
|
||||||
self.selected_launcher = Some(launcher.to_string());
|
&iwad.name,
|
||||||
}
|
))
|
||||||
}
|
.clicked()
|
||||||
ui.horizontal(|ui| {
|
{
|
||||||
ui.label("IWADs");
|
self.selected_iwad = Some(pos);
|
||||||
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| {
|
||||||
for (pos, iwad) in self.all_iwads.iter().enumerate() {
|
ui.label("PWADs and Mods");
|
||||||
if ui
|
for (pos, pwad) in self.all_pwads.iter().enumerate() {
|
||||||
.add(egui::SelectableLabel::new(
|
if ui
|
||||||
self.selected_iwad.is_some()
|
.add(egui::SelectableLabel::new(
|
||||||
&& *self.selected_iwad.as_ref().unwrap() == pos,
|
self.selected_pwads.contains(&pos),
|
||||||
&iwad.name,
|
&pwad.name,
|
||||||
))
|
))
|
||||||
.clicked()
|
.clicked()
|
||||||
{
|
{
|
||||||
self.selected_iwad = Some(pos);
|
self.selected_pwads.push(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("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.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()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user