mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-26 16:02:23 +03:00
invert the default for text background. none by default, should be an exception to use it. planning to support background more generally through some kind of widget layouting.
This commit is contained in:
parent
e307e1f56d
commit
442a0509dd
@ -74,7 +74,7 @@ impl Text {
|
|||||||
pub fn new() -> Text {
|
pub fn new() -> Text {
|
||||||
Text {
|
Text {
|
||||||
lines: Vec::new(),
|
lines: Vec::new(),
|
||||||
bg_color: Some(BG_COLOR),
|
bg_color: None,
|
||||||
override_width: None,
|
override_width: None,
|
||||||
override_height: None,
|
override_height: None,
|
||||||
}
|
}
|
||||||
@ -86,20 +86,15 @@ impl Text {
|
|||||||
txt
|
txt
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO nope
|
|
||||||
pub fn prompt(line: &str) -> Text {
|
pub fn prompt(line: &str) -> Text {
|
||||||
let mut txt = Text::new();
|
let mut txt = Text::new().with_bg();
|
||||||
txt.add_highlighted(Line(line), PROMPT_COLOR);
|
txt.add_highlighted(Line(line), PROMPT_COLOR);
|
||||||
txt
|
txt
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bg(mut self, color: Color) -> Text {
|
pub fn with_bg(mut self) -> Text {
|
||||||
self.bg_color = Some(color);
|
assert!(self.bg_color.is_none());
|
||||||
self
|
self.bg_color = Some(BG_COLOR);
|
||||||
}
|
|
||||||
|
|
||||||
pub fn no_bg(mut self) -> Text {
|
|
||||||
self.bg_color = None;
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,11 +39,11 @@ impl Button {
|
|||||||
draw_hovered,
|
draw_hovered,
|
||||||
hotkey,
|
hotkey,
|
||||||
tooltip: if let Some(key) = hotkey {
|
tooltip: if let Some(key) = hotkey {
|
||||||
let mut txt = Text::from(Line(key.describe()).fg(text::HOTKEY_COLOR));
|
let mut txt = Text::from(Line(key.describe()).fg(text::HOTKEY_COLOR)).with_bg();
|
||||||
txt.append(Line(format!(" - {}", tooltip)));
|
txt.append(Line(format!(" - {}", tooltip)));
|
||||||
txt
|
txt
|
||||||
} else {
|
} else {
|
||||||
Text::from(Line(tooltip))
|
Text::from(Line(tooltip)).with_bg()
|
||||||
},
|
},
|
||||||
hitbox,
|
hitbox,
|
||||||
|
|
||||||
@ -247,14 +247,13 @@ impl Button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn text(
|
pub fn text(
|
||||||
mut text: Text,
|
text: Text,
|
||||||
unselected_bg_color: Color,
|
unselected_bg_color: Color,
|
||||||
selected_bg_color: Color,
|
selected_bg_color: Color,
|
||||||
hotkey: Option<MultiKey>,
|
hotkey: Option<MultiKey>,
|
||||||
tooltip: &str,
|
tooltip: &str,
|
||||||
ctx: &EventCtx,
|
ctx: &EventCtx,
|
||||||
) -> Button {
|
) -> Button {
|
||||||
text = text.no_bg();
|
|
||||||
let dims = ctx.text_dims(&text);
|
let dims = ctx.text_dims(&text);
|
||||||
let geom = Polygon::rounded_rectangle(
|
let geom = Polygon::rounded_rectangle(
|
||||||
Distance::meters(dims.width + 2.0 * HORIZ_PADDING),
|
Distance::meters(dims.width + 2.0 * HORIZ_PADDING),
|
||||||
|
@ -9,7 +9,7 @@ pub struct LogScroller {
|
|||||||
|
|
||||||
impl LogScroller {
|
impl LogScroller {
|
||||||
pub fn new(title: String, lines: Vec<String>) -> LogScroller {
|
pub fn new(title: String, lines: Vec<String>) -> LogScroller {
|
||||||
let mut text = Text::new();
|
let mut text = Text::new().with_bg();
|
||||||
text.add_highlighted(Line(title).size(50), text::PROMPT_COLOR);
|
text.add_highlighted(Line(title).size(50), text::PROMPT_COLOR);
|
||||||
for line in lines {
|
for line in lines {
|
||||||
text.add(Line(line));
|
text.add(Line(line));
|
||||||
|
@ -41,7 +41,7 @@ impl ModalMenu {
|
|||||||
) -> ModalMenu {
|
) -> ModalMenu {
|
||||||
let mut m = ModalMenu {
|
let mut m = ModalMenu {
|
||||||
title: title.into(),
|
title: title.into(),
|
||||||
info: Text::new(),
|
info: Text::new().with_bg(),
|
||||||
chosen_action: None,
|
chosen_action: None,
|
||||||
choices: raw_choices
|
choices: raw_choices
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@ -74,7 +74,7 @@ impl ModalMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_info(&mut self, ctx: &EventCtx, info: Text) {
|
pub fn set_info(&mut self, ctx: &EventCtx, info: Text) {
|
||||||
self.info = info;
|
self.info = info.with_bg();
|
||||||
self.recalculate_dims(ctx);
|
self.recalculate_dims(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ impl<T: Clone + Copy> Scroller<T> {
|
|||||||
Item::UpButton => {
|
Item::UpButton => {
|
||||||
// TODO center the text inside the rectangle. and actually, g should have a
|
// TODO center the text inside the rectangle. and actually, g should have a
|
||||||
// method for that.
|
// method for that.
|
||||||
let mut txt = Text::new().no_bg();
|
let mut txt = Text::new();
|
||||||
if self.top_idx == 0 {
|
if self.top_idx == 0 {
|
||||||
// TODO text::INACTIVE_CHOICE_COLOR
|
// TODO text::INACTIVE_CHOICE_COLOR
|
||||||
txt.add(Line("scroll up").fg(Color::grey(0.4)));
|
txt.add(Line("scroll up").fg(Color::grey(0.4)));
|
||||||
@ -217,7 +217,7 @@ impl<T: Clone + Copy> Scroller<T> {
|
|||||||
g.draw_text_at_screenspace_topleft(&txt, ScreenPt::new(rect.x1, rect.y1));
|
g.draw_text_at_screenspace_topleft(&txt, ScreenPt::new(rect.x1, rect.y1));
|
||||||
}
|
}
|
||||||
Item::DownButton => {
|
Item::DownButton => {
|
||||||
let mut txt = Text::new().no_bg();
|
let mut txt = Text::new();
|
||||||
let num_items = self.num_items_hidden_below(g.canvas);
|
let num_items = self.num_items_hidden_below(g.canvas);
|
||||||
if num_items == 0 {
|
if num_items == 0 {
|
||||||
txt.add(Line("scroll down").fg(Color::grey(0.4)));
|
txt.add(Line("scroll down").fg(Color::grey(0.4)));
|
||||||
|
@ -118,17 +118,17 @@ pub fn challenges_picker(ctx: &EventCtx) -> Box<dyn State> {
|
|||||||
hotkey(Key::Escape),
|
hotkey(Key::Escape),
|
||||||
Box::new(|_, _| Some(Transition::Pop)),
|
Box::new(|_, _| Some(Transition::Pop)),
|
||||||
),
|
),
|
||||||
ManagedWidget::draw_text(ctx, Text::from(Line("A/B STREET").size(50)).no_bg()),
|
ManagedWidget::draw_text(ctx, Text::from(Line("A/B STREET").size(50))),
|
||||||
],
|
],
|
||||||
));
|
));
|
||||||
|
|
||||||
col.push(ManagedWidget::draw_text(
|
col.push(ManagedWidget::draw_text(
|
||||||
ctx,
|
ctx,
|
||||||
Text::from(Line("CHALLENGES")).no_bg(),
|
Text::from(Line("CHALLENGES")),
|
||||||
));
|
));
|
||||||
col.push(ManagedWidget::draw_text(
|
col.push(ManagedWidget::draw_text(
|
||||||
ctx,
|
ctx,
|
||||||
Text::from(Line("Make changes to achieve a goal")).no_bg(),
|
Text::from(Line("Make changes to achieve a goal")),
|
||||||
));
|
));
|
||||||
|
|
||||||
let mut flex_row = Vec::new();
|
let mut flex_row = Vec::new();
|
||||||
@ -155,7 +155,7 @@ pub fn challenges_picker(ctx: &EventCtx) -> Box<dyn State> {
|
|||||||
let edits = abstutil::list_all_objects(abstutil::path_all_edits(
|
let edits = abstutil::list_all_objects(abstutil::path_all_edits(
|
||||||
&abstutil::basename(&challenge.map_path),
|
&abstutil::basename(&challenge.map_path),
|
||||||
));
|
));
|
||||||
let mut summary = Text::new();
|
let mut summary = Text::new().with_bg();
|
||||||
for l in &challenge.description {
|
for l in &challenge.description {
|
||||||
summary.add(Line(l));
|
summary.add(Line(l));
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ impl State for InfoPanel {
|
|||||||
|
|
||||||
fn info_for(id: ID, ui: &UI) -> Text {
|
fn info_for(id: ID, ui: &UI) -> Text {
|
||||||
let (map, sim, draw_map) = (&ui.primary.map, &ui.primary.sim, &ui.primary.draw_map);
|
let (map, sim, draw_map) = (&ui.primary.map, &ui.primary.sim, &ui.primary.draw_map);
|
||||||
let mut txt = Text::new();
|
let mut txt = Text::new().with_bg();
|
||||||
|
|
||||||
txt.extend(&CommonState::default_osd(id.clone(), ui));
|
txt.extend(&CommonState::default_osd(id.clone(), ui));
|
||||||
txt.highlight_last_line(Color::BLUE);
|
txt.highlight_last_line(Color::BLUE);
|
||||||
|
@ -100,7 +100,7 @@ impl CommonState {
|
|||||||
let map = &ui.primary.map;
|
let map = &ui.primary.map;
|
||||||
let id_color = ui.cs.get_def("OSD ID color", Color::RED);
|
let id_color = ui.cs.get_def("OSD ID color", Color::RED);
|
||||||
let name_color = ui.cs.get_def("OSD name color", Color::CYAN);
|
let name_color = ui.cs.get_def("OSD name color", Color::CYAN);
|
||||||
let mut osd = Text::new();
|
let mut osd = Text::new().with_bg();
|
||||||
match id {
|
match id {
|
||||||
ID::Lane(l) => {
|
ID::Lane(l) => {
|
||||||
osd.append_all(vec![
|
osd.append_all(vec![
|
||||||
@ -181,7 +181,7 @@ impl CommonState {
|
|||||||
} else if let Some(button) = g.button_tooltip() {
|
} else if let Some(button) = g.button_tooltip() {
|
||||||
button
|
button
|
||||||
} else {
|
} else {
|
||||||
Text::from(Line("..."))
|
Text::from(Line("...")).with_bg()
|
||||||
};
|
};
|
||||||
CommonState::draw_custom_osd(ui, g, osd);
|
CommonState::draw_custom_osd(ui, g, osd);
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ impl<T: 'static + Ord + PartialEq + Copy + core::fmt::Debug + Yvalue<T>> Plot<T>
|
|||||||
let percent_x = (i as f64) / ((num_x_labels - 1) as f64);
|
let percent_x = (i as f64) / ((num_x_labels - 1) as f64);
|
||||||
let t = max_x.percent_of(percent_x);
|
let t = max_x.percent_of(percent_x);
|
||||||
labels.push((
|
labels.push((
|
||||||
Text::from(Line(t.to_string())),
|
Text::from(Line(t.to_string())).with_bg(),
|
||||||
ScreenPt::new(x1 + percent_x * (x2 - x1), y2),
|
ScreenPt::new(x1 + percent_x * (x2 - x1), y2),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -73,7 +73,7 @@ impl<T: 'static + Ord + PartialEq + Copy + core::fmt::Debug + Yvalue<T>> Plot<T>
|
|||||||
for i in 0..num_y_labels {
|
for i in 0..num_y_labels {
|
||||||
let percent_y = (i as f64) / ((num_y_labels - 1) as f64);
|
let percent_y = (i as f64) / ((num_y_labels - 1) as f64);
|
||||||
labels.push((
|
labels.push((
|
||||||
Text::from(Line(max_y.from_percent(percent_y).prettyprint())),
|
Text::from(Line(max_y.from_percent(percent_y).prettyprint())).with_bg(),
|
||||||
ScreenPt::new(x1, y2 - percent_y * (y2 - y1)),
|
ScreenPt::new(x1, y2 - percent_y * (y2 - y1)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -127,7 +127,7 @@ impl<T: 'static + Ord + PartialEq + Copy + core::fmt::Debug + Yvalue<T>> Plot<T>
|
|||||||
let cursor = g.canvas.get_cursor_in_screen_space();
|
let cursor = g.canvas.get_cursor_in_screen_space();
|
||||||
if self.rect.contains(cursor) {
|
if self.rect.contains(cursor) {
|
||||||
let radius = Distance::meters(5.0);
|
let radius = Distance::meters(5.0);
|
||||||
let mut txt = Text::new();
|
let mut txt = Text::new().with_bg();
|
||||||
for (label, pt, _) in self.closest.all_close_pts(cursor.to_pt(), radius) {
|
for (label, pt, _) in self.closest.all_close_pts(cursor.to_pt(), radius) {
|
||||||
let t = self
|
let t = self
|
||||||
.max_x
|
.max_x
|
||||||
@ -287,7 +287,8 @@ impl Histogram {
|
|||||||
min,
|
min,
|
||||||
max,
|
max,
|
||||||
prettyprint_usize(cnt)
|
prettyprint_usize(cnt)
|
||||||
))),
|
)))
|
||||||
|
.with_bg(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -298,7 +299,7 @@ impl Histogram {
|
|||||||
let percent_x = (i as f64) / ((num_x_labels - 1) as f64);
|
let percent_x = (i as f64) / ((num_x_labels - 1) as f64);
|
||||||
let dt = min_x + (max_x - min_x) * percent_x;
|
let dt = min_x + (max_x - min_x) * percent_x;
|
||||||
labels.push((
|
labels.push((
|
||||||
Text::from(Line(dt.to_string())),
|
Text::from(Line(dt.to_string())).with_bg(),
|
||||||
ScreenPt::new(x1 + percent_x * (x2 - x1), y2),
|
ScreenPt::new(x1 + percent_x * (x2 - x1), y2),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -311,7 +312,8 @@ impl Histogram {
|
|||||||
labels.push((
|
labels.push((
|
||||||
Text::from(Line(prettyprint_usize(
|
Text::from(Line(prettyprint_usize(
|
||||||
((max_y as f64) * percent_y) as usize,
|
((max_y as f64) * percent_y) as usize,
|
||||||
))),
|
)))
|
||||||
|
.with_bg(),
|
||||||
ScreenPt::new(x1 - left_px, y2 - percent_y * (y2 - y1)),
|
ScreenPt::new(x1 - left_px, y2 - percent_y * (y2 - y1)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ impl ObjectDebugger {
|
|||||||
if self.debug_tooltip_key_held {
|
if self.debug_tooltip_key_held {
|
||||||
if let Some(pt) = g.canvas.get_cursor_in_map_space() {
|
if let Some(pt) = g.canvas.get_cursor_in_map_space() {
|
||||||
if let Some(gps) = pt.to_gps(ui.primary.map.get_gps_bounds()) {
|
if let Some(gps) = pt.to_gps(ui.primary.map.get_gps_bounds()) {
|
||||||
let mut txt = Text::new();
|
let mut txt = Text::new().with_bg();
|
||||||
txt.add(Line(pt.to_string()));
|
txt.add(Line(pt.to_string()));
|
||||||
txt.add(Line(gps.to_string()));
|
txt.add(Line(gps.to_string()));
|
||||||
txt.add(Line(format!("{:?}", g.canvas.get_cursor_in_screen_space())));
|
txt.add(Line(format!("{:?}", g.canvas.get_cursor_in_screen_space())));
|
||||||
|
@ -173,21 +173,21 @@ impl State for PolygonDebugger {
|
|||||||
|
|
||||||
match item {
|
match item {
|
||||||
Item::Point(pt) => {
|
Item::Point(pt) => {
|
||||||
g.draw_text_at(&Text::from(Line(idx.to_string())), *pt);
|
g.draw_text_at(&Text::from(Line(idx.to_string())).with_bg(), *pt);
|
||||||
}
|
}
|
||||||
Item::Triangle(ref tri) => {
|
Item::Triangle(ref tri) => {
|
||||||
for pt in &[tri.pt1, tri.pt2, tri.pt3] {
|
for pt in &[tri.pt1, tri.pt2, tri.pt3] {
|
||||||
g.draw_text_at(&Text::from(Line(idx.to_string())), *pt);
|
g.draw_text_at(&Text::from(Line(idx.to_string())).with_bg(), *pt);
|
||||||
}
|
}
|
||||||
g.draw_polygon(ui.cs.get("selected"), &Polygon::from_triangle(tri));
|
g.draw_polygon(ui.cs.get("selected"), &Polygon::from_triangle(tri));
|
||||||
}
|
}
|
||||||
Item::Polygon(ref poly) => {
|
Item::Polygon(ref poly) => {
|
||||||
g.draw_polygon(ui.cs.get("selected"), poly);
|
g.draw_polygon(ui.cs.get("selected"), poly);
|
||||||
g.draw_text_at(&Text::from(Line(idx.to_string())), poly.center());
|
g.draw_text_at(&Text::from(Line(idx.to_string())).with_bg(), poly.center());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(pt) = self.center {
|
if let Some(pt) = self.center {
|
||||||
g.draw_text_at(&Text::from(Line("c")), pt);
|
g.draw_text_at(&Text::from(Line("c")).with_bg(), pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.slider.draw(g);
|
self.slider.draw(g);
|
||||||
|
@ -125,7 +125,7 @@ impl State for StopSignEditor {
|
|||||||
|
|
||||||
self.menu.draw(g);
|
self.menu.draw(g);
|
||||||
if let Some(r) = self.selected_sign {
|
if let Some(r) = self.selected_sign {
|
||||||
let mut osd = Text::new();
|
let mut osd = Text::new().with_bg();
|
||||||
osd.add_appended(vec![
|
osd.add_appended(vec![
|
||||||
Line("Stop sign for "),
|
Line("Stop sign for "),
|
||||||
Line(ui.primary.map.get_r(r).get_name()).fg(ui.cs.get("OSD name color")),
|
Line(ui.primary.map.get_r(r).get_name()).fg(ui.cs.get("OSD name color")),
|
||||||
|
@ -289,7 +289,7 @@ impl State for TrafficSignalEditor {
|
|||||||
ui.primary.map.get_r(id.to).get_name()
|
ui.primary.map.get_r(id.to).get_name()
|
||||||
)))
|
)))
|
||||||
};
|
};
|
||||||
CommonState::draw_custom_osd(ui, g, osd);
|
CommonState::draw_custom_osd(ui, g, osd.with_bg());
|
||||||
} else {
|
} else {
|
||||||
CommonState::draw_osd(g, ui, &None);
|
CommonState::draw_osd(g, ui, &None);
|
||||||
}
|
}
|
||||||
|
@ -122,8 +122,10 @@ impl GUI for Game {
|
|||||||
state.draw(g, &self.ui);
|
state.draw(g, &self.ui);
|
||||||
|
|
||||||
if self.ui.opts.dev {
|
if self.ui.opts.dev {
|
||||||
|
let mut txt = Text::from(Line("DEV"));
|
||||||
|
txt.highlight_last_line(Color::RED);
|
||||||
g.draw_blocking_text(
|
g.draw_blocking_text(
|
||||||
&Text::from(Line("DEV")).bg(Color::RED),
|
&txt,
|
||||||
(HorizontalAlignment::Right, VerticalAlignment::Bottom),
|
(HorizontalAlignment::Right, VerticalAlignment::Bottom),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -86,17 +86,17 @@ pub fn main_menu(ctx: &EventCtx, ui: &UI) -> Box<dyn State> {
|
|||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
ManagedWidget::draw_text(ctx, Text::from(Line("A/B STREET").size(50)).no_bg()),
|
ManagedWidget::draw_text(ctx, Text::from(Line("A/B STREET").size(50))),
|
||||||
],
|
],
|
||||||
));
|
));
|
||||||
|
|
||||||
col.push(ManagedWidget::draw_text(
|
col.push(ManagedWidget::draw_text(
|
||||||
ctx,
|
ctx,
|
||||||
Text::from(Line("Created by Dustin Carlino")).no_bg(),
|
Text::from(Line("Created by Dustin Carlino")),
|
||||||
));
|
));
|
||||||
col.push(ManagedWidget::draw_text(
|
col.push(ManagedWidget::draw_text(
|
||||||
ctx,
|
ctx,
|
||||||
Text::from(Line("Choose your game")).no_bg(),
|
Text::from(Line("Choose your game")),
|
||||||
));
|
));
|
||||||
|
|
||||||
col.push(ManagedWidget::Row(
|
col.push(ManagedWidget::Row(
|
||||||
@ -169,7 +169,7 @@ fn about(ctx: &EventCtx) -> Box<dyn State> {
|
|||||||
Box::new(|_, _| Some(Transition::Pop)),
|
Box::new(|_, _| Some(Transition::Pop)),
|
||||||
));
|
));
|
||||||
|
|
||||||
let mut txt = Text::new().no_bg();
|
let mut txt = Text::new();
|
||||||
txt.add(Line("A/B STREET").size(50));
|
txt.add(Line("A/B STREET").size(50));
|
||||||
txt.add(Line("Created by Dustin Carlino"));
|
txt.add(Line("Created by Dustin Carlino"));
|
||||||
txt.add(Line(""));
|
txt.add(Line(""));
|
||||||
|
@ -42,7 +42,7 @@ impl DrawBuilding {
|
|||||||
let label = bldg
|
let label = bldg
|
||||||
.osm_tags
|
.osm_tags
|
||||||
.get("addr:housenumber")
|
.get("addr:housenumber")
|
||||||
.map(|num| Text::from(Line(num.to_string()).fg(Color::BLACK).size(50)).no_bg());
|
.map(|num| Text::from(Line(num.to_string()).fg(Color::BLACK).size(50)));
|
||||||
|
|
||||||
if bldg.parking.is_some() {
|
if bldg.parking.is_some() {
|
||||||
let center = bldg.label_center;
|
let center = bldg.label_center;
|
||||||
|
@ -142,7 +142,7 @@ impl DrawCar {
|
|||||||
zorder: input.on.get_zorder(map),
|
zorder: input.on.get_zorder(map),
|
||||||
label: input
|
label: input
|
||||||
.label
|
.label
|
||||||
.map(|line| Text::from(Line(line).fg(Color::rgb(249, 206, 24)).size(20)).no_bg()),
|
.map(|line| Text::from(Line(line).fg(Color::rgb(249, 206, 24)).size(20))),
|
||||||
draw_default: prerender.upload(draw_default),
|
draw_default: prerender.upload(draw_default),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,8 +216,7 @@ impl DrawPedCrowd {
|
|||||||
Line(format!("{}", input.members.len()))
|
Line(format!("{}", input.members.len()))
|
||||||
.fg(Color::BLACK)
|
.fg(Color::BLACK)
|
||||||
.size(15),
|
.size(15),
|
||||||
)
|
);
|
||||||
.no_bg();
|
|
||||||
|
|
||||||
DrawPedCrowd {
|
DrawPedCrowd {
|
||||||
members: input.members,
|
members: input.members,
|
||||||
|
@ -43,7 +43,7 @@ impl DrawRoad {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut label = Text::new();
|
let mut label = Text::new().with_bg();
|
||||||
label.add(Line(r.get_name()).size(50));
|
label.add(Line(r.get_name()).size(50));
|
||||||
|
|
||||||
DrawRoad {
|
DrawRoad {
|
||||||
|
@ -182,11 +182,8 @@ impl TrafficSignalDiagram {
|
|||||||
);
|
);
|
||||||
let mut labels = Vec::new();
|
let mut labels = Vec::new();
|
||||||
for (idx, phase) in phases.iter().enumerate() {
|
for (idx, phase) in phases.iter().enumerate() {
|
||||||
labels.push(Text::from(Line(format!(
|
labels
|
||||||
"Phase {}: {}",
|
.push(Text::from(Line(format!("Phase {}: {}", idx + 1, phase.duration))).with_bg());
|
||||||
idx + 1,
|
|
||||||
phase.duration
|
|
||||||
))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TrafficSignalDiagram {
|
TrafficSignalDiagram {
|
||||||
@ -261,7 +258,7 @@ fn make_new_scroller(i: IntersectionID, draw_ctx: &DrawCtx, ctx: &EventCtx) -> N
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
txt.push((
|
txt.push((
|
||||||
Text::from(Line(format!("Phase {}: {}", idx + 1, phase.duration))),
|
Text::from(Line(format!("Phase {}: {}", idx + 1, phase.duration))).with_bg(),
|
||||||
ScreenPt::new(10.0 + (bounds.max_x - bounds.min_x) * zoom, y_offset * zoom),
|
ScreenPt::new(10.0 + (bounds.max_x - bounds.min_x) * zoom, y_offset * zoom),
|
||||||
));
|
));
|
||||||
y_offset += bounds.max_y - bounds.min_y;
|
y_offset += bounds.max_y - bounds.min_y;
|
||||||
|
@ -61,7 +61,7 @@ impl ShowBusRoute {
|
|||||||
let mut labels = Vec::new();
|
let mut labels = Vec::new();
|
||||||
for (idx, bs) in route.stops.iter().enumerate() {
|
for (idx, bs) in route.stops.iter().enumerate() {
|
||||||
labels.push((
|
labels.push((
|
||||||
Text::from(Line(format!("{}", idx + 1))),
|
Text::from(Line(format!("{}", idx + 1))).with_bg(),
|
||||||
map.get_bs(*bs).sidewalk_pos.pt(map),
|
map.get_bs(*bs).sidewalk_pos.pt(map),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ impl GameplayState for Freeform {
|
|||||||
if let Some(ID::Intersection(i)) = ui.primary.current_selection {
|
if let Some(ID::Intersection(i)) = ui.primary.current_selection {
|
||||||
if self.spawn_pts.contains(&i) {
|
if self.spawn_pts.contains(&i) {
|
||||||
let cnt = ui.primary.sim.count_trips_involving_border(i);
|
let cnt = ui.primary.sim.count_trips_involving_border(i);
|
||||||
let mut txt = Text::new();
|
let mut txt = Text::new().with_bg();
|
||||||
for line in cnt.describe() {
|
for line in cnt.describe() {
|
||||||
txt.add(Line(line));
|
txt.add(Line(line));
|
||||||
}
|
}
|
||||||
|
@ -287,7 +287,7 @@ impl AgentMeter {
|
|||||||
pub fn new(ctx: &EventCtx, ui: &UI) -> AgentMeter {
|
pub fn new(ctx: &EventCtx, ui: &UI) -> AgentMeter {
|
||||||
let (active, unfinished, by_mode) = ui.primary.sim.num_trips();
|
let (active, unfinished, by_mode) = ui.primary.sim.num_trips();
|
||||||
|
|
||||||
let mut row1_txt = Text::new().no_bg();
|
let mut row1_txt = Text::new();
|
||||||
row1_txt.add(Line(format!("Active trips: {}", active)));
|
row1_txt.add(Line(format!("Active trips: {}", active)));
|
||||||
row1_txt.add(Line(format!("Unfinished trips: {}", unfinished)));
|
row1_txt.add(Line(format!("Unfinished trips: {}", unfinished)));
|
||||||
|
|
||||||
@ -306,13 +306,13 @@ impl AgentMeter {
|
|||||||
JustDraw::wrap(DrawBoth::new(ctx, rect_bg, Vec::new())),
|
JustDraw::wrap(DrawBoth::new(ctx, rect_bg, Vec::new())),
|
||||||
JustDraw::text(row1_txt, ctx),
|
JustDraw::text(row1_txt, ctx),
|
||||||
JustDraw::svg("assets/meters/pedestrian.svg", ctx),
|
JustDraw::svg("assets/meters/pedestrian.svg", ctx),
|
||||||
JustDraw::text(Text::from(Line(&by_mode[&TripMode::Walk])).no_bg(), ctx),
|
JustDraw::text(Text::from(Line(&by_mode[&TripMode::Walk])), ctx),
|
||||||
JustDraw::svg("assets/meters/bike.svg", ctx),
|
JustDraw::svg("assets/meters/bike.svg", ctx),
|
||||||
JustDraw::text(Text::from(Line(&by_mode[&TripMode::Bike])).no_bg(), ctx),
|
JustDraw::text(Text::from(Line(&by_mode[&TripMode::Bike])), ctx),
|
||||||
JustDraw::svg("assets/meters/car.svg", ctx),
|
JustDraw::svg("assets/meters/car.svg", ctx),
|
||||||
JustDraw::text(Text::from(Line(&by_mode[&TripMode::Drive])).no_bg(), ctx),
|
JustDraw::text(Text::from(Line(&by_mode[&TripMode::Drive])), ctx),
|
||||||
JustDraw::svg("assets/meters/bus.svg", ctx),
|
JustDraw::svg("assets/meters/bus.svg", ctx),
|
||||||
JustDraw::text(Text::from(Line(&by_mode[&TripMode::Transit])).no_bg(), ctx),
|
JustDraw::text(Text::from(Line(&by_mode[&TripMode::Transit])), ctx),
|
||||||
];
|
];
|
||||||
|
|
||||||
// TODO A horrible experiment in manual layouting
|
// TODO A horrible experiment in manual layouting
|
||||||
|
@ -37,7 +37,7 @@ impl Scoreboard {
|
|||||||
prebaked.all_finished_trips(ui.primary.sim.time());
|
prebaked.all_finished_trips(ui.primary.sim.time());
|
||||||
|
|
||||||
// TODO Include unfinished count
|
// TODO Include unfinished count
|
||||||
let mut txt = Text::new();
|
let mut txt = Text::new().with_bg();
|
||||||
txt.add_appended(vec![
|
txt.add_appended(vec![
|
||||||
Line("Finished trips as of "),
|
Line("Finished trips as of "),
|
||||||
Line(ui.primary.sim.time().ampm_tostring()).fg(Color::CYAN),
|
Line(ui.primary.sim.time().ampm_tostring()).fg(Color::CYAN),
|
||||||
|
@ -77,7 +77,7 @@ impl SpeedControls {
|
|||||||
.translate(330.0, 10.0),
|
.translate(330.0, 10.0),
|
||||||
);
|
);
|
||||||
txt.push((
|
txt.push((
|
||||||
Text::from(Line("speed").size(14).roboto()).no_bg(),
|
Text::from(Line("speed").size(14).roboto()),
|
||||||
ScreenPt::new(330.0, 15.0),
|
ScreenPt::new(330.0, 15.0),
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -333,8 +333,7 @@ impl SpeedControls {
|
|||||||
Line(format!("{:.1}x", self.desired_speed()))
|
Line(format!("{:.1}x", self.desired_speed()))
|
||||||
.size(14)
|
.size(14)
|
||||||
.roboto(),
|
.roboto(),
|
||||||
)
|
),
|
||||||
.no_bg(),
|
|
||||||
ScreenPt::new(self.top_left.x + 530.0, self.top_left.y + 10.0),
|
ScreenPt::new(self.top_left.x + 530.0, self.top_left.y + 10.0),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -446,17 +445,17 @@ impl TimePanel {
|
|||||||
);
|
);
|
||||||
|
|
||||||
txt.push((
|
txt.push((
|
||||||
Text::from(Line("00:00").size(12).roboto()).no_bg(),
|
Text::from(Line("00:00").size(12).roboto()),
|
||||||
ScreenPt::new(25.0, 80.0),
|
ScreenPt::new(25.0, 80.0),
|
||||||
));
|
));
|
||||||
batch.add_svg("assets/speed/sunrise.svg", 94.0, 80.0);
|
batch.add_svg("assets/speed/sunrise.svg", 94.0, 80.0);
|
||||||
txt.push((
|
txt.push((
|
||||||
Text::from(Line("12:00").size(12).roboto()).no_bg(),
|
Text::from(Line("12:00").size(12).roboto()),
|
||||||
ScreenPt::new(153.0, 80.0),
|
ScreenPt::new(153.0, 80.0),
|
||||||
));
|
));
|
||||||
batch.add_svg("assets/speed/sunset.svg", 220.0, 80.0);
|
batch.add_svg("assets/speed/sunset.svg", 220.0, 80.0);
|
||||||
txt.push((
|
txt.push((
|
||||||
Text::from(Line("24:00").size(12).roboto()).no_bg(),
|
Text::from(Line("24:00").size(12).roboto()),
|
||||||
ScreenPt::new(280.0, 80.0),
|
ScreenPt::new(280.0, 80.0),
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -475,7 +474,7 @@ impl TimePanel {
|
|||||||
});
|
});
|
||||||
|
|
||||||
g.draw_text_at_screenspace_topleft(
|
g.draw_text_at_screenspace_topleft(
|
||||||
&Text::from(Line(ui.primary.sim.time().ampm_tostring()).size(30)).no_bg(),
|
&Text::from(Line(ui.primary.sim.time().ampm_tostring()).size(30)),
|
||||||
ScreenPt::new(24.0, 10.0),
|
ScreenPt::new(24.0, 10.0),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ impl UI {
|
|||||||
],
|
],
|
||||||
ctx,
|
ctx,
|
||||||
),
|
),
|
||||||
sidebar: Text::new(),
|
sidebar: Text::new().with_bg(),
|
||||||
|
|
||||||
last_id: None,
|
last_id: None,
|
||||||
};
|
};
|
||||||
@ -562,7 +562,7 @@ impl GUI for UI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.sidebar = Text::new();
|
self.sidebar = Text::new().with_bg();
|
||||||
self.sidebar.override_width = Some(0.3 * ctx.canvas.window_width);
|
self.sidebar.override_width = Some(0.3 * ctx.canvas.window_width);
|
||||||
self.sidebar.override_height = Some(ctx.canvas.window_height);
|
self.sidebar.override_height = Some(ctx.canvas.window_height);
|
||||||
if let Some(id) = self.model.world.get_selection() {
|
if let Some(id) = self.model.world.get_selection() {
|
||||||
@ -669,7 +669,7 @@ impl GUI for UI {
|
|||||||
if show_tooltip {
|
if show_tooltip {
|
||||||
// TODO Argh, covers up mouseover tooltip.
|
// TODO Argh, covers up mouseover tooltip.
|
||||||
if let Some(cursor) = g.canvas.get_cursor_in_map_space() {
|
if let Some(cursor) = g.canvas.get_cursor_in_map_space() {
|
||||||
g.draw_mouse_tooltip(&Text::from(Line(cursor.to_string())));
|
g.draw_mouse_tooltip(&Text::from(Line(cursor.to_string())).with_bg());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -709,7 +709,7 @@ fn preview_intersection(
|
|||||||
batch.push(Color::GREEN.alpha(0.5), r);
|
batch.push(Color::GREEN.alpha(0.5), r);
|
||||||
}
|
}
|
||||||
for (label, poly) in debug {
|
for (label, poly) in debug {
|
||||||
labels.push((Text::from(Line(label)), poly.center()));
|
labels.push((Text::from(Line(label)).with_bg(), poly.center()));
|
||||||
batch.push(Color::RED.alpha(0.5), poly);
|
batch.push(Color::RED.alpha(0.5), poly);
|
||||||
}
|
}
|
||||||
(batch.upload(ctx), labels)
|
(batch.upload(ctx), labels)
|
||||||
|
Loading…
Reference in New Issue
Block a user