mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-01 02:33:54 +03:00
Omit trip timeline buttons to jump to the beginning/end of a trip in freeform mode. When you reset there, the sim is empty; there's no scenario. So it'll just crash, because the person doesn't exist.
This commit is contained in:
parent
a70131b629
commit
a6520b26c0
@ -288,6 +288,8 @@ pub struct Details {
|
||||
pub hyperlinks: HashMap<String, Tab>,
|
||||
pub warpers: HashMap<String, ID>,
|
||||
pub time_warpers: HashMap<String, (TripID, Time)>,
|
||||
// It's just convenient to plumb this here
|
||||
pub can_jump_to_time: bool,
|
||||
}
|
||||
|
||||
impl InfoPanel {
|
||||
@ -306,6 +308,7 @@ impl InfoPanel {
|
||||
hyperlinks: HashMap::new(),
|
||||
warpers: HashMap::new(),
|
||||
time_warpers: HashMap::new(),
|
||||
can_jump_to_time: ctx_actions.gameplay_mode().can_jump_to_time(),
|
||||
};
|
||||
|
||||
let (mut col, main_tab) = match tab {
|
||||
|
@ -168,9 +168,11 @@ pub fn future(
|
||||
details
|
||||
.warpers
|
||||
.insert(format!("jump to goal of {}", id), id2);
|
||||
if details.can_jump_to_time {
|
||||
details
|
||||
.time_warpers
|
||||
.insert(format!("wait for {}", id), (id, trip.departure));
|
||||
}
|
||||
|
||||
col.push(
|
||||
Widget::row(vec![
|
||||
@ -180,12 +182,16 @@ pub fn future(
|
||||
)
|
||||
.tooltip(Text::from(Line(name1)))
|
||||
.build(ctx, format!("jump to start of {}", id), None),
|
||||
if details.can_jump_to_time {
|
||||
Btn::text_bg2("Wait for trip")
|
||||
.tooltip(Text::from(Line(format!(
|
||||
"This will advance the simulation to {}",
|
||||
trip.departure.ampm_tostring()
|
||||
))))
|
||||
.build(ctx, format!("wait for {}", id), None),
|
||||
.build(ctx, format!("wait for {}", id), None)
|
||||
} else {
|
||||
Widget::nothing()
|
||||
},
|
||||
Btn::svg(
|
||||
"system/assets/timeline/goal_pos.svg",
|
||||
RewriteColor::Change(Color::WHITE, app.cs.hovering),
|
||||
@ -601,7 +607,7 @@ fn make_timeline(
|
||||
},
|
||||
]),
|
||||
Widget::row(vec![
|
||||
{
|
||||
if details.can_jump_to_time {
|
||||
details.time_warpers.insert(
|
||||
format!("jump to {}", trip.departure),
|
||||
(trip_id, trip.departure),
|
||||
@ -618,8 +624,11 @@ fn make_timeline(
|
||||
txt
|
||||
})
|
||||
.build(ctx, format!("jump to {}", trip.departure), None)
|
||||
} else {
|
||||
Widget::nothing()
|
||||
},
|
||||
if let Some(t) = end_time {
|
||||
if details.can_jump_to_time {
|
||||
details
|
||||
.time_warpers
|
||||
.insert(format!("jump to {}", t), (trip_id, t));
|
||||
@ -638,6 +647,9 @@ fn make_timeline(
|
||||
.align_right()
|
||||
} else {
|
||||
Widget::nothing()
|
||||
}
|
||||
} else {
|
||||
Widget::nothing()
|
||||
},
|
||||
]),
|
||||
];
|
||||
|
@ -154,6 +154,13 @@ impl GameplayMode {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn can_jump_to_time(&self) -> bool {
|
||||
match self {
|
||||
GameplayMode::Freeform(_) => false,
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn allows(&self, edits: &MapEdits) -> bool {
|
||||
for cmd in &edits.commands {
|
||||
match cmd {
|
||||
|
Loading…
Reference in New Issue
Block a user