Added Drag and Drop files

And fixed the add stuff window not being able to be closed
This commit is contained in:
2023-07-10 20:54:29 +01:00
parent 88e6033b99
commit 745c560409

View File

@@ -104,6 +104,7 @@ impl RustDoomLauncher {
} }
Ok((launcher, command)) => { Ok((launcher, command)) => {
// Note to self, don't hit launch button when running from emacs // Note to self, don't hit launch button when running from emacs
// if you do, close it and hold down C+g
let result = Command::new(launcher).args(command).spawn(); let result = Command::new(launcher).args(command).spawn();
match result { match result {
Err(e) => panic!("{}", e), Err(e) => panic!("{}", e),
@@ -399,8 +400,9 @@ impl eframe::App for RustDoomLauncher {
}); });
} }
if self.add_stuff_window_displayed { egui::Window::new("Add WAD or Launcher")
egui::Window::new("Add WAD or Launcher").show(ctx, |ui| { .open(&mut self.add_stuff_window_displayed)
.show(ctx, |ui| {
ui.horizontal(|ui| { ui.horizontal(|ui| {
let name_label = ui.label("Name"); let name_label = ui.label("Name");
ui.text_edit_singleline(&mut self.add_name) ui.text_edit_singleline(&mut self.add_name)
@@ -477,6 +479,25 @@ impl eframe::App for RustDoomLauncher {
} }
} }
}); });
ctx.input(|i| {
if !i.raw.dropped_files.is_empty() {
let dropped_files = i.raw.dropped_files.clone();
match dropped_files.len() {
1 => {
self.selected_file_path = dropped_files[0].path.clone().unwrap();
self.add_stuff_window_displayed = true;
} }
_ => {
MessageDialog::new()
.set_type(MessageType::Error)
.set_title("I can't let you do that")
.set_text(&format!("Multiple files not supported"))
.show_alert()
.unwrap();
}
}
}
});
} }
} }