mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-24 15:02:59 +03:00
Use a cross-hatch pattern to show edited roads, instead of that bizarre
cyan. For the moment, just to simplify things, bake the edited color into the bike network layer. Probably will split it out later, maybe moving the proposal management to the legend row.
This commit is contained in:
parent
78222ffadb
commit
6c3ce23e5f
@ -2,7 +2,7 @@ use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use map_model::{LaneType, PathConstraints, Road};
|
||||
use widgetry::{Color, Drawable, EventCtx, GeomBatch, GfxCtx};
|
||||
use widgetry::{Color, Drawable, Fill, GeomBatch, GfxCtx, Texture};
|
||||
|
||||
use crate::app::App;
|
||||
|
||||
@ -11,8 +11,6 @@ lazy_static::lazy_static! {
|
||||
pub static ref PROTECTED_BIKE_LANE: Color = Color::hex("#A4DE02");
|
||||
pub static ref PAINTED_BIKE_LANE: Color = Color::hex("#76BA1B");
|
||||
pub static ref GREENWAY: Color = Color::hex("#4C9A2A");
|
||||
|
||||
pub static ref EDITED_COLOR: Color = Color::CYAN;
|
||||
}
|
||||
|
||||
/// Shows the bike network while unzoomed. Handles thickening the roads at low zoom levels.
|
||||
@ -84,9 +82,15 @@ impl DrawNetworkLayer {
|
||||
};
|
||||
|
||||
batch.push(
|
||||
color,
|
||||
// Also show edited roads in this layer
|
||||
if map.get_edits().changed_roads.contains(&r.id) {
|
||||
Fill::ColoredTexture(color, Texture::CROSS_HATCH)
|
||||
} else {
|
||||
Fill::Color(color)
|
||||
},
|
||||
r.center_pts.make_polygons(thickness * r.get_width(map)),
|
||||
);
|
||||
|
||||
// Arbitrarily pick a color when two different types of roads meet
|
||||
intersections.insert(r.src_i, color);
|
||||
intersections.insert(r.dst_i, color);
|
||||
@ -113,15 +117,3 @@ pub fn is_greenway(road: &Road) -> bool {
|
||||
.allow_through_traffic
|
||||
.contains(PathConstraints::Bike)
|
||||
}
|
||||
|
||||
pub fn render_edits(ctx: &mut EventCtx, app: &App) -> Drawable {
|
||||
let mut batch = GeomBatch::new();
|
||||
let map = &app.primary.map;
|
||||
for r in &map.get_edits().changed_roads {
|
||||
batch.push(
|
||||
EDITED_COLOR.alpha(0.5),
|
||||
map.get_r(*r).get_thick_polygon(map),
|
||||
);
|
||||
}
|
||||
batch.upload(ctx)
|
||||
}
|
||||
|
@ -7,15 +7,14 @@ mod route;
|
||||
mod share;
|
||||
|
||||
use geom::Distance;
|
||||
use map_gui::tools::{nice_map_name, CityPicker, ColorLegend, PopupMsg, URLManager};
|
||||
use map_gui::tools::{nice_map_name, CityPicker, PopupMsg, URLManager};
|
||||
use map_gui::ID;
|
||||
use map_model::{EditCmd, LaneType};
|
||||
use widgetry::{
|
||||
lctrl, Drawable, EventCtx, GfxCtx, HorizontalAlignment, Key, Line, Outcome, Panel, State,
|
||||
TextExt, VerticalAlignment, Widget,
|
||||
lctrl, EventCtx, GfxCtx, HorizontalAlignment, Key, Line, Outcome, Panel, State, TextExt,
|
||||
VerticalAlignment, Widget,
|
||||
};
|
||||
|
||||
use self::bike_network::render_edits;
|
||||
use self::layers::Layers;
|
||||
use self::magnifying::MagnifyingGlass;
|
||||
use crate::app::{App, Transition};
|
||||
@ -28,7 +27,6 @@ pub struct ExploreMap {
|
||||
top_panel: Panel,
|
||||
layers: Layers,
|
||||
magnifying_glass: MagnifyingGlass,
|
||||
edits_layer: Drawable,
|
||||
|
||||
map_edit_key: usize,
|
||||
}
|
||||
@ -58,7 +56,6 @@ impl ExploreMap {
|
||||
top_panel: Panel::empty(ctx),
|
||||
layers,
|
||||
magnifying_glass: MagnifyingGlass::new(ctx),
|
||||
edits_layer: Drawable::empty(ctx),
|
||||
|
||||
// Start with a bogus value, so we fix up the URL when changing maps
|
||||
map_edit_key: usize::MAX,
|
||||
@ -74,7 +71,6 @@ impl State<App> for ExploreMap {
|
||||
if self.map_edit_key != key {
|
||||
self.map_edit_key = key;
|
||||
self.top_panel = make_top_panel(ctx, app);
|
||||
self.edits_layer = render_edits(ctx, app);
|
||||
|
||||
if let Err(err) = URLManager::update_url_param(
|
||||
"--edits".to_string(),
|
||||
@ -195,7 +191,6 @@ impl State<App> for ExploreMap {
|
||||
self.top_panel.draw(g);
|
||||
self.layers.draw(g, app);
|
||||
self.magnifying_glass.draw(g, app);
|
||||
g.redraw(&self.edits_layer);
|
||||
}
|
||||
}
|
||||
|
||||
@ -240,11 +235,6 @@ fn make_top_panel(ctx: &mut EventCtx, app: &App) -> Panel {
|
||||
.secondary()
|
||||
.into_widget(ctx),
|
||||
);
|
||||
file_management.push(ColorLegend::row(
|
||||
ctx,
|
||||
*crate::ungap::bike_network::EDITED_COLOR,
|
||||
"changed road",
|
||||
));
|
||||
file_management.push(Widget::row(vec![
|
||||
ctx.style()
|
||||
.btn_outline
|
||||
|
@ -2,21 +2,19 @@ use abstutil::Tags;
|
||||
use map_gui::tools::PopupMsg;
|
||||
use map_model::{BufferType, Direction, EditCmd, EditRoad, LaneSpec, LaneType, RoadID};
|
||||
use widgetry::{
|
||||
Choice, Drawable, EventCtx, GfxCtx, HorizontalAlignment, Key, Outcome, Panel, State, TextExt,
|
||||
Choice, EventCtx, GfxCtx, HorizontalAlignment, Key, Outcome, Panel, State, TextExt,
|
||||
VerticalAlignment, Widget,
|
||||
};
|
||||
|
||||
use crate::app::{App, Transition};
|
||||
use crate::common::RouteSketcher;
|
||||
use crate::edit::apply_map_edits;
|
||||
use crate::ungap::bike_network::render_edits;
|
||||
use crate::ungap::layers::Layers;
|
||||
use crate::ungap::magnifying::MagnifyingGlass;
|
||||
|
||||
pub struct QuickSketch {
|
||||
top_panel: Panel,
|
||||
layers: Layers,
|
||||
edits_layer: Drawable,
|
||||
magnifying_glass: MagnifyingGlass,
|
||||
route_sketcher: RouteSketcher,
|
||||
}
|
||||
@ -27,7 +25,6 @@ impl QuickSketch {
|
||||
top_panel: Panel::empty(ctx),
|
||||
layers,
|
||||
magnifying_glass: MagnifyingGlass::new(ctx),
|
||||
edits_layer: render_edits(ctx, app),
|
||||
route_sketcher: RouteSketcher::new(ctx, app),
|
||||
};
|
||||
qs.update_top_panel(ctx);
|
||||
@ -139,7 +136,6 @@ impl State<App> for QuickSketch {
|
||||
self.top_panel.draw(g);
|
||||
self.layers.draw(g, app);
|
||||
self.magnifying_glass.draw(g, app);
|
||||
g.redraw(&self.edits_layer);
|
||||
self.route_sketcher.draw(g);
|
||||
}
|
||||
}
|
||||
|
@ -63,6 +63,7 @@ impl Texture {
|
||||
pub const PINE_TREE: Texture = Texture(16);
|
||||
pub const CACTUS: Texture = Texture(17);
|
||||
pub const SHRUB: Texture = Texture(18);
|
||||
pub const CROSS_HATCH: Texture = Texture(19);
|
||||
pub const SNOW_PERSON: Texture = Texture(29);
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 25 KiB |
Loading…
Reference in New Issue
Block a user