mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-28 12:12:00 +03:00
move some sandox menu items to tool panel for the moment
This commit is contained in:
parent
959a89e81c
commit
3547c2cf1b
@ -1,5 +1,5 @@
|
||||
a5e849fa8883569519976ebfef3ae269 data/system/night_colors.json
|
||||
bb88577b253c978e4d08435a525f2b39 data/system/override_colors.json
|
||||
1909af5ebfefe7ad4102335c9e789d24 data/system/override_colors.json
|
||||
395df98242f9fd7bd2fc8545f0bbc908 data/system/maps/huge_seattle.bin
|
||||
5dbca78c451a3552502cb185edbee1ec data/system/maps/ballard.bin
|
||||
b5fb2ec706d444f7f6ee23f63f4f44b4 data/system/maps/downtown.bin
|
||||
@ -15,7 +15,7 @@ c54a90163d461aa495ed83cdd8b8aa23 data/system/scenarios/downtown/weekday_typical
|
||||
4627ad77a372041371ecd49ae2463168 data/system/scenarios/huge_seattle/weekday_typical_traffic_from_psrc.bin
|
||||
cb730a393826acf17dd65e5fb202e329 data/system/scenarios/caphill/weekday_typical_traffic_from_psrc.bin
|
||||
5d720b255d1b63ca67a67f64f84b6387 data/system/scenarios/montlake/weekday_typical_traffic_from_psrc.bin
|
||||
0abb70b9ff5753ef7ef318b2a2374948 data/system/prebaked_results/23rd/weekday_typical_traffic_from_psrc.bin
|
||||
9571e8d7779db30dd16e2619057b6f0b data/system/prebaked_results/signal_single/tutorial lvl1.bin
|
||||
524914e59a21a5e29d4053e22624a8cf data/system/prebaked_results/signal_single/tutorial lvl2.bin
|
||||
d9a3ab9d67207d29f1cc660c6e3ad3b5 data/system/prebaked_results/montlake/weekday_typical_traffic_from_psrc.bin
|
||||
cd00432a82d198d2077b5a0ac346a81b data/system/prebaked_results/23rd/weekday_typical_traffic_from_psrc.bin
|
||||
4bd6932b24539a6fb0d3896c0b72186e data/system/prebaked_results/signal_single/tutorial lvl1.bin
|
||||
bc80d17d4d11cde80a9393f2493ff432 data/system/prebaked_results/signal_single/tutorial lvl2.bin
|
||||
da0e8ebce442bd9ece172d76deb2fe65 data/system/prebaked_results/montlake/weekday_typical_traffic_from_psrc.bin
|
||||
|
@ -47,7 +47,7 @@ impl ABTestMode {
|
||||
diff_trip: None,
|
||||
diff_all: None,
|
||||
common: CommonState::new(),
|
||||
tool_panel: tool_panel(ctx, None),
|
||||
tool_panel: tool_panel(ctx, Vec::new()),
|
||||
test_name: test_name.to_string(),
|
||||
flipped: false,
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
use crate::common::{navigate, shortcuts};
|
||||
use crate::game::Transition;
|
||||
use crate::managed::{Callback, Composite, ManagedWidget};
|
||||
use crate::managed::{Composite, ManagedWidget};
|
||||
use crate::options;
|
||||
use ezgui::{hotkey, Button, Color, EventCtx, Key, RewriteColor, ScreenPt};
|
||||
|
||||
pub fn tool_panel(ctx: &EventCtx, layers_callback: Option<Callback>) -> Composite {
|
||||
// TODO Rethink this API.
|
||||
pub fn tool_panel(ctx: &EventCtx, extra_buttons: Vec<ManagedWidget>) -> Composite {
|
||||
let mut row = vec![
|
||||
// TODO Maybe this is confusing -- it doesn't jump to the title screen necessarily.
|
||||
// Caller has to handle this one
|
||||
@ -40,15 +41,7 @@ pub fn tool_panel(ctx: &EventCtx, layers_callback: Option<Callback>) -> Composit
|
||||
Box::new(|_, _| Some(Transition::Push(shortcuts::ChoosingShortcut::new()))),
|
||||
),
|
||||
];
|
||||
if let Some(cb) = layers_callback {
|
||||
row.push(ManagedWidget::svg_button(
|
||||
ctx,
|
||||
"assets/tools/layers.svg",
|
||||
"change overlay",
|
||||
hotkey(Key::L),
|
||||
cb,
|
||||
));
|
||||
}
|
||||
row.extend(extra_buttons);
|
||||
|
||||
Composite::minimal_size(
|
||||
ManagedWidget::row(row)
|
||||
|
@ -55,7 +55,7 @@ impl DebugMode {
|
||||
ctx,
|
||||
),
|
||||
common: CommonState::new(),
|
||||
tool_panel: tool_panel(ctx, None),
|
||||
tool_panel: tool_panel(ctx, Vec::new()),
|
||||
associated: associated::ShowAssociatedState::Inactive,
|
||||
connected_roads: connected_roads::ShowConnectedRoads::new(),
|
||||
objects: objects::ObjectDebugger::new(),
|
||||
|
@ -33,7 +33,7 @@ impl EditMode {
|
||||
pub fn new(ctx: &EventCtx, mode: GameplayMode) -> EditMode {
|
||||
EditMode {
|
||||
common: CommonState::new(),
|
||||
tool_panel: tool_panel(ctx, None),
|
||||
tool_panel: tool_panel(ctx, Vec::new()),
|
||||
menu: ModalMenu::new(
|
||||
"Map Edit Mode",
|
||||
vec![
|
||||
|
@ -11,7 +11,7 @@ use stretch::geometry::{Rect, Size};
|
||||
use stretch::node::{Node, Stretch};
|
||||
use stretch::style::{AlignItems, Dimension, FlexDirection, FlexWrap, JustifyContent, Style};
|
||||
|
||||
pub type Callback = Box<dyn Fn(&mut EventCtx, &mut UI) -> Option<Transition>>;
|
||||
type Callback = Box<dyn Fn(&mut EventCtx, &mut UI) -> Option<Transition>>;
|
||||
|
||||
pub struct ManagedWidget {
|
||||
widget: WidgetType,
|
||||
|
@ -125,7 +125,7 @@ impl ScenarioManager {
|
||||
ctx,
|
||||
),
|
||||
common: CommonState::new(),
|
||||
tool_panel: tool_panel(ctx, None),
|
||||
tool_panel: tool_panel(ctx, Vec::new()),
|
||||
scenario,
|
||||
trips_from_bldg,
|
||||
trips_to_bldg,
|
||||
|
@ -2,9 +2,7 @@ use crate::common::{CommonState, RoadColorer, RoadColorerBuilder};
|
||||
use crate::game::{State, Transition, WizardState};
|
||||
use crate::helpers::ID;
|
||||
use crate::ui::UI;
|
||||
use ezgui::{
|
||||
Choice, Color, EventCtx, GeomBatch, GfxCtx, Key, Line, ModalMenu, Text, WarpingItemSlider,
|
||||
};
|
||||
use ezgui::{Choice, Color, EventCtx, GeomBatch, GfxCtx, Key, Line, Text, WarpingItemSlider};
|
||||
use geom::{Circle, Distance, Pt2D};
|
||||
use map_model::{BusRoute, BusRouteID, BusStopID, PathConstraints, PathRequest, PathStep};
|
||||
|
||||
@ -178,13 +176,8 @@ impl State for BusRouteExplorer {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BusRoutePicker;
|
||||
impl BusRoutePicker {
|
||||
pub fn new(ui: &UI, menu: &mut ModalMenu) -> Option<Box<dyn State>> {
|
||||
if ui.primary.current_selection.is_some() || !menu.action("explore a bus route") {
|
||||
return None;
|
||||
}
|
||||
Some(make_bus_route_picker(
|
||||
pub fn pick_any_bus_route(_: &mut EventCtx, ui: &mut UI) -> Option<Transition> {
|
||||
Some(Transition::Push(make_bus_route_picker(
|
||||
ui.primary
|
||||
.map
|
||||
.get_all_bus_routes()
|
||||
@ -192,8 +185,7 @@ impl BusRoutePicker {
|
||||
.map(|r| r.id)
|
||||
.collect(),
|
||||
None,
|
||||
))
|
||||
}
|
||||
)))
|
||||
}
|
||||
|
||||
fn make_bus_route_picker(routes: Vec<BusRouteID>, start: Option<BusStopID>) -> Box<dyn State> {
|
||||
|
@ -16,8 +16,8 @@ use crate::pregame::main_menu;
|
||||
use crate::ui::{ShowEverything, UI};
|
||||
use abstutil::Timer;
|
||||
use ezgui::{
|
||||
hotkey, layout, lctrl, Choice, Color, EventCtx, EventLoopMode, GfxCtx, Key, Line, ModalMenu,
|
||||
ScreenPt, Text,
|
||||
hotkey, layout, lctrl, Button, Choice, Color, EventCtx, EventLoopMode, GfxCtx, Key, Line,
|
||||
ModalMenu, ScreenPt, Text,
|
||||
};
|
||||
pub use gameplay::spawner::spawn_agents_around;
|
||||
pub use gameplay::GameplayMode;
|
||||
@ -45,22 +45,44 @@ impl SandboxMode {
|
||||
agent_tools: AgentTools::new(),
|
||||
overlay: Overlays::Inactive,
|
||||
common: CommonState::new(),
|
||||
tool_panel: tool_panel(ctx, Some(Box::new(Overlays::change_overlays))),
|
||||
tool_panel: tool_panel(
|
||||
ctx,
|
||||
vec![
|
||||
ManagedWidget::svg_button(
|
||||
ctx,
|
||||
"assets/tools/layers.svg",
|
||||
"change overlay",
|
||||
hotkey(Key::L),
|
||||
Box::new(Overlays::change_overlays),
|
||||
),
|
||||
ManagedWidget::btn_no_cb(Button::text(
|
||||
Text::from(Line("scoreboard").size(12)),
|
||||
Color::grey(0.6),
|
||||
Color::ORANGE,
|
||||
hotkey(Key::Q),
|
||||
"scoreboard",
|
||||
ctx,
|
||||
)),
|
||||
ManagedWidget::btn(
|
||||
Button::text(
|
||||
Text::from(Line("explore a bus route").size(12)),
|
||||
Color::grey(0.6),
|
||||
Color::ORANGE,
|
||||
hotkey(Key::Q),
|
||||
"explore a bus route",
|
||||
ctx,
|
||||
),
|
||||
Box::new(bus_explorer::pick_any_bus_route),
|
||||
),
|
||||
],
|
||||
),
|
||||
minimap: if mode.has_minimap() {
|
||||
Some(Minimap::new(ctx, ui))
|
||||
} else {
|
||||
None
|
||||
},
|
||||
gameplay: gameplay::GameplayRunner::initialize(mode, ui, ctx),
|
||||
menu: ModalMenu::new(
|
||||
"Sandbox Mode",
|
||||
vec![
|
||||
(lctrl(Key::E), "edit mode"),
|
||||
(hotkey(Key::Q), "scoreboard"),
|
||||
(None, "explore a bus route"),
|
||||
],
|
||||
ctx,
|
||||
)
|
||||
menu: ModalMenu::new("Sandbox Mode", vec![(lctrl(Key::E), "edit mode")], ctx)
|
||||
.disable_standalone_layout(),
|
||||
}
|
||||
}
|
||||
@ -103,19 +125,9 @@ impl State for SandboxMode {
|
||||
if let Some(t) = self.agent_tools.event(ctx, ui, &mut self.menu) {
|
||||
return t;
|
||||
}
|
||||
if self.menu.action("scoreboard") {
|
||||
return Transition::Push(Box::new(score::Scoreboard::new(
|
||||
ctx,
|
||||
ui,
|
||||
&self.gameplay.prebaked,
|
||||
)));
|
||||
}
|
||||
if let Some(explorer) = bus_explorer::BusRouteExplorer::new(ctx, ui) {
|
||||
return Transition::PushWithMode(explorer, EventLoopMode::Animation);
|
||||
}
|
||||
if let Some(picker) = bus_explorer::BusRoutePicker::new(ui, &mut self.menu) {
|
||||
return Transition::Push(picker);
|
||||
}
|
||||
|
||||
if ui.opts.dev && ctx.input.new_was_pressed(lctrl(Key::D).unwrap()) {
|
||||
return Transition::Push(Box::new(DebugMode::new(ctx)));
|
||||
@ -250,6 +262,13 @@ impl State for SandboxMode {
|
||||
}
|
||||
})));
|
||||
}
|
||||
"scoreboard" => {
|
||||
return Transition::Push(Box::new(score::Scoreboard::new(
|
||||
ctx,
|
||||
ui,
|
||||
&self.gameplay.prebaked,
|
||||
)));
|
||||
}
|
||||
_ => unreachable!(),
|
||||
},
|
||||
None => {}
|
||||
|
Loading…
Reference in New Issue
Block a user