Support playing roms by dragging into window
This commit is contained in:
parent
4f3dc85bb4
commit
1d4c6c9e88
|
|
@ -424,6 +424,9 @@ impl ApplicationHandler<UserEvent> for Application {
|
||||||
{
|
{
|
||||||
self.controllers.handle_key_event(&event);
|
self.controllers.handle_key_event(&event);
|
||||||
}
|
}
|
||||||
|
WindowEvent::DroppedFile(path) => {
|
||||||
|
self.app.handle_dropped_file(viewport_id, path);
|
||||||
|
}
|
||||||
WindowEvent::Focused(new_focused) => {
|
WindowEvent::Focused(new_focused) => {
|
||||||
self.focused = new_focused.then_some(viewport_id);
|
self.focused = new_focused.then_some(viewport_id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use std::sync::Arc;
|
use std::{path::PathBuf, sync::Arc};
|
||||||
|
|
||||||
pub use about::AboutWindow;
|
pub use about::AboutWindow;
|
||||||
use egui::{Ui, ViewportBuilder};
|
use egui::{Ui, ViewportBuilder};
|
||||||
|
|
@ -47,6 +47,10 @@ pub trait AppWindow {
|
||||||
let _ = event;
|
let _ = event;
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
fn handle_dropped_file(&mut self, path: PathBuf) -> bool {
|
||||||
|
let _ = path;
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct InitArgs<'a> {
|
pub struct InitArgs<'a> {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
use std::{
|
use std::{
|
||||||
ops::{Deref, DerefMut},
|
ops::{Deref, DerefMut},
|
||||||
|
path::PathBuf,
|
||||||
sync::{Arc, Mutex, atomic::AtomicBool, mpsc},
|
sync::{Arc, Mutex, atomic::AtomicBool, mpsc},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
@ -214,6 +215,10 @@ impl GameWindow {
|
||||||
self.handle_event(viewport_id, |window| window.handle_gamepad_event(event))
|
self.handle_event(viewport_id, |window| window.handle_gamepad_event(event))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn handle_dropped_file(&mut self, viewport_id: ViewportId, path: PathBuf) -> bool {
|
||||||
|
self.handle_event(viewport_id, |window| window.handle_dropped_file(path))
|
||||||
|
}
|
||||||
|
|
||||||
fn handle_event<F, R>(&mut self, viewport_id: ViewportId, cb: F) -> R
|
fn handle_event<F, R>(&mut self, viewport_id: ViewportId, cb: F) -> R
|
||||||
where
|
where
|
||||||
F: FnOnce(&mut dyn AppWindow) -> R,
|
F: FnOnce(&mut dyn AppWindow) -> R,
|
||||||
|
|
@ -765,6 +770,12 @@ impl AppWindow for GameWindow {
|
||||||
}
|
}
|
||||||
self.file_picker.set_window(args.window);
|
self.file_picker.set_window(args.window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn handle_dropped_file(&mut self, path: PathBuf) -> bool {
|
||||||
|
self.client
|
||||||
|
.send_command(EmulatorCommand::LoadGame(self.sim_id, path));
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for GameWindow {
|
impl Drop for GameWindow {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue