add step button
This commit is contained in:
parent
28a54a231b
commit
2c27d660b3
2 changed files with 21 additions and 13 deletions
BIN
assets/step.png
Normal file
BIN
assets/step.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 191 B |
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue