mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-29 17:34:58 +03:00
set a modal menu's prompt just once in a few places, where that's more
convenient
This commit is contained in:
parent
923adbf8b5
commit
ea9d01bcc1
@ -317,7 +317,7 @@ responds. The possible edits include:
|
||||
|
||||
The map conversion process outlined above takes a few minutes, so reusing this
|
||||
process directly to compute a map with edits wouldn't work at all for real
|
||||
gameplay. Instead, he process for applying edits is incremental:
|
||||
gameplay. Instead, the process for applying edits is incremental:
|
||||
|
||||
- Figure out the actual diff between edits and the current map
|
||||
- This is necessary for correctness, but also speeds up a sequence of edits
|
||||
|
@ -32,6 +32,7 @@
|
||||
- josie kresner from transport foundry
|
||||
- https://www.citylab.com/transportation/2019/08/city-planning-transportation-oakland-community-engagement/596050/
|
||||
- tweeting small problems -> bug tracker
|
||||
- https://www.the74million.org/article/building-a-smarter-and-cheaper-school-bus-system-how-a-boston-mit-partnership-led-to-new-routes-that-are-20-more-efficient-use-400-fewer-buses-save-5-million/
|
||||
|
||||
## Similar projects
|
||||
|
||||
|
@ -52,6 +52,12 @@ fn pick_ab_test(wiz: &mut Wizard, ctx: &mut EventCtx, ui: &mut UI) -> Option<Tra
|
||||
t
|
||||
};
|
||||
|
||||
let mut txt = Text::prompt("A/B Test Editor");
|
||||
txt.add_line(ab_test.test_name.clone());
|
||||
for line in ab_test.describe() {
|
||||
txt.add_line(line);
|
||||
}
|
||||
|
||||
Some(Transition::Replace(Box::new(ABTestSetup {
|
||||
menu: ModalMenu::new(
|
||||
"A/B Test Editor",
|
||||
@ -61,7 +67,8 @@ fn pick_ab_test(wiz: &mut Wizard, ctx: &mut EventCtx, ui: &mut UI) -> Option<Tra
|
||||
(hotkey(Key::L), "load savestate"),
|
||||
]],
|
||||
ctx,
|
||||
),
|
||||
)
|
||||
.set_prompt(ctx, txt),
|
||||
ab_test,
|
||||
})))
|
||||
}
|
||||
@ -73,14 +80,7 @@ struct ABTestSetup {
|
||||
|
||||
impl State for ABTestSetup {
|
||||
fn event(&mut self, ctx: &mut EventCtx, ui: &mut UI) -> Transition {
|
||||
{
|
||||
let mut txt = Text::prompt("A/B Test Editor");
|
||||
txt.add_line(self.ab_test.test_name.clone());
|
||||
for line in self.ab_test.describe() {
|
||||
txt.add_line(line);
|
||||
}
|
||||
self.menu.handle_event(ctx, Some(txt));
|
||||
}
|
||||
self.menu.handle_event(ctx, None);
|
||||
ctx.canvas.handle_event(ctx.input);
|
||||
|
||||
if self.menu.action("quit") {
|
||||
|
@ -10,7 +10,6 @@ use std::collections::{HashMap, HashSet};
|
||||
pub struct Floodfiller {
|
||||
menu: ModalMenu,
|
||||
colorer: RoadColorer,
|
||||
prompt: Text,
|
||||
}
|
||||
|
||||
impl Floodfiller {
|
||||
@ -79,9 +78,9 @@ impl Floodfiller {
|
||||
"Floodfiller",
|
||||
vec![vec![(hotkey(Key::Escape), "quit")]],
|
||||
ctx,
|
||||
),
|
||||
)
|
||||
.set_prompt(ctx, prompt),
|
||||
colorer: colorer.build(ctx, map),
|
||||
prompt,
|
||||
}))
|
||||
}
|
||||
}
|
||||
@ -93,7 +92,7 @@ impl State for Floodfiller {
|
||||
}
|
||||
ctx.canvas.handle_event(ctx.input);
|
||||
|
||||
self.menu.handle_event(ctx, Some(self.prompt.clone()));
|
||||
self.menu.handle_event(ctx, None);
|
||||
if self.menu.action("quit") {
|
||||
return Transition::Pop;
|
||||
}
|
||||
|
@ -60,6 +60,11 @@ impl ModalMenu {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_prompt(mut self, ctx: &mut EventCtx, prompt: Text) -> ModalMenu {
|
||||
self.menu.change_prompt(prompt, ctx.canvas);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn action(&mut self, name: &str) -> bool {
|
||||
if let Some(ref action) = self.chosen_action {
|
||||
if name == action {
|
||||
|
@ -56,6 +56,9 @@ impl fmt::Display for DirectedRoadID {
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct Road {
|
||||
pub id: RoadID,
|
||||
// I've previously tried storing these in a compressed lookup table (since the keys and values
|
||||
// are often common), but the performance benefit was negligible, and the increased API
|
||||
// complexity was annoying.
|
||||
pub osm_tags: BTreeMap<String, String>,
|
||||
// self is 'from'
|
||||
pub turn_restrictions: Vec<(String, RoadID)>,
|
||||
|
Loading…
Reference in New Issue
Block a user