From 59f2f03acb36e4440cd1f586f62bcd3c545210a8 Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Mon, 3 Feb 2020 11:14:17 -0800 Subject: [PATCH] refactoring some UI-related colors --- game/src/challenges.rs | 3 ++- game/src/colors.rs | 9 +++++++++ game/src/common/colors.rs | 3 ++- game/src/common/info.rs | 21 ++++++++++--------- game/src/common/minimap.rs | 13 ++++++------ game/src/common/overlays.rs | 25 ++++++++++++----------- game/src/common/panels.rs | 11 +++++----- game/src/common/turn_cycler.rs | 3 ++- game/src/edit/lanes.rs | 5 +++-- game/src/edit/traffic_signals.rs | 5 +++-- game/src/main.rs | 1 + game/src/managed.rs | 7 ++++--- game/src/pregame.rs | 3 ++- game/src/sandbox/dashboards.rs | 9 +++++---- game/src/sandbox/gameplay/freeform.rs | 3 ++- game/src/sandbox/gameplay/mod.rs | 5 +++-- game/src/sandbox/gameplay/tutorial.rs | 5 +++-- game/src/sandbox/mod.rs | 7 ++++--- game/src/sandbox/speed.rs | 29 +++++++++++++-------------- 19 files changed, 96 insertions(+), 71 deletions(-) create mode 100644 game/src/colors.rs diff --git a/game/src/challenges.rs b/game/src/challenges.rs index b01f28b512..cdd59017f5 100644 --- a/game/src/challenges.rs +++ b/game/src/challenges.rs @@ -1,3 +1,4 @@ +use crate::colors; use crate::edit::apply_map_edits; use crate::game::{State, Transition, WizardState}; use crate::managed::{ManagedGUIState, WrappedComposite}; @@ -139,7 +140,7 @@ pub fn challenges_picker(ctx: &mut EventCtx, ui: &UI) -> Box { flex_row.push(ManagedWidget::btn(Button::text_bg( Text::from(Line(&name).size(40).fg(Color::BLACK)), Color::WHITE, - Color::ORANGE, + colors::HOVERING, hotkey(Key::NUM_KEYS[idx]), &name, ctx, diff --git a/game/src/colors.rs b/game/src/colors.rs new file mode 100644 index 0000000000..d9e3cf6616 --- /dev/null +++ b/game/src/colors.rs @@ -0,0 +1,9 @@ +// TODO Still can't decide how to arrange colorschemes. Trying this out. + +//before: 256 + +use ezgui::Color; + +pub const HOVERING: Color = Color::ORANGE; +pub const PANEL_BG: Color = Color::grey(0.4); +pub const SECTION_BG: Color = Color::grey(0.5); diff --git a/game/src/common/colors.rs b/game/src/common/colors.rs index a2ee3dac0e..228268019d 100644 --- a/game/src/common/colors.rs +++ b/game/src/common/colors.rs @@ -1,3 +1,4 @@ +use crate::colors; use crate::managed::WrappedComposite; use crate::render::MIN_ZOOM_FOR_DETAIL; use crate::ui::UI; @@ -144,7 +145,7 @@ impl ColorerBuilder { for (label, color) in self.prioritized_colors { col.push(ColorLegend::row(ctx, color, label)); } - let legend = Composite::new(ManagedWidget::col(col).bg(Color::grey(0.4))) + let legend = Composite::new(ManagedWidget::col(col).bg(colors::PANEL_BG)) .aligned(HorizontalAlignment::Right, VerticalAlignment::Center) .build(ctx); diff --git a/game/src/common/info.rs b/game/src/common/info.rs index e1f54eaf83..cfd69a1e2a 100644 --- a/game/src/common/info.rs +++ b/game/src/common/info.rs @@ -1,3 +1,4 @@ +use crate::colors; use crate::common::{ColorLegend, CommonState, Warping}; use crate::game::{msg, Transition}; use crate::helpers::{rotating_color, rotating_color_map, ID}; @@ -55,7 +56,7 @@ impl InfoPanel { "assets/tools/locate.svg", "jump to object", hotkey(Key::J), - RewriteColor::Change(Color::hex("#CC4121"), Color::ORANGE), + RewriteColor::Change(Color::hex("#CC4121"), colors::HOVERING), ctx, )), WrappedComposite::text_button(ctx, "X", hotkey(Key::Escape)).align_right(), @@ -67,8 +68,8 @@ impl InfoPanel { txt.append(Line(format!(" - {}", label))); col.push(ManagedWidget::btn(Button::text_bg( txt, - Color::grey(0.5), - Color::ORANGE, + colors::SECTION_BG, + colors::HOVERING, hotkey(*key), label, ctx, @@ -146,7 +147,7 @@ impl InfoPanel { actions, trip_details, time: ui.primary.sim.time(), - composite: Composite::new(ManagedWidget::col(col).bg(Color::grey(0.3))) + composite: Composite::new(ManagedWidget::col(col).bg(colors::PANEL_BG)) .aligned( HorizontalAlignment::Percent(0.02), VerticalAlignment::Percent(0.2), @@ -298,7 +299,7 @@ fn info_for(id: ID, ctx: &EventCtx, ui: &UI) -> Vec { ctx, Text::from(Line("throughput in 20 minute buckets (entire road)")), ) - .bg(Color::grey(0.5)), + .bg(colors::SECTION_BG), ); rows.push( road_throughput( @@ -307,7 +308,7 @@ fn info_for(id: ID, ctx: &EventCtx, ui: &UI) -> Vec { ctx, ui, ) - .bg(Color::grey(0.5)) + .bg(colors::SECTION_BG) .margin(10), ); } @@ -345,21 +346,21 @@ fn info_for(id: ID, ctx: &EventCtx, ui: &UI) -> Vec { if ui.primary.map.get_i(id).is_traffic_signal() { rows.push( ManagedWidget::draw_text(ctx, Text::from(Line("delay in 20 minute buckets"))) - .bg(Color::grey(0.5)), + .bg(colors::SECTION_BG), ); rows.push( intersection_delay(id, Duration::minutes(20), ctx, ui) - .bg(Color::grey(0.5)) + .bg(colors::SECTION_BG) .margin(10), ); } rows.push( ManagedWidget::draw_text(ctx, Text::from(Line("throughput in 20 minute buckets"))) - .bg(Color::grey(0.5)), + .bg(colors::SECTION_BG), ); rows.push( intersection_throughput(id, Duration::minutes(20), ctx, ui) - .bg(Color::grey(0.5)) + .bg(colors::SECTION_BG) .margin(10), ); } diff --git a/game/src/common/minimap.rs b/game/src/common/minimap.rs index 2d36dc5013..28ef24f7aa 100644 --- a/game/src/common/minimap.rs +++ b/game/src/common/minimap.rs @@ -1,3 +1,4 @@ +use crate::colors; use crate::common::{navigate, shortcuts, Overlays, Warping}; use crate::game::{Transition, WizardState}; use crate::managed::WrappedComposite; @@ -277,7 +278,7 @@ fn make_minimap_panel(ctx: &mut EventCtx, acs: &AgentColorScheme, zoom_lvl: usiz "assets/speed/speed_up.svg", "zoom in", None, - RewriteColor::ChangeAll(Color::ORANGE), + RewriteColor::ChangeAll(colors::HOVERING), ctx, ))]; for i in (0..=3).rev() { @@ -295,7 +296,7 @@ fn make_minimap_panel(ctx: &mut EventCtx, acs: &AgentColorScheme, zoom_lvl: usiz ), DrawBoth::new( ctx, - GeomBatch::from(vec![(Color::ORANGE, rect.clone())]), + GeomBatch::from(vec![(colors::HOVERING, rect.clone())]), Vec::new(), ), None, @@ -307,7 +308,7 @@ fn make_minimap_panel(ctx: &mut EventCtx, acs: &AgentColorScheme, zoom_lvl: usiz "assets/speed/slow_down.svg", "zoom out", None, - RewriteColor::ChangeAll(Color::ORANGE), + RewriteColor::ChangeAll(colors::HOVERING), ctx, ))); @@ -339,7 +340,7 @@ fn make_minimap_panel(ctx: &mut EventCtx, acs: &AgentColorScheme, zoom_lvl: usiz ]) .centered(), ]) - .bg(Color::grey(0.5)), + .bg(colors::PANEL_BG), ) .aligned( HorizontalAlignment::Right, @@ -411,7 +412,7 @@ fn make_viz_panel(ctx: &mut EventCtx, acs: &AgentColorScheme) -> ManagedWidget { } else { RewriteColor::ChangeAll(Color::WHITE.alpha(0.5)) }, - RewriteColor::ChangeAll(Color::ORANGE), + RewriteColor::ChangeAll(colors::HOVERING), ctx, )) .margin(3), @@ -441,5 +442,5 @@ fn make_viz_panel(ctx: &mut EventCtx, acs: &AgentColorScheme) -> ManagedWidget { .centered_cross(), ); } - ManagedWidget::col(col).bg(Color::grey(0.4)) + ManagedWidget::col(col).bg(colors::PANEL_BG) } diff --git a/game/src/common/overlays.rs b/game/src/common/overlays.rs index 590ade2174..b6dba252af 100644 --- a/game/src/common/overlays.rs +++ b/game/src/common/overlays.rs @@ -1,3 +1,4 @@ +use crate::colors; use crate::common::{ColorLegend, Colorer, ShowBusRoute, Warping}; use crate::game::Transition; use crate::helpers::rotating_color_total; @@ -224,35 +225,35 @@ impl Overlays { "assets/layers/parking_avail.svg", "parking availability", hotkey(Key::P), - RewriteColor::Change(Color::hex("#F2F2F2"), Color::ORANGE), + RewriteColor::Change(Color::hex("#F2F2F2"), colors::HOVERING), ctx, )), ManagedWidget::btn(Button::rectangle_svg( "assets/layers/intersection_delay.svg", "intersection delay", hotkey(Key::I), - RewriteColor::Change(Color::hex("#F2F2F2"), Color::ORANGE), + RewriteColor::Change(Color::hex("#F2F2F2"), colors::HOVERING), ctx, )), ManagedWidget::btn(Button::rectangle_svg( "assets/layers/throughput.svg", "throughput", hotkey(Key::T), - RewriteColor::Change(Color::hex("#F2F2F2"), Color::ORANGE), + RewriteColor::Change(Color::hex("#F2F2F2"), colors::HOVERING), ctx, )), ManagedWidget::btn(Button::rectangle_svg( "assets/layers/bike_network.svg", "bike network", hotkey(Key::B), - RewriteColor::Change(Color::hex("#F2F2F2"), Color::ORANGE), + RewriteColor::Change(Color::hex("#F2F2F2"), colors::HOVERING), ctx, )), ManagedWidget::btn(Button::rectangle_svg( "assets/layers/bus_network.svg", "bus network", hotkey(Key::U), - RewriteColor::Change(Color::hex("#F2F2F2"), Color::ORANGE), + RewriteColor::Change(Color::hex("#F2F2F2"), colors::HOVERING), ctx, )), ]; @@ -306,7 +307,7 @@ impl Overlays { ]), ManagedWidget::row(choices).flex_wrap(ctx, 20), ]) - .bg(Color::hex("#5B5B5B")), + .bg(colors::PANEL_BG), ) .max_size_percent(30, 50) .build(ctx), @@ -595,7 +596,7 @@ impl Overlays { ctx, ), ]) - .bg(Color::grey(0.4)), + .bg(colors::PANEL_BG), ) .aligned(HorizontalAlignment::Right, VerticalAlignment::Center) .build(ctx), @@ -637,7 +638,7 @@ impl Overlays { "assets/tools/locate.svg", "intersection demand", None, - RewriteColor::Change(Color::hex("#CC4121"), Color::ORANGE), + RewriteColor::Change(Color::hex("#CC4121"), colors::HOVERING), ctx, )), WrappedComposite::text_button(ctx, "X", None).align_right(), @@ -648,7 +649,7 @@ impl Overlays { ui.primary.sim.time(), i, batch.upload(ctx), - Composite::new(ManagedWidget::col(col).bg(Color::grey(0.4))) + Composite::new(ManagedWidget::col(col).bg(colors::PANEL_BG)) .aligned(HorizontalAlignment::Right, VerticalAlignment::Center) .build(ctx), ) @@ -678,7 +679,7 @@ impl Overlays { "assets/tools/locate.svg", &format!("Stop {}", idx + 1), None, - RewriteColor::Change(Color::hex("#CC4121"), Color::ORANGE), + RewriteColor::Change(Color::hex("#CC4121"), colors::HOVERING), ctx, )), ]; @@ -729,7 +730,7 @@ impl Overlays { ])); let mut c = WrappedComposite::new( - Composite::new(ManagedWidget::col(master_col).bg(Color::grey(0.4))) + Composite::new(ManagedWidget::col(master_col).bg(colors::PANEL_BG)) .aligned(HorizontalAlignment::Right, VerticalAlignment::Center) .build(ctx), ); @@ -788,7 +789,7 @@ impl Overlays { ]), Plot::new_duration(series, ctx).margin(10), ]) - .bg(Color::grey(0.3)), + .bg(colors::PANEL_BG), ) // TODO Doesn't fit .aligned(HorizontalAlignment::Right, VerticalAlignment::Center) diff --git a/game/src/common/panels.rs b/game/src/common/panels.rs index e03babe923..f4123da78b 100644 --- a/game/src/common/panels.rs +++ b/game/src/common/panels.rs @@ -1,9 +1,10 @@ +use crate::colors; use crate::game::Transition; use crate::managed::WrappedComposite; use crate::options; use ezgui::{ - hotkey, Button, Color, Composite, EventCtx, HorizontalAlignment, Key, ManagedWidget, - RewriteColor, VerticalAlignment, + hotkey, Button, Composite, EventCtx, HorizontalAlignment, Key, ManagedWidget, RewriteColor, + VerticalAlignment, }; pub fn tool_panel(ctx: &mut EventCtx) -> WrappedComposite { @@ -14,7 +15,7 @@ pub fn tool_panel(ctx: &mut EventCtx) -> WrappedComposite { "assets/tools/home.svg", "back", hotkey(Key::Escape), - RewriteColor::ChangeAll(Color::ORANGE), + RewriteColor::ChangeAll(colors::HOVERING), ctx, )) .margin(10), @@ -22,13 +23,13 @@ pub fn tool_panel(ctx: &mut EventCtx) -> WrappedComposite { "assets/tools/settings.svg", "settings", None, - RewriteColor::ChangeAll(Color::ORANGE), + RewriteColor::ChangeAll(colors::HOVERING), ctx, )) .margin(10), ]; WrappedComposite::new( - Composite::new(ManagedWidget::row(row).bg(Color::grey(0.4))) + Composite::new(ManagedWidget::row(row).bg(colors::PANEL_BG)) .aligned(HorizontalAlignment::Left, VerticalAlignment::BottomAboveOSD) .build(ctx), ) diff --git a/game/src/common/turn_cycler.rs b/game/src/common/turn_cycler.rs index b444f9cd84..9c15c9721d 100644 --- a/game/src/common/turn_cycler.rs +++ b/game/src/common/turn_cycler.rs @@ -1,3 +1,4 @@ +use crate::colors; use crate::game::{State, Transition}; use crate::helpers::plain_list_names; use crate::helpers::ID; @@ -334,7 +335,7 @@ fn make_diagram(i: IntersectionID, selected: usize, ui: &UI, ctx: &mut EventCtx) ); } - Composite::new(ManagedWidget::col(col).bg(Color::hex("#545454"))) + Composite::new(ManagedWidget::col(col).bg(colors::PANEL_BG)) .aligned(HorizontalAlignment::Left, VerticalAlignment::Top) .max_size_percent(30, 90) .build(ctx) diff --git a/game/src/edit/lanes.rs b/game/src/edit/lanes.rs index 0798a79dc1..a14347b9ac 100644 --- a/game/src/edit/lanes.rs +++ b/game/src/edit/lanes.rs @@ -1,3 +1,4 @@ +use crate::colors; use crate::common::Colorer; use crate::edit::apply_map_edits; use crate::game::{msg, State, Transition, WizardState}; @@ -220,7 +221,7 @@ fn make_brush_panel(ctx: &mut EventCtx, brush: Brush) -> Composite { } else { RewriteColor::NoOp }, - RewriteColor::ChangeAll(Color::ORANGE), + RewriteColor::ChangeAll(colors::HOVERING), ctx, ))]) .padding(5), @@ -231,7 +232,7 @@ fn make_brush_panel(ctx: &mut EventCtx, brush: Brush) -> Composite { ManagedWidget::draw_text(ctx, Text::from(Line("Modify lanes"))).centered_horiz(), ManagedWidget::row(row).centered(), ]) - .bg(Color::hex("#4C4C4C")) + .bg(colors::PANEL_BG) .padding(10), ) .aligned(HorizontalAlignment::Center, VerticalAlignment::Top) diff --git a/game/src/edit/traffic_signals.rs b/game/src/edit/traffic_signals.rs index 1d406c6798..7fb6a08ed4 100644 --- a/game/src/edit/traffic_signals.rs +++ b/game/src/edit/traffic_signals.rs @@ -1,3 +1,4 @@ +use crate::colors; use crate::common::CommonState; use crate::edit::apply_map_edits; use crate::game::{msg, State, Transition, WizardState}; @@ -389,7 +390,7 @@ fn make_top_panel(can_undo: bool, can_redo: bool, ctx: &mut EventCtx) -> Composi }) .margin(15), ]; - Composite::new(ManagedWidget::row(row).bg(Color::hex("#545454"))) + Composite::new(ManagedWidget::row(row).bg(colors::PANEL_BG)) .aligned(HorizontalAlignment::Center, VerticalAlignment::Top) .build(ctx) } @@ -565,7 +566,7 @@ fn make_diagram(i: IntersectionID, selected: usize, ui: &UI, ctx: &mut EventCtx) ); } - Composite::new(ManagedWidget::col(col).bg(Color::hex("#545454"))) + Composite::new(ManagedWidget::col(col).bg(colors::PANEL_BG)) .aligned(HorizontalAlignment::Left, VerticalAlignment::Top) .max_size_percent(30, 90) .build(ctx) diff --git a/game/src/main.rs b/game/src/main.rs index df52c881a6..87755da865 100644 --- a/game/src/main.rs +++ b/game/src/main.rs @@ -1,5 +1,6 @@ mod abtest; mod challenges; +mod colors; mod common; mod debug; mod edit; diff --git a/game/src/managed.rs b/game/src/managed.rs index 5df6dfd7b4..393d5e93a5 100644 --- a/game/src/managed.rs +++ b/game/src/managed.rs @@ -1,3 +1,4 @@ +use crate::colors; use crate::common::CommonState; use crate::game::{State, Transition}; use crate::ui::UI; @@ -68,7 +69,7 @@ impl WrappedComposite { filename, tooltip, hotkey, - RewriteColor::Change(Color::WHITE, Color::ORANGE), + RewriteColor::Change(Color::WHITE, colors::HOVERING), ctx, )) } @@ -81,7 +82,7 @@ impl WrappedComposite { ) -> ManagedWidget { ManagedWidget::btn(Button::text_no_bg( txt.clone(), - txt.change_fg(Color::ORANGE), + txt.change_fg(colors::HOVERING), hotkey, label, true, @@ -98,7 +99,7 @@ impl WrappedComposite { ManagedWidget::btn(Button::text_bg( Text::from(Line(label).fg(Color::BLACK)), Color::WHITE, - Color::ORANGE, + colors::HOVERING, hotkey, label, ctx, diff --git a/game/src/pregame.rs b/game/src/pregame.rs index 0be1f617d7..62176780e6 100644 --- a/game/src/pregame.rs +++ b/game/src/pregame.rs @@ -1,5 +1,6 @@ use crate::abtest::setup::PickABTest; use crate::challenges::challenges_picker; +use crate::colors; use crate::game::{State, Transition}; use crate::managed::{ManagedGUIState, WrappedComposite, WrappedOutcome}; use crate::mission::MissionEditMode; @@ -35,7 +36,7 @@ impl TitleScreen { ManagedWidget::btn(Button::text_bg( Text::from(Line("PLAY")), Color::BLUE, - Color::ORANGE, + colors::HOVERING, hotkey(Key::Space), "start game", ctx, diff --git a/game/src/sandbox/dashboards.rs b/game/src/sandbox/dashboards.rs index 44b9a3363e..b0c37b3527 100644 --- a/game/src/sandbox/dashboards.rs +++ b/game/src/sandbox/dashboards.rs @@ -1,3 +1,4 @@ +use crate::colors; use crate::common::ShowBusRoute; use crate::game::{State, Transition}; use crate::helpers::ID; @@ -59,7 +60,7 @@ pub fn make(ctx: &mut EventCtx, ui: &UI, tab: Tab) -> Box { Composite::new(ManagedWidget::col(vec![ ManagedWidget::row(tabs) .evenly_spaced() - .bg(Color::grey(0.6)) + .bg(colors::PANEL_BG) .padding(10), content, ])) @@ -151,7 +152,7 @@ fn finished_trips_summary_prebaked(ctx: &EventCtx, ui: &UI) -> ManagedWidget { // TODO The x-axes for the plot and histogram get stretched to the full screen. Don't do that! ManagedWidget::col(vec![ ManagedWidget::draw_text(ctx, txt), - finished_trips_plot(ctx, ui).bg(Color::grey(0.3)), + finished_trips_plot(ctx, ui).bg(colors::SECTION_BG), ManagedWidget::draw_text( ctx, Text::from(Line( @@ -165,7 +166,7 @@ fn finished_trips_summary_prebaked(ctx: &EventCtx, ui: &UI) -> ManagedWidget { .finished_trip_deltas(ui.primary.sim.time(), ui.prebaked()), ctx, ) - .bg(Color::grey(0.3)), + .bg(colors::SECTION_BG), ]) } @@ -213,7 +214,7 @@ fn finished_trips_summary_not_prebaked(ctx: &EventCtx, ui: &UI) -> ManagedWidget // TODO The x-axes for the plot and histogram get stretched to the full screen. Don't do that! ManagedWidget::col(vec![ ManagedWidget::draw_text(ctx, txt), - finished_trips_plot(ctx, ui).bg(Color::grey(0.3)), + finished_trips_plot(ctx, ui).bg(colors::SECTION_BG), ]) } diff --git a/game/src/sandbox/gameplay/freeform.rs b/game/src/sandbox/gameplay/freeform.rs index c81f0c9e4a..177e35ed08 100644 --- a/game/src/sandbox/gameplay/freeform.rs +++ b/game/src/sandbox/gameplay/freeform.rs @@ -1,3 +1,4 @@ +use crate::colors; use crate::edit::EditMode; use crate::game::{State, Transition, WizardState}; use crate::helpers::{nice_map_name, ID}; @@ -114,7 +115,7 @@ pub fn freeform_controller( .margin(5), ]) .centered() - .bg(Color::grey(0.4)), + .bg(colors::PANEL_BG), ) .aligned(HorizontalAlignment::Center, VerticalAlignment::Top) .build(ctx), diff --git a/game/src/sandbox/gameplay/mod.rs b/game/src/sandbox/gameplay/mod.rs index e8640503fd..9760caec83 100644 --- a/game/src/sandbox/gameplay/mod.rs +++ b/game/src/sandbox/gameplay/mod.rs @@ -10,6 +10,7 @@ mod tutorial; pub use self::tutorial::{Tutorial, TutorialState}; use crate::challenges; use crate::challenges::challenges_picker; +use crate::colors; use crate::common::{CommonState, Overlays}; use crate::edit::EditMode; use crate::game::{msg, State, Transition}; @@ -312,7 +313,7 @@ fn challenge_controller( rows.extend(extra_rows); WrappedComposite::new( - Composite::new(ManagedWidget::col(rows).bg(Color::grey(0.4))) + Composite::new(ManagedWidget::col(rows).bg(colors::PANEL_BG)) .aligned(HorizontalAlignment::Center, VerticalAlignment::Top) .build(ctx), ) @@ -352,7 +353,7 @@ impl FinalScore { ]) .centered(), ]) - .bg(Color::grey(0.4)) + .bg(colors::PANEL_BG) .outline(10.0, Color::WHITE) .padding(10), ) diff --git a/game/src/sandbox/gameplay/tutorial.rs b/game/src/sandbox/gameplay/tutorial.rs index b3f352f4ab..143963a941 100644 --- a/game/src/sandbox/gameplay/tutorial.rs +++ b/game/src/sandbox/gameplay/tutorial.rs @@ -1,3 +1,4 @@ +use crate::colors; use crate::common::{tool_panel, Minimap, Overlays, Warping}; use crate::edit::EditMode; use crate::game::{msg, Transition}; @@ -690,7 +691,7 @@ impl TutorialState { ); } - Composite::new(ManagedWidget::col(col).bg(Color::grey(0.4))) + Composite::new(ManagedWidget::col(col).bg(colors::PANEL_BG)) .aligned(HorizontalAlignment::Center, VerticalAlignment::Top) .build(ctx) } @@ -742,7 +743,7 @@ impl TutorialState { WrappedComposite::text_button(ctx, "OK", hotkey(Key::Enter)) .centered_horiz(), ]) - .bg(Color::grey(0.4)) + .bg(colors::PANEL_BG) .outline(5.0, Color::WHITE) .padding(5), ) diff --git a/game/src/sandbox/mod.rs b/game/src/sandbox/mod.rs index dee27073ef..d55200a158 100644 --- a/game/src/sandbox/mod.rs +++ b/game/src/sandbox/mod.rs @@ -2,6 +2,7 @@ mod dashboards; mod gameplay; mod speed; +use crate::colors; use crate::common::{tool_panel, CommonState, Minimap, Overlays, ShowBusRoute}; use crate::debug::DebugMode; use crate::edit::{apply_map_edits, save_edits, EditMode, StopSignEditor, TrafficSignalEditor}; @@ -14,8 +15,8 @@ use crate::sandbox::gameplay::Tutorial; pub use crate::sandbox::gameplay::TutorialState; use crate::ui::{ShowEverything, UI}; use ezgui::{ - hotkey, lctrl, Choice, Color, Composite, EventCtx, EventLoopMode, GfxCtx, HorizontalAlignment, - Key, Line, ManagedWidget, Outcome, Text, VerticalAlignment, Wizard, + hotkey, lctrl, Choice, Composite, EventCtx, EventLoopMode, GfxCtx, HorizontalAlignment, Key, + Line, ManagedWidget, Outcome, Text, VerticalAlignment, Wizard, }; pub use gameplay::spawner::spawn_agents_around; pub use gameplay::GameplayMode; @@ -368,7 +369,7 @@ impl AgentMeter { // TODO The SVG button uses clip and doesn't seem to work WrappedComposite::text_button(ctx, "view finished trip data", hotkey(Key::Q)), ]) - .bg(Color::grey(0.4)) + .bg(colors::PANEL_BG) .padding(20), ) .aligned(HorizontalAlignment::Right, VerticalAlignment::Top) diff --git a/game/src/sandbox/speed.rs b/game/src/sandbox/speed.rs index 1621ad2289..bbb34bfef6 100644 --- a/game/src/sandbox/speed.rs +++ b/game/src/sandbox/speed.rs @@ -1,3 +1,4 @@ +use crate::colors; use crate::game::{State, Transition, WizardState}; use crate::managed::{WrappedComposite, WrappedOutcome}; use crate::ui::UI; @@ -29,8 +30,6 @@ enum SpeedSetting { impl SpeedControls { fn make_panel(ctx: &mut EventCtx, paused: bool, setting: SpeedSetting) -> WrappedComposite { - let bg = Color::hex("#7C7C7C"); - let mut row = Vec::new(); row.push( ManagedWidget::btn(if paused { @@ -38,7 +37,7 @@ impl SpeedControls { "assets/speed/triangle.svg", "play", hotkey(Key::Space), - RewriteColor::ChangeAll(Color::ORANGE), + RewriteColor::ChangeAll(colors::HOVERING), ctx, ) } else { @@ -46,13 +45,13 @@ impl SpeedControls { "assets/speed/pause.svg", "pause", hotkey(Key::Space), - RewriteColor::ChangeAll(Color::ORANGE), + RewriteColor::ChangeAll(colors::HOVERING), ctx, ) }) .margin(5) .centered_vert() - .bg(bg), + .bg(colors::SECTION_BG), ); row.push( @@ -74,14 +73,14 @@ impl SpeedControls { } else { RewriteColor::ChangeAll(Color::WHITE.alpha(0.2)) }, - RewriteColor::ChangeAll(Color::ORANGE), + RewriteColor::ChangeAll(colors::HOVERING), ctx, )) .margin(5) }) .collect(), ) - .bg(bg) + .bg(colors::SECTION_BG) .centered(), ); @@ -90,7 +89,7 @@ impl SpeedControls { vec![ ManagedWidget::btn(Button::text_no_bg( Text::from(Line("+0.1s").fg(Color::WHITE).size(21).roboto()), - Text::from(Line("+0.1s").fg(Color::ORANGE).size(21).roboto()), + Text::from(Line("+0.1s").fg(colors::HOVERING).size(21).roboto()), hotkey(Key::M), "step forwards 0.1 seconds", false, @@ -98,7 +97,7 @@ impl SpeedControls { )), ManagedWidget::btn(Button::text_no_bg( Text::from(Line("+1h").fg(Color::WHITE).size(21).roboto()), - Text::from(Line("+1h").fg(Color::ORANGE).size(21).roboto()), + Text::from(Line("+1h").fg(colors::HOVERING).size(21).roboto()), hotkey(Key::N), "step forwards 1 hour", false, @@ -108,14 +107,14 @@ impl SpeedControls { "assets/speed/jump_to_time.svg", "jump to specific time", hotkey(Key::B), - RewriteColor::ChangeAll(Color::ORANGE), + RewriteColor::ChangeAll(colors::HOVERING), ctx, )), ManagedWidget::btn(Button::rectangle_svg( "assets/speed/reset.svg", "reset to midnight", hotkey(Key::X), - RewriteColor::ChangeAll(Color::ORANGE), + RewriteColor::ChangeAll(colors::HOVERING), ctx, )), ] @@ -123,14 +122,14 @@ impl SpeedControls { .map(|x| x.margin(5)) .collect(), ) - .bg(bg) + .bg(colors::SECTION_BG) .centered(), ); WrappedComposite::new( Composite::new( ManagedWidget::row(row.into_iter().map(|x| x.margin(5)).collect()) - .bg(Color::hex("#4C4C4C")), + .bg(colors::PANEL_BG), ) .aligned( HorizontalAlignment::Center, @@ -395,7 +394,7 @@ impl TimePanel { batch.push(Color::WHITE, Polygon::rectangle(width, height)); if percent != 0.0 { batch.push( - Color::grey(0.5), + colors::SECTION_BG, Polygon::rectangle(percent * width, height), ); } @@ -412,7 +411,7 @@ impl TimePanel { .evenly_spaced(), ]) .padding(10) - .bg(Color::hex("#4C4C4C")), + .bg(colors::PANEL_BG), ) .aligned(HorizontalAlignment::Left, VerticalAlignment::Top) .build(ctx),