mirror of
https://github.com/FranLMSP/snes.git
synced 2026-08-03 08:30:01 -04:00
enable debugging window
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
pub struct DebugOptions {
|
||||
pub enable_debugging: bool,
|
||||
pub show_debug_options_window: bool,
|
||||
}
|
||||
|
||||
impl DebugOptions {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
enable_debugging: true,
|
||||
show_debug_options_window: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
pub mod debug_options;
|
||||
pub mod state;
|
||||
pub use state::AppState;
|
||||
@@ -0,0 +1,21 @@
|
||||
use crate::emu_state::debug_options::DebugOptions;
|
||||
|
||||
|
||||
pub struct AppState {
|
||||
pub debug_options: DebugOptions,
|
||||
}
|
||||
|
||||
impl AppState {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
debug_options: DebugOptions::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl Default for AppState {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
use eframe::egui;
|
||||
|
||||
use crate::emu_state::AppState;
|
||||
|
||||
|
||||
pub fn build_debug_window(ctx: &egui::Context, app_state: &mut AppState) {
|
||||
egui::Window::new("Debug")
|
||||
.open(&mut app_state.debug_options.show_debug_options_window)
|
||||
.show(ctx, |ui| {
|
||||
ui.checkbox(
|
||||
&mut app_state.debug_options.enable_debugging,
|
||||
"Enable debugging",
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
pub mod debug;
|
||||
|
||||
pub use debug::build_debug_window;
|
||||
@@ -1,7 +1,7 @@
|
||||
use eframe::egui;
|
||||
|
||||
|
||||
pub fn build_game_window(ctx: &egui::Context, ui: &mut egui::Ui) {
|
||||
pub fn build_game_window(ctx: &egui::Context) {
|
||||
egui::Window::new("Game").show(ctx, |ui| {
|
||||
ui.label("Hello World!");
|
||||
render_framebuffer(ctx, ui, &[]);
|
||||
@@ -9,7 +9,7 @@ pub fn build_game_window(ctx: &egui::Context, ui: &mut egui::Ui) {
|
||||
}
|
||||
|
||||
|
||||
fn render_framebuffer(ctx: &egui::Context, ui: &mut egui::Ui, framebuffer: &[u8]) {
|
||||
fn render_framebuffer(ctx: &egui::Context, ui: &mut egui::Ui, _framebuffer: &[u8]) {
|
||||
ui.painter().rect_filled(
|
||||
ctx.available_rect(),
|
||||
egui::Rounding::ZERO,
|
||||
@@ -1,8 +1,10 @@
|
||||
use eframe::egui;
|
||||
use snes_core::emulator::Emulator;
|
||||
|
||||
use crate::emu_state::AppState;
|
||||
|
||||
pub fn build_menu_bar(emulator: &mut Emulator, ui: &mut egui::Ui) {
|
||||
|
||||
pub fn build_menu_bar(emulator: &mut Emulator, ui: &mut egui::Ui, state: &mut AppState) {
|
||||
egui::menu::bar(ui, |ui| {
|
||||
ui.menu_button("Emulator", |ui| {
|
||||
if ui.button("Load ROM file").clicked() {
|
||||
@@ -17,6 +19,7 @@ pub fn build_menu_bar(emulator: &mut Emulator, ui: &mut egui::Ui) {
|
||||
});
|
||||
ui.menu_button("Debug", |ui| {
|
||||
if ui.button("Show Debug Menu").clicked() {
|
||||
state.debug_options.show_debug_options_window = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,2 +1,3 @@
|
||||
pub mod game;
|
||||
pub mod menu;
|
||||
pub mod debug;
|
||||
@@ -1,12 +1,14 @@
|
||||
use eframe::egui;
|
||||
use snes_core::emulator::Emulator;
|
||||
|
||||
pub mod ui;
|
||||
mod emu_ui;
|
||||
mod emu_state;
|
||||
|
||||
|
||||
#[derive(Default)]
|
||||
struct SnesEmulatorApp {
|
||||
emulator: Emulator,
|
||||
state: emu_state::AppState,
|
||||
}
|
||||
|
||||
impl SnesEmulatorApp {
|
||||
@@ -18,10 +20,11 @@ impl SnesEmulatorApp {
|
||||
impl eframe::App for SnesEmulatorApp {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
ui::menu::build_menu_bar(&mut self.emulator, ui);
|
||||
emu_ui::menu::build_menu_bar(&mut self.emulator, ui, &mut self.state);
|
||||
ui.separator();
|
||||
// ui::game::build_game_window(ctx, ui);
|
||||
// ui::game::build_game_window(ctx);
|
||||
});
|
||||
emu_ui::debug::build_debug_window(ctx, &mut self.state);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user