mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-29 17:34:58 +03:00
show full turn of current selected icon
This commit is contained in:
parent
1aabbb1e32
commit
16a4607aca
@ -1,11 +1,11 @@
|
||||
use dimensioned::si;
|
||||
use ezgui::{Color, GfxCtx, Text, Wizard};
|
||||
use geom::{Bounds, Polygon, Pt2D};
|
||||
use map_model::{IntersectionID, TurnPriority};
|
||||
use map_model::{IntersectionID, TurnID, TurnPriority};
|
||||
use objects::{Ctx, ID};
|
||||
use piston::input::Key;
|
||||
use plugins::{Plugin, PluginCtx};
|
||||
use render::draw_signal_cycle;
|
||||
use render::{draw_signal_cycle, DrawTurn};
|
||||
use std::collections::HashSet;
|
||||
|
||||
pub enum TrafficSignalEditor {
|
||||
@ -14,6 +14,7 @@ pub enum TrafficSignalEditor {
|
||||
i: IntersectionID,
|
||||
current_cycle: usize,
|
||||
cycle_duration_wizard: Option<Wizard>,
|
||||
icon_selected: Option<TurnID>,
|
||||
},
|
||||
}
|
||||
|
||||
@ -49,6 +50,7 @@ impl Plugin for TrafficSignalEditor {
|
||||
i: id,
|
||||
current_cycle: 0,
|
||||
cycle_duration_wizard: None,
|
||||
icon_selected: None,
|
||||
};
|
||||
return true;
|
||||
}
|
||||
@ -64,6 +66,7 @@ impl Plugin for TrafficSignalEditor {
|
||||
i,
|
||||
current_cycle,
|
||||
ref mut cycle_duration_wizard,
|
||||
ref mut icon_selected,
|
||||
} => {
|
||||
ctx.hints.suppress_traffic_signal_icon = Some(*i);
|
||||
ctx.hints.hide_crosswalks.extend(
|
||||
@ -95,6 +98,11 @@ impl Plugin for TrafficSignalEditor {
|
||||
} else if input.key_pressed(Key::Return, "quit the editor") {
|
||||
new_state = Some(TrafficSignalEditor::Inactive);
|
||||
} else {
|
||||
*icon_selected = match selected {
|
||||
Some(ID::Turn(id)) => Some(id),
|
||||
_ => None,
|
||||
};
|
||||
|
||||
// Change cycles
|
||||
{
|
||||
let cycles = &ctx.primary.map.get_traffic_signal(*i).cycles;
|
||||
@ -165,6 +173,7 @@ impl Plugin for TrafficSignalEditor {
|
||||
i,
|
||||
current_cycle,
|
||||
cycle_duration_wizard,
|
||||
icon_selected,
|
||||
} = self
|
||||
{
|
||||
let cycles = &ctx.map.get_traffic_signal(*i).cycles;
|
||||
@ -257,6 +266,12 @@ impl Plugin for TrafficSignalEditor {
|
||||
|
||||
g.unfork(old_ctx);
|
||||
|
||||
if let Some(id) = icon_selected {
|
||||
// TODO This covers up the original color and makes it a bit hard to see what it is
|
||||
// now. Also looks weird for crosswalks.
|
||||
DrawTurn::draw_full(ctx.map.get_t(*id), g, ctx.cs.get("selected", Color::BLUE));
|
||||
}
|
||||
|
||||
if let Some(wizard) = cycle_duration_wizard {
|
||||
wizard.draw(g, ctx.canvas);
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
use ezgui::{Color, GfxCtx};
|
||||
use geom::{Polygon, Pt2D};
|
||||
use map_model::{IntersectionID, LaneID, Turn, TurnType};
|
||||
use map_model::{IntersectionID, LaneID, TurnType};
|
||||
use objects::{Ctx, ID};
|
||||
use piston::input::Key;
|
||||
use plugins::{Plugin, PluginCtx};
|
||||
use render::{draw_signal_cycle, BIG_ARROW_THICKNESS, BIG_ARROW_TIP_LENGTH};
|
||||
use render::{draw_signal_cycle, DrawTurn};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum TurnCyclerState {
|
||||
@ -81,7 +81,11 @@ impl Plugin for TurnCyclerState {
|
||||
match current_turn_index {
|
||||
Some(idx) => {
|
||||
let turn = relevant_turns[idx % relevant_turns.len()];
|
||||
draw_full(turn, g, ctx.cs.get("current selected turn", Color::RED));
|
||||
DrawTurn::draw_full(
|
||||
turn,
|
||||
g,
|
||||
ctx.cs.get("current selected turn", Color::RED),
|
||||
);
|
||||
}
|
||||
None => for turn in &relevant_turns {
|
||||
let color = match turn.turn_type {
|
||||
@ -93,7 +97,7 @@ impl Plugin for TurnCyclerState {
|
||||
TurnType::Right => ctx.cs.get("right turn", Color::GREEN),
|
||||
TurnType::Left => ctx.cs.get("left turn", Color::RED),
|
||||
}.alpha(0.5);
|
||||
draw_full(turn, g, color);
|
||||
DrawTurn::draw_full(turn, g, color);
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -160,17 +164,3 @@ impl Plugin for TurnCyclerState {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn draw_full(t: &Turn, g: &mut GfxCtx, color: Color) {
|
||||
g.draw_polygon(
|
||||
color,
|
||||
&t.geom.make_polygons(2.0 * BIG_ARROW_THICKNESS).unwrap(),
|
||||
);
|
||||
// And a cap on the arrow
|
||||
g.draw_rounded_arrow(
|
||||
color,
|
||||
BIG_ARROW_THICKNESS,
|
||||
BIG_ARROW_TIP_LENGTH,
|
||||
&t.geom.last_line(),
|
||||
);
|
||||
}
|
||||
|
@ -3,12 +3,12 @@ use dimensioned::si;
|
||||
use ezgui::{Color, GfxCtx};
|
||||
use geom::{Angle, Bounds, Circle, Polygon, Pt2D};
|
||||
use map_model::{
|
||||
Cycle, Intersection, IntersectionID, IntersectionType, Map, Turn, TurnID, TurnType,
|
||||
LANE_THICKNESS,
|
||||
Cycle, Intersection, IntersectionID, IntersectionType, Map, TurnID, TurnType, LANE_THICKNESS,
|
||||
};
|
||||
use objects::{Ctx, ID};
|
||||
use render::{
|
||||
DrawCrosswalk, DrawMap, RenderOptions, Renderable, BIG_ARROW_THICKNESS, BIG_ARROW_TIP_LENGTH,
|
||||
DrawCrosswalk, DrawMap, DrawTurn, RenderOptions, Renderable, BIG_ARROW_THICKNESS,
|
||||
BIG_ARROW_TIP_LENGTH,
|
||||
};
|
||||
use std::collections::HashSet;
|
||||
|
||||
@ -194,7 +194,7 @@ pub fn draw_signal_cycle(
|
||||
for t in &cycle.priority_turns {
|
||||
let turn = map.get_t(*t);
|
||||
if !turn.between_sidewalks() {
|
||||
draw_full(turn, g, priority_color);
|
||||
DrawTurn::draw_full(turn, g, priority_color);
|
||||
}
|
||||
}
|
||||
for t in &cycle.yield_turns {
|
||||
@ -217,18 +217,3 @@ pub fn draw_signal_cycle(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Copied from turn_cycler. Share or inline?
|
||||
fn draw_full(t: &Turn, g: &mut GfxCtx, color: Color) {
|
||||
g.draw_polygon(
|
||||
color,
|
||||
&t.geom.make_polygons(2.0 * BIG_ARROW_THICKNESS).unwrap(),
|
||||
);
|
||||
// And a cap on the arrow
|
||||
g.draw_rounded_arrow(
|
||||
color,
|
||||
BIG_ARROW_THICKNESS,
|
||||
BIG_ARROW_TIP_LENGTH,
|
||||
&t.geom.last_line(),
|
||||
);
|
||||
}
|
||||
|
@ -32,9 +32,9 @@ const PARCEL_BOUNDARY_THICKNESS: f64 = 0.5;
|
||||
const EXTRA_SHAPE_THICKNESS: f64 = 1.0;
|
||||
const EXTRA_SHAPE_POINT_RADIUS: f64 = 1.0;
|
||||
|
||||
pub const BIG_ARROW_THICKNESS: f64 = 0.5;
|
||||
const BIG_ARROW_THICKNESS: f64 = 0.5;
|
||||
const TURN_ICON_ARROW_THICKNESS: f64 = BIG_ARROW_THICKNESS / 3.0;
|
||||
pub const BIG_ARROW_TIP_LENGTH: f64 = 1.0;
|
||||
const BIG_ARROW_TIP_LENGTH: f64 = 1.0;
|
||||
const TURN_ICON_ARROW_TIP_LENGTH: f64 = BIG_ARROW_TIP_LENGTH * 0.8;
|
||||
const TURN_ICON_ARROW_LENGTH: f64 = 2.0;
|
||||
pub const CROSSWALK_LINE_THICKNESS: f64 = 0.25;
|
||||
|
@ -4,8 +4,8 @@ use geom::{Bounds, Circle, Line, Pt2D};
|
||||
use map_model::{Map, Turn, TurnID, LANE_THICKNESS};
|
||||
use objects::{Ctx, ID};
|
||||
use render::{
|
||||
RenderOptions, Renderable, CROSSWALK_LINE_THICKNESS, TURN_ICON_ARROW_LENGTH,
|
||||
TURN_ICON_ARROW_THICKNESS, TURN_ICON_ARROW_TIP_LENGTH,
|
||||
RenderOptions, Renderable, BIG_ARROW_THICKNESS, BIG_ARROW_TIP_LENGTH, CROSSWALK_LINE_THICKNESS,
|
||||
TURN_ICON_ARROW_LENGTH, TURN_ICON_ARROW_THICKNESS, TURN_ICON_ARROW_TIP_LENGTH,
|
||||
};
|
||||
use std::f64;
|
||||
|
||||
@ -39,6 +39,20 @@ impl DrawTurn {
|
||||
icon_arrow,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn draw_full(t: &Turn, g: &mut GfxCtx, color: Color) {
|
||||
g.draw_polygon(
|
||||
color,
|
||||
&t.geom.make_polygons(2.0 * BIG_ARROW_THICKNESS).unwrap(),
|
||||
);
|
||||
// And a cap on the arrow
|
||||
g.draw_rounded_arrow(
|
||||
color,
|
||||
BIG_ARROW_THICKNESS,
|
||||
BIG_ARROW_TIP_LENGTH,
|
||||
&t.geom.last_line(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Little weird, but this is focused on the turn icon, not the full visualization
|
||||
|
Loading…
Reference in New Issue
Block a user