diff --git a/assets/step.png b/assets/step.png new file mode 100644 index 0000000..ddb7dc9 Binary files /dev/null and b/assets/step.png differ diff --git a/src/editor.rs b/src/editor.rs index 869a708..84f05b7 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -128,6 +128,18 @@ impl Editor { self.machine.set_board(self.source_board.clone()); } + fn step_pressed(&mut self){ + match self.sim_state { + SimState::Editing => { + self.start_sim(); + self.step(); + } + SimState::Running => (), + SimState::Stepping => self.step(), + } + self.sim_state = SimState::Stepping; + } + fn step(&mut self) { self.machine.step(); if !self.level.outputs().is_empty() @@ -211,15 +223,7 @@ impl Editor { } } if rl.is_key_pressed(KeyboardKey::KEY_SPACE) { - match self.sim_state { - SimState::Editing => { - self.start_sim(); - self.step(); - } - SimState::Running => (), - SimState::Stepping => self.step(), - } - self.sim_state = SimState::Stepping; + self.step_pressed() } if rl.is_key_pressed(KeyboardKey::KEY_ENTER) { match self.sim_state { @@ -392,24 +396,28 @@ impl Editor { self.sim_state = SimState::Stepping; } draw_scaled_texture(d, textures.get("pause"), 260, 4, 2.); - if simple_button(d, 260 + 36, 4, 32, 32) { + if simple_button(d, 296, 4, 32, 32) { self.sim_state = SimState::Editing; self.complete_popup = Popup::Start; } - draw_scaled_texture(d, textures.get("stop"), 260 + 36, 4, 2.); + draw_scaled_texture(d, textures.get("stop"), 296, 4, 2.); } SimState::Stepping => { if simple_button(d, 260, 4, 32, 32) { self.sim_state = SimState::Running; } draw_scaled_texture(d, textures.get("play"), 260, 4, 2.); - if simple_button(d, 260 + 36, 4, 32, 32) { + if simple_button(d, 296, 4, 32, 32) { self.sim_state = SimState::Editing; self.complete_popup = Popup::Start; } - draw_scaled_texture(d, textures.get("stop"), 260 + 36, 4, 2.); + draw_scaled_texture(d, textures.get("stop"), 296, 4, 2.); } } + if simple_button(d, 332, 4, 32, 32) { + self.step_pressed(); + } + draw_scaled_texture(d, textures.get("step"), 332, 4, 2.); let mut input_text = String::from_utf8_lossy(self.machine.input()).to_string(); let width = d.get_screen_width();