mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-28 20:29:04 +03:00
change pause/resume button to say the appropriate thing, now that it's easy
This commit is contained in:
parent
7c3a26fed8
commit
98d7f26f2d
@ -33,7 +33,7 @@ impl SpeedControls {
|
|||||||
vec![vec![
|
vec![vec![
|
||||||
(hotkey(Key::LeftBracket), "slow down"),
|
(hotkey(Key::LeftBracket), "slow down"),
|
||||||
(hotkey(Key::RightBracket), "speed up"),
|
(hotkey(Key::RightBracket), "speed up"),
|
||||||
(hotkey(Key::Space), "pause/resume"),
|
(hotkey(Key::Space), "resume"),
|
||||||
]],
|
]],
|
||||||
ctx,
|
ctx,
|
||||||
)
|
)
|
||||||
@ -80,7 +80,7 @@ impl SpeedControls {
|
|||||||
|
|
||||||
match self.state {
|
match self.state {
|
||||||
State::Paused => {
|
State::Paused => {
|
||||||
if self.menu.action("pause/resume") {
|
if self.menu.consume_action("resume", ctx) {
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
self.state = State::Running {
|
self.state = State::Running {
|
||||||
last_step: now,
|
last_step: now,
|
||||||
@ -88,6 +88,7 @@ impl SpeedControls {
|
|||||||
last_measurement: now,
|
last_measurement: now,
|
||||||
last_measurement_sim: current_sim_time,
|
last_measurement_sim: current_sim_time,
|
||||||
};
|
};
|
||||||
|
self.menu.add_action(hotkey(Key::Space), "pause", ctx);
|
||||||
// Sorta hack to trigger EventLoopMode::Animation.
|
// Sorta hack to trigger EventLoopMode::Animation.
|
||||||
return Some(Duration::ZERO);
|
return Some(Duration::ZERO);
|
||||||
}
|
}
|
||||||
@ -98,8 +99,9 @@ impl SpeedControls {
|
|||||||
ref mut last_measurement,
|
ref mut last_measurement,
|
||||||
ref mut last_measurement_sim,
|
ref mut last_measurement_sim,
|
||||||
} => {
|
} => {
|
||||||
if self.menu.action("pause/resume") {
|
if self.menu.consume_action("pause", ctx) {
|
||||||
self.state = State::Paused;
|
self.state = State::Paused;
|
||||||
|
self.menu.add_action(hotkey(Key::Space), "resume", ctx);
|
||||||
} else if ctx.input.nonblocking_is_update_event() {
|
} else if ctx.input.nonblocking_is_update_event() {
|
||||||
ctx.input.use_update_event();
|
ctx.input.use_update_event();
|
||||||
let dt = Duration::seconds(elapsed_seconds(*last_step)) * desired_speed;
|
let dt = Duration::seconds(elapsed_seconds(*last_step)) * desired_speed;
|
||||||
|
Loading…
Reference in New Issue
Block a user