Added file selection

Still need to do launcher
This commit is contained in:
2023-05-31 23:13:49 +01:00
parent b871c48c60
commit 5a8d57ee4f
2 changed files with 24 additions and 22 deletions

View File

@@ -25,16 +25,8 @@ impl Default for RustDoomLauncher {
fn default() -> Self {
Self {
launchers: vec!["GZDoom 1.9".to_string(), "PRBoom+".to_string()],
all_iwads: vec![
"DOOM2.WAD".to_string(),
"DOOM.WAD".to_string(),
"FREEDOOM.WAD".to_string(),
],
all_pwads: vec![
"DOOM2.WAD".to_string(),
"DOOM.WAD".to_string(),
"FREEDOOM.WAD".to_string(),
],
all_iwads: Vec::new(),
all_pwads: Vec::new(),
selected_launcher: None,
selected_iwad: None,
selected_pwads: Vec::new(),
@@ -49,9 +41,7 @@ impl eframe::App for RustDoomLauncher {
ui.horizontal(|ui| {
ui.label("Launcers");
if ui.button("Add Launcher").clicked() {
// Open file selector
// Add to the launchers list
// done?
todo!();
}
});
for launcher in &self.launchers {
@@ -69,9 +59,11 @@ impl eframe::App for RustDoomLauncher {
ui.horizontal(|ui| {
ui.label("IWADs");
if ui.button("Add IWAD").clicked() {
// Open file selector
// Add to the IWADS list
// done?
if let Some(paths) = rfd::FileDialog::new().pick_files() {
for path in paths {
self.all_iwads.push(path.display().to_string());
}
}
}
});
for iwad in &self.all_iwads {
@@ -89,9 +81,11 @@ impl eframe::App for RustDoomLauncher {
ui.horizontal(|ui| {
ui.label("PWADs");
if ui.button("Add PWAD").clicked() {
// Open file selector
// Add to the PWADS list
// done?
if let Some(paths) = rfd::FileDialog::new().pick_files() {
for path in paths {
self.all_pwads.push(path.display().to_string());
}
}
}
});
for pwad in &self.all_pwads {
@@ -107,7 +101,8 @@ impl eframe::App for RustDoomLauncher {
}
ui.label("Command");
ui.horizontal(|ui| {
// I don't actually think using SelectableLabel is correct here - but it'll at least do the highlighting when hovered correctly
// 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 {
if ui.add(egui::SelectableLabel::new(false, l)).clicked() {
self.selected_launcher = None;
@@ -123,9 +118,15 @@ impl eframe::App for RustDoomLauncher {
ui.label("Select an iwad plz");
}
// This feels ver much more C-like, but I think it works?
let mut pos = 0 as usize;
let mut pos = 0_usize;
while pos < self.selected_pwads.len() {
if ui.add(egui::SelectableLabel::new(false, self.selected_pwads[pos].clone())).clicked() {
if ui
.add(egui::SelectableLabel::new(
false,
self.selected_pwads[pos].clone(),
))
.clicked()
{
self.selected_pwads.remove(pos);
continue;
}