No debugging unless the game is running

This commit is contained in:
2025-01-17 22:00:46 -05:00
parent f031bb17b2
commit 17d3811124
4 changed files with 54 additions and 14 deletions
+6 -2
View File
@@ -3,7 +3,7 @@ use winit::event_loop::EventLoopProxy;
use crate::{
app::UserEvent,
emulator::{EmulatorClient, SimId},
emulator::{EmulatorClient, SimId, SimState},
gdbserver::{GdbServer, GdbServerStatus},
};
@@ -11,6 +11,7 @@ use super::AppWindow;
pub struct GdbServerWindow {
sim_id: SimId,
client: EmulatorClient,
port_str: String,
connected: bool,
quit_on_disconnect: bool,
@@ -22,6 +23,7 @@ impl GdbServerWindow {
pub fn new(sim_id: SimId, client: EmulatorClient, proxy: EventLoopProxy<UserEvent>) -> Self {
Self {
sim_id,
client: client.clone(),
port_str: (8080 + sim_id.to_index()).to_string(),
connected: false,
quit_on_disconnect: false,
@@ -78,7 +80,9 @@ impl AppWindow for GdbServerWindow {
self.connected = false;
}
let start_button = Button::new("Start");
if ui.add_enabled(port_num.is_some(), start_button).clicked() {
let can_start =
port_num.is_some() && self.client.sim_state(self.sim_id) == SimState::Ready;
if ui.add_enabled(can_start, start_button).clicked() {
let port = port_num.unwrap();
self.server.start(port);
self.connected = true;