hide popup on exit without stopping simulation, pause sim while popup is open
This commit is contained in:
parent
c5328126b3
commit
8863912179
1 changed files with 18 additions and 6 deletions
|
@ -81,7 +81,7 @@ enum Action {
|
|||
SetArea(ResizeDeltas, Pos, Board, Board),
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Clone, Copy)]
|
||||
enum Popup {
|
||||
None,
|
||||
Success,
|
||||
|
@ -445,15 +445,21 @@ impl Editor {
|
|||
pub fn update(&mut self, rl: &RaylibHandle) {
|
||||
self.tooltip.init_frame(rl);
|
||||
self.mouse = MouseInput::get(rl);
|
||||
if !matches!(self.popup, Popup::None | Popup::Dismissed) {
|
||||
if !self.popup.is_hidden() {
|
||||
self.mouse.clear();
|
||||
}
|
||||
|
||||
if rl.is_key_pressed(KeyboardKey::KEY_ESCAPE) {
|
||||
if self.popup.is_hidden() {
|
||||
self.sim_state = SimState::Editing;
|
||||
self.popup = Popup::None;
|
||||
}
|
||||
if self.sim_state == SimState::Running {
|
||||
self.popup = match self.popup {
|
||||
Popup::Success | Popup::Failure => Popup::Dismissed,
|
||||
_ => Popup::None,
|
||||
};
|
||||
}
|
||||
if self.sim_state == SimState::Running && self.popup.is_hidden() {
|
||||
self.time_since_step += rl.get_frame_time();
|
||||
let step_size = 1. / (1 << self.sim_speed) as f32;
|
||||
let mut steps_taken = 0;
|
||||
|
@ -586,7 +592,7 @@ impl Editor {
|
|||
|
||||
self.mouse = MouseInput::get(d);
|
||||
|
||||
if !matches!(self.popup, Popup::None | Popup::Dismissed) {
|
||||
if !self.popup.is_hidden() {
|
||||
self.tooltip.reset();
|
||||
d.draw_rectangle(
|
||||
0,
|
||||
|
@ -1391,3 +1397,9 @@ fn get_blueprints() -> Vec<Blueprint> {
|
|||
blueprints.sort_by(|a, b| a.name.cmp(&b.name));
|
||||
blueprints
|
||||
}
|
||||
|
||||
impl Popup {
|
||||
fn is_hidden(self) -> bool {
|
||||
matches!(self, Popup::None | Popup::Dismissed)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue