mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 09:24:26 +03:00
try out a new style for road labels
This commit is contained in:
parent
5a9fb4ceef
commit
c66564dd9d
@ -295,7 +295,6 @@ impl State for DebugMode {
|
||||
fn draw(&self, g: &mut GfxCtx, app: &App) {
|
||||
let mut opts = DrawOptions::new();
|
||||
opts.label_buildings = self.layers.show_labels;
|
||||
opts.label_roads = self.layers.show_labels;
|
||||
app.draw(g, opts, &app.primary.sim, self);
|
||||
|
||||
if let Some(ref results) = self.search_results {
|
||||
|
@ -279,7 +279,6 @@ impl State for StoryMapEditor {
|
||||
fn draw(&self, g: &mut GfxCtx, app: &App) {
|
||||
let mut opts = DrawOptions::new();
|
||||
opts.label_buildings = true;
|
||||
opts.label_roads = true;
|
||||
app.draw(g, opts, &DontDrawAgents {}, &ShowEverything::new());
|
||||
|
||||
match self.mode {
|
||||
|
@ -9,25 +9,31 @@ use geom::Duration;
|
||||
// TODO SimOptions stuff too
|
||||
#[derive(Clone)]
|
||||
pub struct Options {
|
||||
pub dev: bool,
|
||||
|
||||
pub label_roads: bool,
|
||||
pub traffic_signal_style: TrafficSignalStyle,
|
||||
pub color_scheme: ColorSchemeChoice,
|
||||
pub dev: bool,
|
||||
pub time_increment: Duration,
|
||||
pub resume_after_edit: bool,
|
||||
pub min_zoom_for_detail: f64,
|
||||
pub large_unzoomed_agents: bool,
|
||||
|
||||
pub time_increment: Duration,
|
||||
pub resume_after_edit: bool,
|
||||
}
|
||||
|
||||
impl Options {
|
||||
pub fn default() -> Options {
|
||||
Options {
|
||||
dev: false,
|
||||
|
||||
label_roads: false,
|
||||
traffic_signal_style: TrafficSignalStyle::BAP,
|
||||
color_scheme: ColorSchemeChoice::Standard,
|
||||
dev: false,
|
||||
time_increment: Duration::minutes(10),
|
||||
resume_after_edit: true,
|
||||
min_zoom_for_detail: 4.0,
|
||||
large_unzoomed_agents: false,
|
||||
|
||||
time_increment: Duration::minutes(10),
|
||||
resume_after_edit: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -95,6 +101,8 @@ impl OptionsPanel {
|
||||
.margin_below(10),
|
||||
"Appearance".draw_text(ctx).margin_below(10),
|
||||
Widget::col(vec![
|
||||
Checkbox::text(ctx, "Draw road names", None, app.opts.label_roads)
|
||||
.margin_below(10),
|
||||
Widget::row(vec![
|
||||
"Traffic signal rendering:".draw_text(ctx).margin_right(15),
|
||||
Widget::dropdown(
|
||||
@ -207,6 +215,8 @@ impl State for OptionsPanel {
|
||||
return Transition::Pop;
|
||||
}
|
||||
"Apply" => {
|
||||
app.opts.dev = self.composite.is_checked("Enable developer mode");
|
||||
|
||||
ctx.canvas.invert_scroll = self
|
||||
.composite
|
||||
.is_checked("Invert direction of vertical scrolling");
|
||||
@ -217,8 +227,8 @@ impl State for OptionsPanel {
|
||||
.composite
|
||||
.is_checked("Use arrow keys to pan and Q/W to zoom");
|
||||
ctx.canvas.edge_auto_panning = self.composite.is_checked("autopan");
|
||||
app.opts.dev = self.composite.is_checked("Enable developer mode");
|
||||
|
||||
app.opts.label_roads = self.composite.is_checked("Draw road names");
|
||||
let style = self.composite.dropdown_value("Traffic signal rendering");
|
||||
if app.opts.traffic_signal_style != style {
|
||||
app.opts.traffic_signal_style = style;
|
||||
|
@ -75,7 +75,6 @@ fn draw_vehicle(
|
||||
pub struct DrawOptions {
|
||||
pub suppress_traffic_signal_details: Vec<IntersectionID>,
|
||||
pub label_buildings: bool,
|
||||
pub label_roads: bool,
|
||||
}
|
||||
|
||||
impl DrawOptions {
|
||||
@ -83,7 +82,6 @@ impl DrawOptions {
|
||||
DrawOptions {
|
||||
suppress_traffic_signal_details: Vec::new(),
|
||||
label_buildings: false,
|
||||
label_roads: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,23 +50,42 @@ impl Renderable for DrawRoad {
|
||||
ID::Road(self.id)
|
||||
}
|
||||
|
||||
fn draw(&self, g: &mut GfxCtx, app: &App, opts: &DrawOptions) {
|
||||
fn draw(&self, g: &mut GfxCtx, app: &App, _: &DrawOptions) {
|
||||
g.redraw(&self.draw_center_line);
|
||||
|
||||
if opts.label_roads {
|
||||
if app.opts.label_roads {
|
||||
// Lazily calculate
|
||||
let mut label = self.label.borrow_mut();
|
||||
if label.is_none() {
|
||||
let mut batch = GeomBatch::new();
|
||||
let r = app.primary.map.get_r(self.id);
|
||||
|
||||
let mut txt = Text::new().with_bg();
|
||||
txt.add(Line(r.get_name()));
|
||||
batch.append(
|
||||
txt.render_to_batch(g.prerender)
|
||||
.scale(0.1)
|
||||
.centered_on(r.center_pts.middle()),
|
||||
);
|
||||
if false {
|
||||
// Style 1: banner
|
||||
let mut txt = Text::new().with_bg();
|
||||
txt.add(Line(r.get_name()));
|
||||
batch.append(
|
||||
txt.render_to_batch(g.prerender)
|
||||
.scale(0.1)
|
||||
.centered_on(r.center_pts.middle()),
|
||||
);
|
||||
} else {
|
||||
// Style 2: Yellow center-line
|
||||
let name = r.get_name();
|
||||
if r.center_pts.length() >= Distance::meters(30.0) && name != "???" {
|
||||
// TODO If it's definitely straddling bus/bike lanes, change the color? Or
|
||||
// even easier, just skip the center lines?
|
||||
let txt = Text::from(Line(name).fg(app.cs.road_center_line))
|
||||
.bg(app.cs.driving_lane);
|
||||
let (pt, angle) = r.center_pts.dist_along(r.center_pts.length() / 2.0);
|
||||
batch.append(
|
||||
txt.render_to_batch(g.prerender)
|
||||
.scale(0.1)
|
||||
.centered_on(pt)
|
||||
.rotate(angle.invert_y()),
|
||||
);
|
||||
}
|
||||
}
|
||||
*label = Some(g.prerender.upload(batch));
|
||||
}
|
||||
// TODO Covered up sometimes. We could fork and force a different z value...
|
||||
|
@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
|
||||
// Stores in radians
|
||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, PartialOrd)]
|
||||
pub struct Angle(f64);
|
||||
|
||||
impl Angle {
|
||||
|
Loading…
Reference in New Issue
Block a user