diff --git a/game/src/sandbox/gameplay/actdev.rs b/game/src/sandbox/gameplay/actdev.rs index 96a6615656..02240abe7c 100644 --- a/game/src/sandbox/gameplay/actdev.rs +++ b/game/src/sandbox/gameplay/actdev.rs @@ -13,13 +13,14 @@ use crate::common::jump_to_time_upon_startup; use crate::edit::EditMode; use crate::info::{OpenTrip, Tab}; use crate::sandbox::gameplay::{GameplayMode, GameplayState}; -use crate::sandbox::{Actions, SandboxControls, SandboxMode}; +use crate::sandbox::{Actions, SandboxControls, SandboxMode, SpeedSetting}; /// A gameplay mode with specific controls for integration with /// https://cyipt.github.io/acton/articles/the-actdev-project.html. pub struct Actdev { top_center: Panel, scenario_name: String, + once: bool, } impl Actdev { @@ -27,6 +28,7 @@ impl Actdev { Box::new(Actdev { top_center: Panel::empty(ctx), scenario_name, + once: true, }) } } @@ -39,6 +41,15 @@ impl GameplayState for Actdev { controls: &mut SandboxControls, actions: &mut Actions, ) -> Option { + if self.once { + self.once = false; + controls + .speed + .as_mut() + .unwrap() + .resume(ctx, app, SpeedSetting::Faster); + } + match self.top_center.event(ctx) { Outcome::Clicked(x) => match x.as_ref() { "change scenario" => { @@ -175,11 +186,11 @@ impl GameplayState for Actdev { .build_def(ctx), ctx.style() .btn_plain - .icon_text("system/assets/meters/bike.svg", "Cycling activity") + .icon_text("system/assets/meters/pedestrian.svg", "Walking activity") .build_def(ctx), ctx.style() .btn_plain - .icon_text("system/assets/meters/pedestrian.svg", "Walking activity") + .icon_text("system/assets/meters/bike.svg", "Cycling activity") .build_def(ctx), ]), ]); diff --git a/game/src/sandbox/mod.rs b/game/src/sandbox/mod.rs index bb656467cb..40b8b06a4b 100644 --- a/game/src/sandbox/mod.rs +++ b/game/src/sandbox/mod.rs @@ -17,7 +17,7 @@ use widgetry::{ pub use self::gameplay::{spawn_agents_around, GameplayMode, TutorialPointer, TutorialState}; use self::misc_tools::{RoutePreview, TrafficRecorder}; -pub use self::speed::{SpeedControls, TimePanel}; +pub use self::speed::{SpeedControls, SpeedSetting, TimePanel}; pub use self::time_warp::TimeWarpScreen; use crate::app::{App, Transition}; use crate::common::{tool_panel, update_url_cam, CommonState, MinimapController}; @@ -608,7 +608,7 @@ impl ContextualActions for Actions { let mode = state.downcast_mut::().unwrap(); let speed = mode.controls.speed.as_mut().unwrap(); assert!(speed.is_paused()); - speed.resume_realtime(ctx, app); + speed.resume(ctx, app, SpeedSetting::Realtime); })) } (_, "unfollow (pause the simulation)") => { diff --git a/game/src/sandbox/speed.rs b/game/src/sandbox/speed.rs index 0b3181358e..b891507f5b 100644 --- a/game/src/sandbox/speed.rs +++ b/game/src/sandbox/speed.rs @@ -20,14 +20,14 @@ pub struct SpeedControls { } #[derive(Clone, Copy, PartialEq, PartialOrd)] -enum SpeedSetting { - // 1 sim second per real second +pub enum SpeedSetting { + /// 1 sim second per real second Realtime, - // 5 sim seconds per real second + /// 5 sim seconds per real second Fast, - // 30 sim seconds per real second + /// 30 sim seconds per real second Faster, - // 1 sim hour per real second + /// 1 sim hour per real second Fastest, } @@ -344,10 +344,10 @@ impl SpeedControls { } } - pub fn resume_realtime(&mut self, ctx: &mut EventCtx, app: &App) { - if self.paused || self.setting != SpeedSetting::Realtime { + pub fn resume(&mut self, ctx: &mut EventCtx, app: &App, setting: SpeedSetting) { + if self.paused || self.setting != setting { self.paused = false; - self.setting = SpeedSetting::Realtime; + self.setting = setting; self.recreate_panel(ctx, app); } }