From f59b7386924f3d003bb3f07e27d27bec0e7992ed Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Thu, 17 Sep 2020 15:06:35 -0700 Subject: [PATCH] Simplify traffic signal rendering before big turn icon overhaul by removing some older styles. --- game/src/edit/traffic_signals/mod.rs | 2 +- game/src/info/intersection.rs | 2 +- game/src/options.rs | 24 ++--------- game/src/render/traffic_signal.rs | 63 ++-------------------------- 4 files changed, 9 insertions(+), 82 deletions(-) diff --git a/game/src/edit/traffic_signals/mod.rs b/game/src/edit/traffic_signals/mod.rs index 889e70f4bf..be2d465d7f 100644 --- a/game/src/edit/traffic_signals/mod.rs +++ b/game/src/edit/traffic_signals/mod.rs @@ -871,7 +871,7 @@ fn draw_multiple_signals( None, &mut piece, app, - TrafficSignalStyle::Sidewalks, + TrafficSignalStyle::Yuwen, ); if members.len() > 1 && hovering.map(|x| x == *i).unwrap_or(false) { // TODO This makes the side-panel jump a little, because the outline slightly increases diff --git a/game/src/info/intersection.rs b/game/src/info/intersection.rs index 2e8c10a086..61cda753ec 100644 --- a/game/src/info/intersection.rs +++ b/game/src/info/intersection.rs @@ -283,7 +283,7 @@ pub fn traffic_signal( None, &mut orig_batch, app, - TrafficSignalStyle::Sidewalks, + TrafficSignalStyle::Yuwen, ); let mut normal = GeomBatch::new(); diff --git a/game/src/options.rs b/game/src/options.rs index 19e830c75b..aa4a376376 100644 --- a/game/src/options.rs +++ b/game/src/options.rs @@ -53,9 +53,7 @@ impl Options { #[derive(Clone, PartialEq, Debug)] pub enum TrafficSignalStyle { BAP, - GroupArrows, - Sidewalks, - Icons, + Yuwen, IndividualTurnArrows, } @@ -127,24 +125,8 @@ impl OptionsPanel { "Traffic signal rendering", app.opts.traffic_signal_style.clone(), vec![ - Choice::new( - "Brian's variation of arrows showing the protected and \ - permitted movements", - TrafficSignalStyle::BAP, - ), - Choice::new( - "arrows showing the protected and permitted movements", - TrafficSignalStyle::GroupArrows, - ), - Choice::new( - "arrows showing the protected and permitted movements, with \ - sidewalks", - TrafficSignalStyle::Sidewalks, - ), - Choice::new( - "icons for movements (like the editor UI)", - TrafficSignalStyle::Icons, - ), + Choice::new("Default (Brian's style)", TrafficSignalStyle::BAP), + Choice::new("Yuwen's style", TrafficSignalStyle::Yuwen), Choice::new( "arrows showing individual turns (to debug)", TrafficSignalStyle::IndividualTurnArrows, diff --git a/game/src/render/traffic_signal.rs b/game/src/render/traffic_signal.rs index 8313ea7fed..6fd383fea6 100644 --- a/game/src/render/traffic_signal.rs +++ b/game/src/render/traffic_signal.rs @@ -1,7 +1,7 @@ use crate::app::App; use crate::options::TrafficSignalStyle; use crate::render::intersection::make_crosswalk; -use crate::render::{DrawMovement, BIG_ARROW_THICKNESS}; +use crate::render::BIG_ARROW_THICKNESS; use geom::{Angle, ArrowCap, Circle, Distance, Duration, Line, PolyLine, Pt2D}; use map_model::{IntersectionID, Stage, TurnPriority, SIDEWALK_THICKNESS}; use std::collections::BTreeSet; @@ -137,53 +137,7 @@ pub fn draw_signal_stage( // No time_left box return; } - TrafficSignalStyle::GroupArrows => { - for m in &stage.yield_movements { - assert!(!m.crosswalk); - let arrow = signal.movements[m] - .geom - .make_arrow(BIG_ARROW_THICKNESS * 2.0, ArrowCap::Triangle); - batch.push(app.cs.signal_permitted_turn.alpha(0.3), arrow.clone()); - if let Ok(p) = arrow.to_outline(BIG_ARROW_THICKNESS / 2.0) { - batch.push(app.cs.signal_permitted_turn, p); - } - } - let mut dont_walk = BTreeSet::new(); - for m in signal.movements.keys() { - if m.crosswalk { - dont_walk.insert(m); - } - } - for m in &stage.protected_movements { - if !m.crosswalk { - batch.push( - app.cs.signal_protected_turn, - signal.movements[m] - .geom - .make_arrow(BIG_ARROW_THICKNESS * 2.0, ArrowCap::Triangle), - ); - } else { - let (center, angle) = crosswalk_icon(&signal.movements[m].geom); - batch.append( - GeomBatch::load_svg(prerender, "system/assets/map/walk.svg") - .scale(0.07) - .centered_on(center) - .rotate(angle), - ); - dont_walk.remove(m); - } - } - for m in dont_walk { - let (center, angle) = crosswalk_icon(&signal.movements[m].geom); - batch.append( - GeomBatch::load_svg(prerender, "system/assets/map/dont_walk.svg") - .scale(0.07) - .centered_on(center) - .rotate(angle), - ); - } - } - TrafficSignalStyle::Sidewalks => { + TrafficSignalStyle::Yuwen => { for m in &stage.yield_movements { assert!(!m.crosswalk); let arrow = signal.movements[m] @@ -196,6 +150,8 @@ pub fn draw_signal_stage( } for m in &stage.protected_movements { if m.crosswalk { + // TODO This only works on the side panel. On the full map, the crosswalks are + // always drawn, so this awkwardly doubles some of them. make_crosswalk( batch, app.primary.map.get_t(signal.movements[m].members[0]), @@ -212,17 +168,6 @@ pub fn draw_signal_stage( } } } - TrafficSignalStyle::Icons => { - for m in DrawMovement::for_i(i, &app.primary.map) { - batch.push(app.cs.signal_turn_block_bg, m.block.clone()); - let arrow_color = match stage.get_priority_of_movement(m.id) { - TurnPriority::Protected => app.cs.signal_protected_turn, - TurnPriority::Yield => app.cs.signal_permitted_turn.alpha(1.0), - TurnPriority::Banned => app.cs.signal_banned_turn, - }; - batch.push(arrow_color, m.arrow.clone()); - } - } TrafficSignalStyle::IndividualTurnArrows => { for turn in app.primary.map.get_turns_in_intersection(i) { if turn.between_sidewalks() {