mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-29 04:35:51 +03:00
remove duplicate color definitions and don't allow them
This commit is contained in:
parent
a5befc83fe
commit
4b7a424b1f
@ -10,7 +10,8 @@ def run():
|
||||
for f in files:
|
||||
if f.endswith('.rs') and f != 'colors.rs':
|
||||
for k, v in read_file(os.path.join(path, f)):
|
||||
# TODO Check for double-definitions
|
||||
if k in mapping:
|
||||
raise ValueError('Color {} defined twice'.format(k))
|
||||
mapping[k] = v
|
||||
|
||||
with open('src/init_colors.rs', 'w') as f:
|
||||
|
@ -38,6 +38,10 @@ impl ColorScheme {
|
||||
self.map[name]
|
||||
}
|
||||
|
||||
pub fn get(&self, name: &str) -> Color {
|
||||
self.map[name]
|
||||
}
|
||||
|
||||
// Just for the color picker plugin, that's why the funky return value
|
||||
pub fn color_names(&self) -> Vec<(String, ())> {
|
||||
let mut names: Vec<(String, ())> = self.map.keys().map(|n| (n.clone(), ())).collect();
|
||||
|
@ -126,7 +126,7 @@ impl Plugin for DrawNeighborhoodState {
|
||||
}
|
||||
for pt in &pts {
|
||||
g.draw_circle(
|
||||
ctx.cs.get_def("neighborhood point", Color::RED),
|
||||
ctx.cs.get("neighborhood point"),
|
||||
&Circle::new(*pt, POINT_RADIUS),
|
||||
);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ use crate::plugins::{
|
||||
choose_intersection, choose_neighborhood, choose_origin_destination, input_tick,
|
||||
input_weighted_usize, load_scenario, Plugin, PluginCtx,
|
||||
};
|
||||
use ezgui::{Color, GfxCtx, LogScroller, Wizard, WrappedWizard};
|
||||
use ezgui::{GfxCtx, LogScroller, Wizard, WrappedWizard};
|
||||
use map_model::Map;
|
||||
use piston::input::Key;
|
||||
use sim::{BorderSpawnOverTime, Neighborhood, Scenario, SeedParkedCars, SpawnOverTime};
|
||||
@ -78,11 +78,7 @@ impl Plugin for ScenarioManager {
|
||||
}
|
||||
ScenarioManager::EditScenario(_, wizard) => {
|
||||
if let Some(neighborhood) = wizard.current_menu_choice::<Neighborhood>() {
|
||||
g.draw_polygon(
|
||||
ctx.cs
|
||||
.get_def("neighborhood polygon", Color::rgba(0, 0, 255, 0.6)),
|
||||
&neighborhood.polygon,
|
||||
);
|
||||
g.draw_polygon(ctx.cs.get("neighborhood polygon"), &neighborhood.polygon);
|
||||
}
|
||||
wizard.draw(g, ctx.canvas);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::objects::Ctx;
|
||||
use crate::plugins::{Plugin, PluginCtx};
|
||||
use ezgui::{Color, GfxCtx};
|
||||
use ezgui::GfxCtx;
|
||||
use geom::Line;
|
||||
use map_model::LANE_THICKNESS;
|
||||
use piston::input::Key;
|
||||
@ -46,11 +46,7 @@ impl Plugin for DiffAllState {
|
||||
|
||||
fn draw(&self, g: &mut GfxCtx, ctx: &Ctx) {
|
||||
for line in &self.lines {
|
||||
g.draw_line(
|
||||
ctx.cs.get_def("diff agents line", Color::YELLOW),
|
||||
LANE_THICKNESS,
|
||||
line,
|
||||
);
|
||||
g.draw_line(ctx.cs.get("diff agents line"), LANE_THICKNESS, line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ impl Plugin for ShowRouteState {
|
||||
State::DebugAllRoutes(_, traces) => {
|
||||
for t in traces {
|
||||
g.draw_polygon(
|
||||
ctx.cs.get_def("route", Color::rgba(255, 0, 0, 0.8)),
|
||||
ctx.cs.get("route"),
|
||||
&t.make_polygons_blindly(LANE_THICKNESS),
|
||||
);
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ pub fn draw_signal_cycle(
|
||||
|
||||
for crosswalk in &draw_map.get_i(cycle.parent).crosswalks {
|
||||
if !hide_crosswalks.contains(&crosswalk.id1) {
|
||||
crosswalk.draw(g, cs.get_def("crosswalk", Color::WHITE));
|
||||
crosswalk.draw(g, cs.get("crosswalk"));
|
||||
}
|
||||
}
|
||||
for t in &cycle.priority_turns {
|
||||
|
Loading…
Reference in New Issue
Block a user