Initial commit

This commit is contained in:
2024-07-22 14:07:35 -04:00
commit ceb62d2c53
16 changed files with 3245 additions and 0 deletions
+79
View File
@@ -0,0 +1,79 @@
use easy_imgui::{Ui, UiBuilder};
use easy_imgui_window::{MainWindow, MainWindowWithRenderer};
use winit::{application::ApplicationHandler, event_loop::ActiveEventLoop, window::{Window, WindowAttributes}};
pub struct Chip8Display {
pub window: MainWindowWithRenderer,
}
impl Chip8Display {
pub fn new(event_loop: &ActiveEventLoop) -> Chip8Display {
Chip8Display { window: MainWindowWithRenderer::new(
MainWindow::new::<()>(&event_loop, Window::default_attributes().with_title("Chip8 Display")).unwrap())
}
}
pub fn render<M>(ui: &Ui<M>) {
}
}
impl UiBuilder for Chip8AppHandler {
fn do_ui(&mut self, ui: &Ui<Self>) {
ui.text("This is where the Chip8 UI Goes");
ui.text("Controls for Start/Stop/Load/Run Maybe?");
}
}
#[derive(Default)]
pub struct Chip8AppHandler {
pub windows: Vec<MainWindowWithRenderer>,
// pub display: Chip8Display
}
impl ApplicationHandler for Chip8AppHandler {
fn suspended(&mut self, _event_loop: &ActiveEventLoop) {
self.windows.clear();
}
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
self.windows.push(Chip8Display::new(event_loop).window);
}
fn window_event(
&mut self,
event_loop: &ActiveEventLoop,
window_id: winit::window::WindowId,
event: winit::event::WindowEvent,
) {
for window in &mut self.windows {
if window.main_window().window().id() != window_id {
continue;
}
let res = window.window_event(
&mut self,
&event,
easy_imgui_window::EventFlags::empty(),
);
if res.window_closed {
event_loop.exit();
}
break;
}
}
fn new_events(&mut self, _event_loop: &ActiveEventLoop, _cause: winit::event::StartCause) {
for window in &mut self.windows {
window.new_events();
}
}
fn about_to_wait(&mut self, _event_loop: &ActiveEventLoop) {
for window in &mut self.windows {
window.about_to_wait();
}
}
}