mirror of
https://github.com/a-b-street/abstreet.git
synced 2025-01-05 13:05:06 +03:00
simpler top-center panel
This commit is contained in:
parent
875f311f55
commit
801d4f47c9
@ -3,10 +3,9 @@ use crate::game::Transition;
|
||||
use crate::managed::Composite;
|
||||
use crate::options;
|
||||
use crate::sandbox::GameplayMode;
|
||||
use crate::ui::UI;
|
||||
use ezgui::{
|
||||
hotkey, lctrl, Button, Color, EventCtx, HorizontalAlignment, Key, Line, ManagedWidget,
|
||||
RewriteColor, Text, VerticalAlignment,
|
||||
hotkey, lctrl, Button, Color, EventCtx, HorizontalAlignment, Key, ManagedWidget, RewriteColor,
|
||||
VerticalAlignment,
|
||||
};
|
||||
|
||||
// TODO Rethink this API.
|
||||
@ -45,21 +44,11 @@ pub fn tool_panel(ctx: &mut EventCtx, extra_buttons: Vec<ManagedWidget>) -> Comp
|
||||
)
|
||||
}
|
||||
|
||||
pub fn edit_map_panel(ctx: &mut EventCtx, ui: &UI, gameplay: GameplayMode) -> Composite {
|
||||
pub fn edit_map_panel(ctx: &mut EventCtx, gameplay: GameplayMode) -> Composite {
|
||||
Composite::new(
|
||||
ezgui::Composite::new(
|
||||
ManagedWidget::col(vec![
|
||||
Composite::svg_button(ctx, "assets/tools/edit_map.svg", "edit map", lctrl(Key::E)),
|
||||
{
|
||||
let edits = ui.primary.map.get_edits();
|
||||
let mut txt = Text::from(Line(&edits.edits_name));
|
||||
if edits.dirty {
|
||||
txt.append(Line("*"));
|
||||
}
|
||||
ManagedWidget::draw_text(ctx, txt)
|
||||
},
|
||||
])
|
||||
.bg(Color::grey(0.4)),
|
||||
Composite::svg_button(ctx, "assets/tools/edit_map.svg", "edit map", lctrl(Key::E))
|
||||
.bg(Color::grey(0.4)),
|
||||
)
|
||||
.aligned(HorizontalAlignment::Center, VerticalAlignment::Top)
|
||||
.build(ctx),
|
||||
|
@ -15,7 +15,7 @@ pub struct CreateGridlock {
|
||||
}
|
||||
|
||||
impl CreateGridlock {
|
||||
pub fn new(ctx: &mut EventCtx, ui: &UI) -> (ModalMenu, Composite, Box<dyn GameplayState>) {
|
||||
pub fn new(ctx: &mut EventCtx) -> (ModalMenu, Composite, Box<dyn GameplayState>) {
|
||||
(
|
||||
ModalMenu::new(
|
||||
"Cause gridlock",
|
||||
@ -25,7 +25,7 @@ impl CreateGridlock {
|
||||
],
|
||||
ctx,
|
||||
),
|
||||
edit_map_panel(ctx, ui, GameplayMode::CreateGridlock),
|
||||
edit_map_panel(ctx, GameplayMode::CreateGridlock),
|
||||
Box::new(CreateGridlock {
|
||||
time: Time::START_OF_DAY,
|
||||
}),
|
||||
|
@ -18,7 +18,6 @@ impl FasterTrips {
|
||||
pub fn new(
|
||||
trip_mode: TripMode,
|
||||
ctx: &mut EventCtx,
|
||||
ui: &UI,
|
||||
) -> (ModalMenu, Composite, Box<dyn GameplayState>) {
|
||||
(
|
||||
ModalMenu::new(
|
||||
@ -26,7 +25,7 @@ impl FasterTrips {
|
||||
vec![(hotkey(Key::H), "help")],
|
||||
ctx,
|
||||
),
|
||||
edit_map_panel(ctx, ui, GameplayMode::FasterTrips(trip_mode)),
|
||||
edit_map_panel(ctx, GameplayMode::FasterTrips(trip_mode)),
|
||||
Box::new(FasterTrips {
|
||||
mode: trip_mode,
|
||||
time: Time::START_OF_DAY,
|
||||
|
@ -18,7 +18,6 @@ pub struct FixTrafficSignals {
|
||||
impl FixTrafficSignals {
|
||||
pub fn new(
|
||||
ctx: &mut EventCtx,
|
||||
ui: &UI,
|
||||
mode: GameplayMode,
|
||||
) -> (ModalMenu, Composite, Box<dyn GameplayState>) {
|
||||
(
|
||||
@ -32,7 +31,7 @@ impl FixTrafficSignals {
|
||||
],
|
||||
ctx,
|
||||
),
|
||||
edit_map_panel(ctx, ui, mode),
|
||||
edit_map_panel(ctx, mode),
|
||||
Box::new(FixTrafficSignals {
|
||||
time: Time::START_OF_DAY,
|
||||
once: true,
|
||||
|
@ -80,31 +80,21 @@ pub fn freeform_controller(
|
||||
Composite::new(
|
||||
ezgui::Composite::new(
|
||||
ManagedWidget::row(vec![
|
||||
ManagedWidget::col(vec![
|
||||
Composite::text_button(ctx, "change map", lctrl(Key::L)),
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line(ui.primary.map.get_name()))),
|
||||
]),
|
||||
ManagedWidget::col(vec![
|
||||
Composite::text_button(ctx, "change scenario", hotkey(Key::S)),
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line(scenario_name))),
|
||||
]),
|
||||
// TODO Refactor
|
||||
ManagedWidget::col(vec![
|
||||
Composite::svg_button(
|
||||
ctx,
|
||||
"assets/tools/edit_map.svg",
|
||||
"edit map",
|
||||
lctrl(Key::E),
|
||||
),
|
||||
{
|
||||
let edits = ui.primary.map.get_edits();
|
||||
let mut txt = Text::from(Line(&edits.edits_name));
|
||||
if edits.dirty {
|
||||
txt.append(Line("*"));
|
||||
}
|
||||
ManagedWidget::draw_text(ctx, txt)
|
||||
},
|
||||
]),
|
||||
Composite::detailed_text_button(
|
||||
ctx,
|
||||
Text::from(Line(ui.primary.map.get_name()).fg(Color::BLACK)),
|
||||
lctrl(Key::L),
|
||||
"change map",
|
||||
),
|
||||
Composite::detailed_text_button(
|
||||
ctx,
|
||||
Text::from(Line(scenario_name).fg(Color::BLACK)),
|
||||
hotkey(Key::S),
|
||||
"change scenario",
|
||||
),
|
||||
// TODO Name of edits and whether the current ones are saved or not is probably
|
||||
// less interesting.
|
||||
Composite::svg_button(ctx, "assets/tools/edit_map.svg", "edit map", lctrl(Key::E)),
|
||||
])
|
||||
.bg(Color::grey(0.4)),
|
||||
)
|
||||
|
@ -143,12 +143,10 @@ impl GameplayRunner {
|
||||
GameplayMode::OptimizeBus(route_name) => {
|
||||
optimize_bus::OptimizeBus::new(route_name, ctx, ui)
|
||||
}
|
||||
GameplayMode::CreateGridlock => create_gridlock::CreateGridlock::new(ctx, ui),
|
||||
GameplayMode::FasterTrips(trip_mode) => {
|
||||
faster_trips::FasterTrips::new(trip_mode, ctx, ui)
|
||||
}
|
||||
GameplayMode::CreateGridlock => create_gridlock::CreateGridlock::new(ctx),
|
||||
GameplayMode::FasterTrips(trip_mode) => faster_trips::FasterTrips::new(trip_mode, ctx),
|
||||
GameplayMode::FixTrafficSignals | GameplayMode::FixTrafficSignalsTutorial(_) => {
|
||||
fix_traffic_signals::FixTrafficSignals::new(ctx, ui, mode.clone())
|
||||
fix_traffic_signals::FixTrafficSignals::new(ctx, mode.clone())
|
||||
}
|
||||
};
|
||||
// TODO Maybe don't load this for Freeform mode
|
||||
|
@ -39,7 +39,7 @@ impl OptimizeBus {
|
||||
],
|
||||
ctx,
|
||||
),
|
||||
edit_map_panel(ctx, ui, GameplayMode::OptimizeBus(route_name.clone())),
|
||||
edit_map_panel(ctx, GameplayMode::OptimizeBus(route_name.clone())),
|
||||
Box::new(OptimizeBus {
|
||||
route: route.id,
|
||||
time: Time::START_OF_DAY,
|
||||
|
Loading…
Reference in New Issue
Block a user