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