First pass of character data viewer

This commit is contained in:
2025-02-15 18:29:33 -05:00
parent 5f17469dc2
commit 6c9265cb78
6 changed files with 654 additions and 2 deletions
+20 -2
View File
@@ -19,7 +19,10 @@ use crate::{
emulator::{EmulatorClient, EmulatorCommand, SimId},
input::MappingProvider,
persistence::Persistence,
window::{AboutWindow, AppWindow, GameWindow, GdbServerWindow, InputWindow},
vram::VramLoader,
window::{
AboutWindow, AppWindow, CharacterDataWindow, GameWindow, GdbServerWindow, InputWindow,
},
};
fn load_icon() -> anyhow::Result<IconData> {
@@ -36,6 +39,7 @@ fn load_icon() -> anyhow::Result<IconData> {
pub struct Application {
icon: Option<Arc<IconData>>,
wgpu: WgpuState,
vram: Arc<VramLoader>,
client: EmulatorClient,
proxy: EventLoopProxy<UserEvent>,
mappings: MappingProvider,
@@ -65,6 +69,7 @@ impl Application {
Self {
icon,
wgpu,
vram: Arc::new(VramLoader::new(client.clone())),
client,
proxy,
mappings,
@@ -83,7 +88,13 @@ impl Application {
}
self.viewports.insert(
viewport_id,
Viewport::new(event_loop, &self.wgpu, self.icon.clone(), window),
Viewport::new(
event_loop,
&self.wgpu,
self.icon.clone(),
self.vram.clone(),
window,
),
);
}
}
@@ -197,6 +208,10 @@ impl ApplicationHandler<UserEvent> for Application {
let about = AboutWindow;
self.open(event_loop, Box::new(about));
}
UserEvent::OpenCharacterData(sim_id) => {
let vram = CharacterDataWindow::new(sim_id);
self.open(event_loop, Box::new(vram));
}
UserEvent::OpenDebugger(sim_id) => {
let debugger =
GdbServerWindow::new(sim_id, self.client.clone(), self.proxy.clone());
@@ -308,6 +323,7 @@ impl Viewport {
event_loop: &ActiveEventLoop,
wgpu: &WgpuState,
icon: Option<Arc<IconData>>,
vram: Arc<VramLoader>,
mut app: Box<dyn AppWindow>,
) -> Self {
let ctx = Context::default();
@@ -329,6 +345,7 @@ impl Viewport {
s.visuals.menu_rounding = Default::default();
});
egui_extras::install_image_loaders(&ctx);
ctx.add_image_loader(vram);
let wgpu_config = egui_wgpu::WgpuConfiguration {
present_mode: wgpu::PresentMode::AutoNoVsync,
@@ -455,6 +472,7 @@ impl Drop for Viewport {
pub enum UserEvent {
GamepadEvent(gilrs::Event),
OpenAbout,
OpenCharacterData(SimId),
OpenDebugger(SimId),
OpenInput,
OpenPlayer2,