Actdev tweaks: flip walking/biking button order, start with 3x speed

This commit is contained in:
Dustin Carlino 2021-03-02 09:30:44 -08:00
parent 081819d86b
commit 6cacaf1c8a
3 changed files with 24 additions and 13 deletions

View File

@ -13,13 +13,14 @@ use crate::common::jump_to_time_upon_startup;
use crate::edit::EditMode; use crate::edit::EditMode;
use crate::info::{OpenTrip, Tab}; use crate::info::{OpenTrip, Tab};
use crate::sandbox::gameplay::{GameplayMode, GameplayState}; 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 /// A gameplay mode with specific controls for integration with
/// https://cyipt.github.io/acton/articles/the-actdev-project.html. /// https://cyipt.github.io/acton/articles/the-actdev-project.html.
pub struct Actdev { pub struct Actdev {
top_center: Panel, top_center: Panel,
scenario_name: String, scenario_name: String,
once: bool,
} }
impl Actdev { impl Actdev {
@ -27,6 +28,7 @@ impl Actdev {
Box::new(Actdev { Box::new(Actdev {
top_center: Panel::empty(ctx), top_center: Panel::empty(ctx),
scenario_name, scenario_name,
once: true,
}) })
} }
} }
@ -39,6 +41,15 @@ impl GameplayState for Actdev {
controls: &mut SandboxControls, controls: &mut SandboxControls,
actions: &mut Actions, actions: &mut Actions,
) -> Option<Transition> { ) -> Option<Transition> {
if self.once {
self.once = false;
controls
.speed
.as_mut()
.unwrap()
.resume(ctx, app, SpeedSetting::Faster);
}
match self.top_center.event(ctx) { match self.top_center.event(ctx) {
Outcome::Clicked(x) => match x.as_ref() { Outcome::Clicked(x) => match x.as_ref() {
"change scenario" => { "change scenario" => {
@ -175,11 +186,11 @@ impl GameplayState for Actdev {
.build_def(ctx), .build_def(ctx),
ctx.style() ctx.style()
.btn_plain .btn_plain
.icon_text("system/assets/meters/bike.svg", "Cycling activity") .icon_text("system/assets/meters/pedestrian.svg", "Walking activity")
.build_def(ctx), .build_def(ctx),
ctx.style() ctx.style()
.btn_plain .btn_plain
.icon_text("system/assets/meters/pedestrian.svg", "Walking activity") .icon_text("system/assets/meters/bike.svg", "Cycling activity")
.build_def(ctx), .build_def(ctx),
]), ]),
]); ]);

View File

@ -17,7 +17,7 @@ use widgetry::{
pub use self::gameplay::{spawn_agents_around, GameplayMode, TutorialPointer, TutorialState}; pub use self::gameplay::{spawn_agents_around, GameplayMode, TutorialPointer, TutorialState};
use self::misc_tools::{RoutePreview, TrafficRecorder}; 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; pub use self::time_warp::TimeWarpScreen;
use crate::app::{App, Transition}; use crate::app::{App, Transition};
use crate::common::{tool_panel, update_url_cam, CommonState, MinimapController}; use crate::common::{tool_panel, update_url_cam, CommonState, MinimapController};
@ -608,7 +608,7 @@ impl ContextualActions for Actions {
let mode = state.downcast_mut::<SandboxMode>().unwrap(); let mode = state.downcast_mut::<SandboxMode>().unwrap();
let speed = mode.controls.speed.as_mut().unwrap(); let speed = mode.controls.speed.as_mut().unwrap();
assert!(speed.is_paused()); assert!(speed.is_paused());
speed.resume_realtime(ctx, app); speed.resume(ctx, app, SpeedSetting::Realtime);
})) }))
} }
(_, "unfollow (pause the simulation)") => { (_, "unfollow (pause the simulation)") => {

View File

@ -20,14 +20,14 @@ pub struct SpeedControls {
} }
#[derive(Clone, Copy, PartialEq, PartialOrd)] #[derive(Clone, Copy, PartialEq, PartialOrd)]
enum SpeedSetting { pub enum SpeedSetting {
// 1 sim second per real second /// 1 sim second per real second
Realtime, Realtime,
// 5 sim seconds per real second /// 5 sim seconds per real second
Fast, Fast,
// 30 sim seconds per real second /// 30 sim seconds per real second
Faster, Faster,
// 1 sim hour per real second /// 1 sim hour per real second
Fastest, Fastest,
} }
@ -344,10 +344,10 @@ impl SpeedControls {
} }
} }
pub fn resume_realtime(&mut self, ctx: &mut EventCtx, app: &App) { pub fn resume(&mut self, ctx: &mut EventCtx, app: &App, setting: SpeedSetting) {
if self.paused || self.setting != SpeedSetting::Realtime { if self.paused || self.setting != setting {
self.paused = false; self.paused = false;
self.setting = SpeedSetting::Realtime; self.setting = setting;
self.recreate_panel(ctx, app); self.recreate_panel(ctx, app);
} }
} }