From 008c63cd1a357e2e22a224ead7b2f912977c74cc Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Sat, 15 Sep 2018 09:11:06 -0700 Subject: [PATCH] passing ctx to both plugins and renderers, so we can debug lanes --- docs/design.md | 6 ++-- editor/src/objects.rs | 13 +++++++- editor/src/plugins/classification.rs | 4 +-- editor/src/plugins/floodfill.rs | 4 +-- editor/src/plugins/mod.rs | 11 +------ editor/src/plugins/search.rs | 4 +-- editor/src/plugins/show_route.rs | 4 +-- editor/src/plugins/steep.rs | 4 +-- editor/src/plugins/stop_sign_editor.rs | 4 +-- editor/src/plugins/traffic_signal_editor.rs | 4 +-- editor/src/plugins/turn_cycler.rs | 4 +-- editor/src/render/building.rs | 8 ++--- editor/src/render/car.rs | 5 ++-- editor/src/render/extra_shape.rs | 5 ++-- editor/src/render/intersection.rs | 26 ++++++++-------- editor/src/render/lane.rs | 28 ++++++++--------- editor/src/render/mod.rs | 5 ++-- editor/src/render/parcel.rs | 5 ++-- editor/src/render/pedestrian.rs | 5 ++-- editor/src/render/turn.rs | 8 ++--- editor/src/ui.rs | 33 ++++++++++++++++++--- 21 files changed, 106 insertions(+), 84 deletions(-) diff --git a/docs/design.md b/docs/design.md index 619f8d63e3..f5a526cd2c 100644 --- a/docs/design.md +++ b/docs/design.md @@ -995,7 +995,9 @@ Alright, replan yet again. - deal with overlapping keys that still kinda happen (sim ctrl, escape game) - bug: do need to recalculate current_selection whenever anything potentially changes camera, like follow -- then rethink colors, with simplified single plugin - - plugin trait, color(id) -> Option. parallel list of box plugins (or, a fxn that takes the idx) += then rethink colors, with simplified single plugin + = plugin trait, color(id) -> Option. parallel list of box plugins (or, a fxn that takes the idx) + - refactor to one color_blah method + - handle the two color things... just buildings? - and see how much boilerplate a new type would need, by adding bus stops and water/parks - consider merging control map into map diff --git a/editor/src/objects.rs b/editor/src/objects.rs index f592ccb2dc..96245d58ed 100644 --- a/editor/src/objects.rs +++ b/editor/src/objects.rs @@ -1,5 +1,8 @@ +use colors::ColorScheme; +use control::ControlMap; +use ezgui::Canvas; use kml::ExtraShapeID; -use map_model::{BuildingID, IntersectionID, LaneID, ParcelID, TurnID}; +use map_model::{BuildingID, IntersectionID, LaneID, Map, ParcelID, TurnID}; use sim::{CarID, PedestrianID}; #[derive(Clone, Copy, Hash, PartialEq, Eq, Debug)] @@ -13,3 +16,11 @@ pub enum ID { ExtraShape(ExtraShapeID), Parcel(ParcelID), } + +// For plugins and rendering. Not sure what module this should live in, here seems fine. +pub struct Ctx<'a> { + pub cs: &'a ColorScheme, + pub map: &'a Map, + pub control_map: &'a ControlMap, + pub canvas: &'a Canvas, +} diff --git a/editor/src/plugins/classification.rs b/editor/src/plugins/classification.rs index 9444efac5e..7955e9a0a0 100644 --- a/editor/src/plugins/classification.rs +++ b/editor/src/plugins/classification.rs @@ -3,9 +3,9 @@ use colors::Colors; use ezgui::UserInput; use graphics::types::Color; -use objects::ID; +use objects::{Ctx, ID}; use piston::input::Key; -use plugins::{Colorizer, Ctx}; +use plugins::Colorizer; // TODO have some UI for editing these rules and saving them pub struct OsmClassifier { diff --git a/editor/src/plugins/floodfill.rs b/editor/src/plugins/floodfill.rs index e9545d7471..d423130fe8 100644 --- a/editor/src/plugins/floodfill.rs +++ b/editor/src/plugins/floodfill.rs @@ -4,9 +4,9 @@ use colors::Colors; use ezgui::UserInput; use graphics::types::Color; use map_model::{LaneID, Map}; -use objects::ID; +use objects::{Ctx, ID}; use piston::input::Key; -use plugins::{Colorizer, Ctx}; +use plugins::Colorizer; use std::collections::{HashSet, VecDeque}; // Keeps track of state so this can be interactively visualized diff --git a/editor/src/plugins/mod.rs b/editor/src/plugins/mod.rs index d7d5af0cad..821c6f601b 100644 --- a/editor/src/plugins/mod.rs +++ b/editor/src/plugins/mod.rs @@ -16,20 +16,11 @@ pub mod turn_colors; pub mod turn_cycler; pub mod warp; -use colors::ColorScheme; -use control::ControlMap; use graphics::types::Color; -use map_model::Map; -use objects::ID; +use objects::{Ctx, ID}; pub trait Colorizer { fn color_for(&self, _obj: ID, _ctx: Ctx) -> Option { None } } - -pub struct Ctx<'a> { - pub cs: &'a ColorScheme, - pub map: &'a Map, - pub control_map: &'a ControlMap, -} diff --git a/editor/src/plugins/search.rs b/editor/src/plugins/search.rs index 594dcd5841..fd38a5a530 100644 --- a/editor/src/plugins/search.rs +++ b/editor/src/plugins/search.rs @@ -3,9 +3,9 @@ use colors::{ColorScheme, Colors}; use ezgui::{TextBox, UserInput}; use graphics::types::Color; -use objects::ID; +use objects::{Ctx, ID}; use piston::input::Key; -use plugins::{Colorizer, Ctx}; +use plugins::Colorizer; use std::collections::BTreeMap; pub enum SearchState { diff --git a/editor/src/plugins/show_route.rs b/editor/src/plugins/show_route.rs index b262fbb284..3f0f75b439 100644 --- a/editor/src/plugins/show_route.rs +++ b/editor/src/plugins/show_route.rs @@ -2,9 +2,9 @@ use colors::Colors; use ezgui::UserInput; use graphics::types::Color; use map_model::LaneID; -use objects::ID; +use objects::{Ctx, ID}; use piston::input::Key; -use plugins::{Colorizer, Ctx}; +use plugins::Colorizer; use sim::{AgentID, Sim}; use std::collections::HashSet; diff --git a/editor/src/plugins/steep.rs b/editor/src/plugins/steep.rs index b4d5d9ee31..8af4ae3ee4 100644 --- a/editor/src/plugins/steep.rs +++ b/editor/src/plugins/steep.rs @@ -5,9 +5,9 @@ use ezgui::UserInput; use graphics::types::Color; use map_model::{Lane, Map}; -use objects::ID; +use objects::{Ctx, ID}; use piston::input::Key; -use plugins::{Colorizer, Ctx}; +use plugins::Colorizer; use std::f64; pub struct SteepnessVisualizer { diff --git a/editor/src/plugins/stop_sign_editor.rs b/editor/src/plugins/stop_sign_editor.rs index 6bbff0c516..0fcf0877bc 100644 --- a/editor/src/plugins/stop_sign_editor.rs +++ b/editor/src/plugins/stop_sign_editor.rs @@ -7,9 +7,9 @@ use ezgui::UserInput; use graphics::types::Color; use map_model::IntersectionID; use map_model::Map; -use objects::ID; +use objects::{Ctx, ID}; use piston::input::Key; -use plugins::{Colorizer, Ctx}; +use plugins::Colorizer; #[derive(PartialEq)] pub enum StopSignEditor { diff --git a/editor/src/plugins/traffic_signal_editor.rs b/editor/src/plugins/traffic_signal_editor.rs index a887d538a8..a4053fc105 100644 --- a/editor/src/plugins/traffic_signal_editor.rs +++ b/editor/src/plugins/traffic_signal_editor.rs @@ -7,9 +7,9 @@ use control::ControlMap; use ezgui::UserInput; use graphics::types::Color; use map_model::{IntersectionID, Map}; -use objects::ID; +use objects::{Ctx, ID}; use piston::input::Key; -use plugins::{Colorizer, Ctx}; +use plugins::Colorizer; #[derive(PartialEq)] pub enum TrafficSignalEditor { diff --git a/editor/src/plugins/turn_cycler.rs b/editor/src/plugins/turn_cycler.rs index 421f331a6f..316c53a7b3 100644 --- a/editor/src/plugins/turn_cycler.rs +++ b/editor/src/plugins/turn_cycler.rs @@ -5,9 +5,9 @@ use control::ControlMap; use ezgui::{GfxCtx, UserInput}; use graphics::types::Color; use map_model::{IntersectionID, LaneID, Map}; -use objects::ID; +use objects::{Ctx, ID}; use piston::input::Key; -use plugins::{Colorizer, Ctx}; +use plugins::Colorizer; use render::DrawMap; use sim::Sim; diff --git a/editor/src/render/building.rs b/editor/src/render/building.rs index 94dd8133c1..5e16d3c77b 100644 --- a/editor/src/render/building.rs +++ b/editor/src/render/building.rs @@ -1,12 +1,12 @@ // Copyright 2018 Google LLC, licensed under http://www.apache.org/licenses/LICENSE-2.0 use aabb_quadtree::geom::Rect; -use colors::{ColorScheme, Colors}; +use colors::Colors; use ezgui::GfxCtx; use geom::{PolyLine, Polygon, Pt2D}; use graphics; use map_model::{Building, BuildingID, Map}; -use objects::ID; +use objects::{Ctx, ID}; use render::{get_bbox, RenderOptions, Renderable, BUILDING_BOUNDARY_THICKNESS}; use std::f64; @@ -40,13 +40,13 @@ impl Renderable for DrawBuilding { } // TODO need two colors here - fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, cs: &ColorScheme) { + fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: Ctx) { //g.draw_polygon(boundary_color, &self.boundary_polygon); g.draw_polygon(opts.color, &self.fill_polygon); // TODO tune width g.draw_line( - &graphics::Line::new_round(cs.get(Colors::BuildingPath), 1.0), + &graphics::Line::new_round(ctx.cs.get(Colors::BuildingPath), 1.0), self.front_path, ); } diff --git a/editor/src/render/car.rs b/editor/src/render/car.rs index 700afa647a..8a095c6a30 100644 --- a/editor/src/render/car.rs +++ b/editor/src/render/car.rs @@ -1,11 +1,10 @@ use aabb_quadtree::geom::Rect; -use colors::ColorScheme; use dimensioned::si; use ezgui::GfxCtx; use geom::{Polygon, Pt2D}; use graphics; use map_model::{geometry, Map}; -use objects::ID; +use objects::{Ctx, ID}; use render::{get_bbox, RenderOptions, Renderable}; use sim::{CarID, DrawCarInput}; @@ -99,7 +98,7 @@ impl Renderable for DrawCar { ID::Car(self.id) } - fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, _cs: &ColorScheme) { + fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, _ctx: Ctx) { g.draw_polygon(opts.color, &self.body_polygon); for p in &self.window_polygons { g.draw_polygon([0.0, 0.0, 0.0, 1.0], p); diff --git a/editor/src/render/extra_shape.rs b/editor/src/render/extra_shape.rs index 37bfc87673..a057c0e99a 100644 --- a/editor/src/render/extra_shape.rs +++ b/editor/src/render/extra_shape.rs @@ -1,10 +1,9 @@ use aabb_quadtree::geom::Rect; -use colors::ColorScheme; use ezgui::GfxCtx; use geom::{Polygon, Pt2D}; use kml::{ExtraShape, ExtraShapeGeom, ExtraShapeID}; use map_model::{geometry, Map}; -use objects::ID; +use objects::{Ctx, ID}; use render::{ get_bbox, RenderOptions, Renderable, EXTRA_SHAPE_POINT_RADIUS, EXTRA_SHAPE_THICKNESS, }; @@ -45,7 +44,7 @@ impl Renderable for DrawExtraShape { ID::ExtraShape(self.id) } - fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, _cs: &ColorScheme) { + fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, _ctx: Ctx) { match self.shape { Shape::Polygon(ref p) => g.draw_polygon(opts.color, &p), Shape::Circle(c) => g.draw_ellipse(opts.color, c), diff --git a/editor/src/render/intersection.rs b/editor/src/render/intersection.rs index 3783231950..048ead85a4 100644 --- a/editor/src/render/intersection.rs +++ b/editor/src/render/intersection.rs @@ -1,14 +1,14 @@ // Copyright 2018 Google LLC, licensed under http://www.apache.org/licenses/LICENSE-2.0 use aabb_quadtree::geom::Rect; -use colors::{ColorScheme, Colors}; +use colors::Colors; use dimensioned::si; use ezgui::GfxCtx; use geom::{Line, Polygon, Pt2D}; use graphics; use graphics::math::Vec2d; use map_model::{geometry, Intersection, IntersectionID, LaneType, Map}; -use objects::ID; +use objects::{Ctx, ID}; use render::{get_bbox, DrawLane, RenderOptions, Renderable}; use std::f64; @@ -50,20 +50,20 @@ impl DrawIntersection { } } - fn draw_stop_sign(&self, g: &mut GfxCtx, cs: &ColorScheme) { + fn draw_stop_sign(&self, g: &mut GfxCtx, ctx: Ctx) { // TODO rotate it g.draw_polygon( - cs.get(Colors::StopSignBackground), + ctx.cs.get(Colors::StopSignBackground), &geometry::regular_polygon(self.center, 8, 1.5), ); // TODO draw "STOP" } - fn draw_traffic_signal(&self, g: &mut GfxCtx, cs: &ColorScheme) { + fn draw_traffic_signal(&self, g: &mut GfxCtx, ctx: Ctx) { let radius = 0.5; g.draw_rectangle( - cs.get(Colors::TrafficSignalBox), + ctx.cs.get(Colors::TrafficSignalBox), [ self.center.x() - (2.0 * radius), self.center.y() - (4.0 * radius), @@ -73,17 +73,17 @@ impl DrawIntersection { ); g.draw_ellipse( - cs.get(Colors::TrafficSignalYellow), + ctx.cs.get(Colors::TrafficSignalYellow), geometry::make_circle(self.center, radius), ); g.draw_ellipse( - cs.get(Colors::TrafficSignalGreen), + ctx.cs.get(Colors::TrafficSignalGreen), geometry::make_circle(self.center.offset(0.0, radius * 2.0), radius), ); g.draw_ellipse( - cs.get(Colors::TrafficSignalRed), + ctx.cs.get(Colors::TrafficSignalRed), geometry::make_circle(self.center.offset(0.0, radius * -2.0), radius), ); } @@ -94,11 +94,11 @@ impl Renderable for DrawIntersection { ID::Intersection(self.id) } - fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, cs: &ColorScheme) { + fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: Ctx) { g.draw_polygon(opts.color, &self.polygon); let crosswalk_marking = graphics::Line::new( - cs.get(Colors::Crosswalk), + ctx.cs.get(Colors::Crosswalk), // TODO move this somewhere 0.25, ); @@ -112,9 +112,9 @@ impl Renderable for DrawIntersection { } if self.has_traffic_signal { - self.draw_traffic_signal(g, cs); + self.draw_traffic_signal(g, ctx); } else { - self.draw_stop_sign(g, cs); + self.draw_stop_sign(g, ctx); } } diff --git a/editor/src/render/lane.rs b/editor/src/render/lane.rs index 36acc8f3e5..278cbd9ebd 100644 --- a/editor/src/render/lane.rs +++ b/editor/src/render/lane.rs @@ -1,15 +1,15 @@ // Copyright 2018 Google LLC, licensed under http://www.apache.org/licenses/LICENSE-2.0 use aabb_quadtree::geom::Rect; -use colors::{ColorScheme, Colors}; +use colors::Colors; use control::ControlMap; use dimensioned::si; -use ezgui::{Canvas, GfxCtx}; +use ezgui::GfxCtx; use geom::{Line, Polygon, Pt2D}; use graphics; use map_model; use map_model::{geometry, LaneID}; -use objects::ID; +use objects::{Ctx, ID}; use render::{get_bbox, RenderOptions, Renderable, PARCEL_BOUNDARY_THICKNESS}; const MIN_ZOOM_FOR_LANE_MARKERS: f64 = 5.0; @@ -88,14 +88,12 @@ impl DrawLane { } } - // TODO can't easily call this with generic quadtree - #[allow(dead_code)] - fn draw_debug(&self, g: &mut GfxCtx, canvas: &Canvas, cs: &ColorScheme, l: &map_model::Lane) { + fn draw_debug(&self, g: &mut GfxCtx, ctx: Ctx) { let line = - graphics::Line::new_round(cs.get(Colors::Debug), PARCEL_BOUNDARY_THICKNESS / 2.0); - let circle_color = cs.get(Colors::BrightDebug); + graphics::Line::new_round(ctx.cs.get(Colors::Debug), PARCEL_BOUNDARY_THICKNESS / 2.0); + let circle_color = ctx.cs.get(Colors::BrightDebug); - for pair in l.lane_center_pts.points().windows(2) { + for pair in ctx.map.get_l(self.id).lane_center_pts.points().windows(2) { let (pt1, pt2) = (pair[0], pair[1]); g.draw_line(&line, [pt1.x(), pt1.y(), pt2.x(), pt2.y()]); g.draw_ellipse(circle_color, geometry::make_circle(pt1, 0.4)); @@ -103,7 +101,8 @@ impl DrawLane { } for pt in &self.draw_id_at { - canvas.draw_text_at(g, &vec![format!("{}", self.id.0)], pt.x(), pt.y()); + ctx.canvas + .draw_text_at(g, &vec![format!("{}", self.id.0)], pt.x(), pt.y()); } } @@ -122,15 +121,15 @@ impl Renderable for DrawLane { ID::Lane(self.id) } - fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, cs: &ColorScheme) { + fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: Ctx) { g.draw_polygon(opts.color, &self.polygon); if opts.cam_zoom >= MIN_ZOOM_FOR_LANE_MARKERS { for m in &self.markings { let line = if m.round { - graphics::Line::new_round(cs.get(m.color), m.thickness) + graphics::Line::new_round(ctx.cs.get(m.color), m.thickness) } else { - graphics::Line::new(cs.get(m.color), m.thickness) + graphics::Line::new(ctx.cs.get(m.color), m.thickness) }; for pts in &m.lines { g.draw_line(&line, *pts); @@ -139,8 +138,7 @@ impl Renderable for DrawLane { } if opts.debug_mode { - // TODO Don't have canvas and map available in draw()... - //self.draw_debug(g, canvas, cs, map.get_l(self.id)); + self.draw_debug(g, ctx); } } diff --git a/editor/src/render/mod.rs b/editor/src/render/mod.rs index 20552957c1..74442d6bb6 100644 --- a/editor/src/render/mod.rs +++ b/editor/src/render/mod.rs @@ -11,12 +11,11 @@ mod pedestrian; mod turn; use aabb_quadtree::geom::{Point, Rect}; -use colors::ColorScheme; use ezgui::GfxCtx; use geom::{Bounds, Pt2D}; use graphics::types::Color; use map_model::{geometry, Map}; -use objects::ID; +use objects::{Ctx, ID}; pub use render::car::DrawCar; pub use render::lane::DrawLane; pub use render::map::DrawMap; @@ -50,7 +49,7 @@ pub fn get_bbox(b: &Bounds) -> Rect { pub trait Renderable { fn get_id(&self) -> ID; - fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, cs: &ColorScheme); + fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: Ctx); // TODO Maybe return Bounds fn get_bbox(&self) -> Rect; fn contains_pt(&self, pt: Pt2D) -> bool; diff --git a/editor/src/render/parcel.rs b/editor/src/render/parcel.rs index 4cac708fc2..85445fbe3b 100644 --- a/editor/src/render/parcel.rs +++ b/editor/src/render/parcel.rs @@ -1,11 +1,10 @@ // Copyright 2018 Google LLC, licensed under http://www.apache.org/licenses/LICENSE-2.0 use aabb_quadtree::geom::Rect; -use colors::ColorScheme; use ezgui::GfxCtx; use geom::{PolyLine, Polygon, Pt2D}; use map_model::{Map, Parcel, ParcelID}; -use objects::ID; +use objects::{Ctx, ID}; use render::{get_bbox, RenderOptions, Renderable, PARCEL_BOUNDARY_THICKNESS}; #[derive(Debug)] @@ -32,7 +31,7 @@ impl Renderable for DrawParcel { ID::Parcel(self.id) } - fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, _cs: &ColorScheme) { + fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, _ctx: Ctx) { g.draw_polygon(opts.color, &self.fill_polygon); } diff --git a/editor/src/render/pedestrian.rs b/editor/src/render/pedestrian.rs index 77a994ea53..b8ec8312fd 100644 --- a/editor/src/render/pedestrian.rs +++ b/editor/src/render/pedestrian.rs @@ -1,10 +1,9 @@ use aabb_quadtree::geom::Rect; -use colors::ColorScheme; use ezgui::GfxCtx; use geom::Pt2D; use graphics; use map_model::{geometry, Map}; -use objects::ID; +use objects::{Ctx, ID}; use render::{RenderOptions, Renderable}; use sim::{DrawPedestrianInput, PedestrianID}; @@ -41,7 +40,7 @@ impl Renderable for DrawPedestrian { ID::Pedestrian(self.id) } - fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, _cs: &ColorScheme) { + fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, _ctx: Ctx) { g.draw_ellipse(opts.color, self.circle); // TODO tune color, sizes diff --git a/editor/src/render/turn.rs b/editor/src/render/turn.rs index ef5f1380c0..0df15120a8 100644 --- a/editor/src/render/turn.rs +++ b/editor/src/render/turn.rs @@ -1,7 +1,7 @@ // Copyright 2018 Google LLC, licensed under http://www.apache.org/licenses/LICENSE-2.0 use aabb_quadtree::geom::Rect; -use colors::{ColorScheme, Colors}; +use colors::Colors; use dimensioned::si; use ezgui::GfxCtx; use geom::Pt2D; @@ -9,7 +9,7 @@ use graphics; use graphics::math::Vec2d; use graphics::types::Color; use map_model::{geometry, Map, Turn, TurnID}; -use objects::ID; +use objects::{Ctx, ID}; use render::{ RenderOptions, Renderable, BIG_ARROW_TIP_LENGTH, TURN_ICON_ARROW_LENGTH, TURN_ICON_ARROW_THICKNESS, TURN_ICON_ARROW_TIP_LENGTH, @@ -78,8 +78,8 @@ impl Renderable for DrawTurn { ID::Turn(self.id) } - fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, cs: &ColorScheme) { - g.draw_ellipse(cs.get(Colors::TurnIconCircle), self.icon_circle); + fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: Ctx) { + g.draw_ellipse(ctx.cs.get(Colors::TurnIconCircle), self.icon_circle); g.draw_arrow( &graphics::Line::new_round(opts.color, TURN_ICON_ARROW_THICKNESS), diff --git a/editor/src/ui.rs b/editor/src/ui.rs index 75add77ba9..2a2ca597b2 100644 --- a/editor/src/ui.rs +++ b/editor/src/ui.rs @@ -13,7 +13,7 @@ use graphics::types::Color; use kml; use map_model; use map_model::IntersectionID; -use objects::ID; +use objects::{Ctx, ID}; use piston::input::{Key, MouseCursorEvent}; use piston::window::Size; use plugins::classification::OsmClassifier; @@ -33,7 +33,7 @@ use plugins::traffic_signal_editor::TrafficSignalEditor; use plugins::turn_colors::TurnColors; use plugins::turn_cycler::TurnCyclerState; use plugins::warp::WarpState; -use plugins::{Colorizer, Ctx}; +use plugins::Colorizer; use render::{DrawMap, RenderOptions}; use sim; use sim::{CarID, CarState, PedestrianID, Sim}; @@ -332,6 +332,7 @@ impl UI { cs: &self.cs, map: &self.map, control_map: &self.control_map, + canvas: &self.canvas, }, ) { return c; @@ -363,6 +364,7 @@ impl UI { cs: &self.cs, map: &self.map, control_map: &self.control_map, + canvas: &self.canvas, }, ) { return c; @@ -395,6 +397,7 @@ impl UI { cs: &self.cs, map: &self.map, control_map: &self.control_map, + canvas: &self.canvas, }, ) { return c; @@ -417,6 +420,7 @@ impl UI { cs: &self.cs, map: &self.map, control_map: &self.control_map, + canvas: &self.canvas, }, ) { return c; @@ -437,6 +441,7 @@ impl UI { cs: &self.cs, map: &self.map, control_map: &self.control_map, + canvas: &self.canvas, }, ) { return c; @@ -476,6 +481,7 @@ impl UI { cs: &self.cs, map: &self.map, control_map: &self.control_map, + canvas: &self.canvas, }, ) { return c; @@ -502,6 +508,7 @@ impl UI { cs: &self.cs, map: &self.map, control_map: &self.control_map, + canvas: &self.canvas, }, ) { return c; @@ -620,7 +627,16 @@ impl UI { cam_zoom: self.canvas.cam_zoom, debug_mode: self.layers.debug_mode.is_enabled(), }; - obj.draw(g, opts, &self.cs); + obj.draw( + g, + opts, + Ctx { + cs: &self.cs, + map: &self.map, + control_map: &self.control_map, + canvas: &self.canvas, + }, + ); } for obj in dynamics.into_iter() { let color = match obj.get_id() { @@ -633,7 +649,16 @@ impl UI { cam_zoom: self.canvas.cam_zoom, debug_mode: self.layers.debug_mode.is_enabled(), }; - obj.draw(g, opts, &self.cs); + obj.draw( + g, + opts, + Ctx { + cs: &self.cs, + map: &self.map, + control_map: &self.control_map, + canvas: &self.canvas, + }, + ); } self.turn_cycler.draw(