mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-25 15:33:44 +03:00
using new rust 1.26 match stuff, and fmt
This commit is contained in:
parent
677f74770a
commit
f2b7344940
@ -31,12 +31,12 @@ extern crate structopt;
|
||||
extern crate svg;
|
||||
extern crate vecmath;
|
||||
|
||||
use ezgui::input::UserInput;
|
||||
use glutin_window::GlutinWindow;
|
||||
use opengl_graphics::{Filter, GlGraphics, GlyphCache, OpenGL, TextureSettings};
|
||||
use piston::event_loop::{EventLoop, EventSettings, Events};
|
||||
use piston::input::RenderEvent;
|
||||
use piston::window::{Window, WindowSettings};
|
||||
use opengl_graphics::{Filter, GlGraphics, GlyphCache, OpenGL, TextureSettings};
|
||||
use ezgui::input::UserInput;
|
||||
use structopt::StructOpt;
|
||||
|
||||
mod animation;
|
||||
|
@ -35,7 +35,7 @@ impl SearchState {
|
||||
}
|
||||
|
||||
fn choose_color(&self, osm_tags: &[String]) -> Option<Color> {
|
||||
if let SearchState::FilterOSM(ref filter) = *self {
|
||||
if let SearchState::FilterOSM(filter) = self {
|
||||
for tag in osm_tags {
|
||||
if tag.contains(filter) {
|
||||
return Some(render::SEARCH_RESULT_COLOR);
|
||||
@ -78,7 +78,7 @@ impl SearchState {
|
||||
}
|
||||
|
||||
pub fn draw(&self, canvas: &Canvas, g: &mut GfxCtx) {
|
||||
if let SearchState::EnteringSearch(ref text_box) = *self {
|
||||
if let SearchState::EnteringSearch(text_box) = self {
|
||||
canvas.draw_osd_notification(g, &vec![text_box.line.clone()]);
|
||||
// TODO draw the cursor
|
||||
}
|
||||
|
@ -13,13 +13,13 @@
|
||||
// limitations under the License.
|
||||
|
||||
use animation;
|
||||
use control::ControlMap;
|
||||
use ezgui::canvas::{Canvas, GfxCtx};
|
||||
use ezgui::input::UserInput;
|
||||
use geom;
|
||||
use graphics::types::Color;
|
||||
use map_model;
|
||||
use map_model::{BuildingID, IntersectionID, Map, RoadID, TurnID};
|
||||
use control::ControlMap;
|
||||
use piston::input::{Button, Key, ReleaseEvent};
|
||||
use render;
|
||||
use sim::CarID;
|
||||
@ -156,7 +156,7 @@ impl SelectionState {
|
||||
match *self {
|
||||
SelectionState::Empty | SelectionState::SelectedTurn(_) => {}
|
||||
SelectionState::SelectedIntersection(id) => {
|
||||
if let Some(ref signal) = control_map.traffic_signals.get(&id) {
|
||||
if let Some(signal) = control_map.traffic_signals.get(&id) {
|
||||
let (cycle, _) = signal.current_cycle_and_remaining_time(sim.time.as_time());
|
||||
for t in &cycle.turns {
|
||||
draw_map.get_t(*t).draw_full(g, render::TURN_COLOR);
|
||||
|
@ -16,8 +16,8 @@ extern crate map_model;
|
||||
|
||||
use animation;
|
||||
use ezgui::canvas::{Canvas, GfxCtx};
|
||||
use graphics::types::Color;
|
||||
use ezgui::input::UserInput;
|
||||
use graphics::types::Color;
|
||||
use map_model::{Map, Pt2D, Road, RoadID, TurnID};
|
||||
use piston::input::{Key, UpdateEvent};
|
||||
use piston::window::Size;
|
||||
|
@ -14,16 +14,16 @@
|
||||
|
||||
extern crate map_model;
|
||||
|
||||
use control::ControlMap;
|
||||
use control::stop_signs::TurnPriority;
|
||||
use ezgui::canvas;
|
||||
use ezgui::input::UserInput;
|
||||
use geom::GeomMap;
|
||||
use graphics::types::Color;
|
||||
use map_model::{Map, Turn};
|
||||
use plugins::selection::SelectionState;
|
||||
use control::ControlMap;
|
||||
use map_model::IntersectionID;
|
||||
use ezgui::input::UserInput;
|
||||
use map_model::{Map, Turn};
|
||||
use piston::input::Key;
|
||||
use plugins::selection::SelectionState;
|
||||
|
||||
pub struct StopSignEditor {
|
||||
i: IntersectionID,
|
||||
|
@ -16,15 +16,15 @@
|
||||
|
||||
extern crate map_model;
|
||||
|
||||
use ezgui::canvas;
|
||||
use geom::GeomMap;
|
||||
use map_model::Map;
|
||||
use graphics::types::Color;
|
||||
use plugins::selection::SelectionState;
|
||||
use control::ControlMap;
|
||||
use map_model::{IntersectionID, Turn};
|
||||
use ezgui::canvas;
|
||||
use ezgui::input::UserInput;
|
||||
use geom::GeomMap;
|
||||
use graphics::types::Color;
|
||||
use map_model::Map;
|
||||
use map_model::{IntersectionID, Turn};
|
||||
use piston::input::Key;
|
||||
use plugins::selection::SelectionState;
|
||||
|
||||
pub struct TrafficSignalEditor {
|
||||
i: IntersectionID,
|
||||
|
@ -16,9 +16,9 @@
|
||||
|
||||
extern crate map_model;
|
||||
|
||||
use control::ControlMap;
|
||||
use graphics::types::Color;
|
||||
use map_model::{Turn, TurnID};
|
||||
use control::ControlMap;
|
||||
use std::collections::HashMap;
|
||||
|
||||
const CYCLE_COLORS: [Color; 8] = [
|
||||
|
@ -17,8 +17,8 @@ extern crate map_model;
|
||||
|
||||
use aabb_quadtree::QuadTree;
|
||||
use aabb_quadtree::geom::{Point, Rect};
|
||||
use geom::geometry;
|
||||
use geom::GeomMap;
|
||||
use geom::geometry;
|
||||
use map_model::{Bounds, BuildingID, IntersectionID, Map, ParcelID, Pt2D, RoadID, TurnID};
|
||||
use render::building::DrawBuilding;
|
||||
use render::intersection::DrawIntersection;
|
||||
|
@ -22,8 +22,8 @@ use geom::geometry;
|
||||
use graphics;
|
||||
use graphics::math::Vec2d;
|
||||
use graphics::types::Color;
|
||||
use render::{BRIGHT_DEBUG_COLOR, DEBUG_COLOR, PARCEL_BOUNDARY_THICKNESS, ROAD_ORIENTATION_COLOR};
|
||||
use map_model::{Bounds, Pt2D, RoadID};
|
||||
use render::{BRIGHT_DEBUG_COLOR, DEBUG_COLOR, PARCEL_BOUNDARY_THICKNESS, ROAD_ORIENTATION_COLOR};
|
||||
use std::f64;
|
||||
use svg;
|
||||
|
||||
|
@ -18,8 +18,8 @@ extern crate map_model;
|
||||
use aabb_quadtree::geom::Rect;
|
||||
use ezgui::canvas::GfxCtx;
|
||||
use geom;
|
||||
use geom::geometry;
|
||||
use geom::GeomMap;
|
||||
use geom::geometry;
|
||||
use graphics;
|
||||
use graphics::math::Vec2d;
|
||||
use graphics::types::Color;
|
||||
|
@ -17,13 +17,13 @@
|
||||
extern crate map_model;
|
||||
|
||||
use animation;
|
||||
use control::ControlMap;
|
||||
use ezgui::ToggleableLayer;
|
||||
use ezgui::canvas;
|
||||
use ezgui::canvas::{Canvas, GfxCtx};
|
||||
use ezgui::input::UserInput;
|
||||
use geom;
|
||||
use graphics::types::Color;
|
||||
use control::ControlMap;
|
||||
use ezgui::input::UserInput;
|
||||
use piston::input::{Key, MouseCursorEvent};
|
||||
use piston::window::Size;
|
||||
use plugins::classification::OsmClassifier;
|
||||
|
@ -14,13 +14,13 @@
|
||||
|
||||
use aabb_quadtree::geom::{Point, Rect};
|
||||
use graphics;
|
||||
use graphics::{Context, Image, Transformed};
|
||||
use graphics::character::CharacterCache;
|
||||
use graphics::types::Color;
|
||||
use graphics::{Context, Image, Transformed};
|
||||
use opengl_graphics::{GlGraphics, Texture};
|
||||
use piston::input::{Button, Event, Key, MouseButton, MouseCursorEvent, MouseScrollEvent,
|
||||
PressEvent, ReleaseEvent};
|
||||
use piston::window::Size;
|
||||
use opengl_graphics::{GlGraphics, Texture};
|
||||
|
||||
//pub const WHITE: Color = [1.0, 1.0, 1.0, 1.0];
|
||||
pub const BLACK: Color = [0.0, 0.0, 0.0, 1.0];
|
||||
|
@ -19,8 +19,8 @@ extern crate serde;
|
||||
extern crate serde_derive;
|
||||
|
||||
use ordered_float::NotNaN;
|
||||
use protobuf::{CodedInputStream, CodedOutputStream, Message};
|
||||
use protobuf::error::ProtobufError;
|
||||
use protobuf::{CodedInputStream, CodedOutputStream, Message};
|
||||
use std::collections::HashMap;
|
||||
use std::f64;
|
||||
use std::fs::File;
|
||||
|
2
rgrep.sh
2
rgrep.sh
@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
grep -R --exclude-dir=.git --exclude-dir=target --exclude-dir=data --exclude=Cargo.lock $@
|
||||
grep -R --exclude-dir=.git --exclude-dir=target --exclude-dir=data --exclude=Cargo.lock "$@"
|
||||
|
@ -54,9 +54,9 @@ impl IntersectionPolicy {
|
||||
}
|
||||
|
||||
pub fn on_enter(&self, car: CarID) {
|
||||
match *self {
|
||||
IntersectionPolicy::StopSignPolicy(ref p) => p.on_enter(car),
|
||||
IntersectionPolicy::TrafficSignalPolicy(ref p) => p.on_enter(car),
|
||||
match self {
|
||||
IntersectionPolicy::StopSignPolicy(p) => p.on_enter(car),
|
||||
IntersectionPolicy::TrafficSignalPolicy(p) => p.on_enter(car),
|
||||
}
|
||||
}
|
||||
pub fn on_exit(&mut self, car: CarID) {
|
||||
|
@ -286,7 +286,8 @@ impl SimQueue {
|
||||
pub struct Sim {
|
||||
// This is slightly dangerous, but since we'll be using comparisons based on savestating (which
|
||||
// captures the RNG), this should be OK for now.
|
||||
#[derivative(PartialEq = "ignore")] rng: XorShiftRng,
|
||||
#[derivative(PartialEq = "ignore")]
|
||||
rng: XorShiftRng,
|
||||
// TODO investigate slot map-like structures for performance
|
||||
// Using BTreeMap instead of HashMap so iteration is deterministic. Should be able to relax
|
||||
// this later after step() doesnt need a RNG.
|
||||
@ -309,9 +310,9 @@ impl Sim {
|
||||
let mut intersections: Vec<IntersectionPolicy> = Vec::new();
|
||||
for i in map.all_intersections() {
|
||||
if i.has_traffic_signal {
|
||||
intersections.push(IntersectionPolicy::TrafficSignalPolicy(
|
||||
TrafficSignal::new(i.id),
|
||||
));
|
||||
intersections.push(IntersectionPolicy::TrafficSignalPolicy(TrafficSignal::new(
|
||||
i.id,
|
||||
)));
|
||||
} else {
|
||||
intersections.push(IntersectionPolicy::StopSignPolicy(StopSign::new(i.id)));
|
||||
}
|
||||
@ -427,7 +428,7 @@ impl Sim {
|
||||
// It might make more sense to push the conflict resolution down to SimQueue?
|
||||
// TODO should shuffle deterministically here, to be more fair
|
||||
let mut new_car_entered_this_step = HashSet::new();
|
||||
for &(ref id, ref act) in &requested_moves {
|
||||
for (id, act) in &requested_moves {
|
||||
match *act {
|
||||
Action::Vanish => {
|
||||
self.cars.remove(&id);
|
||||
|
Loading…
Reference in New Issue
Block a user