diff --git a/Cargo.toml b/Cargo.toml index 18f3b9f..e3075c8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,3 +7,4 @@ edition = "2021" [dependencies] eframe = "0.21.3" +rfd = "*" \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index b56ec6c..8029c50 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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; }