mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-28 20:29:04 +03:00
clean up old traits
This commit is contained in:
parent
12540970b3
commit
8a7413ac68
@ -3,7 +3,6 @@
|
||||
## Performance
|
||||
|
||||
- cache draw agents
|
||||
- dont use traits for things... or move code back to DrawMap after all.
|
||||
- actually use Drawables in the places
|
||||
|
||||
## Quick n easy
|
||||
|
@ -124,6 +124,36 @@ impl DefaultUIState {
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
pub fn show_icons_for(&self, id: IntersectionID) -> bool {
|
||||
if let Some(ref plugin) = self.exclusive_blocking_plugin {
|
||||
if let Ok(p) = plugin.downcast_ref::<edit::stop_sign_editor::StopSignEditor>() {
|
||||
return p.show_turn_icons(id);
|
||||
}
|
||||
if let Ok(p) = plugin.downcast_ref::<edit::traffic_signal_editor::TrafficSignalEditor>()
|
||||
{
|
||||
return p.show_turn_icons(id);
|
||||
}
|
||||
}
|
||||
|
||||
self.layers.show_all_turn_icons.is_enabled() || {
|
||||
// TODO This sounds like some old hack, probably remove this?
|
||||
if let Some(ID::Turn(t)) = self.primary.current_selection {
|
||||
t.parent == id
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn show(&self, obj: ID) -> bool {
|
||||
if let Some(ref p) = self.primary_plugins.hider {
|
||||
if !p.show(obj) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
self.layers.show(obj)
|
||||
}
|
||||
}
|
||||
|
||||
impl UIState for DefaultUIState {
|
||||
@ -376,44 +406,6 @@ impl UIState for DefaultUIState {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Doesn't need to be a trait anymore
|
||||
pub trait ShowObjects {
|
||||
fn show_icons_for(&self, id: IntersectionID) -> bool;
|
||||
fn show(&self, obj: ID) -> bool;
|
||||
}
|
||||
|
||||
impl ShowObjects for DefaultUIState {
|
||||
fn show_icons_for(&self, id: IntersectionID) -> bool {
|
||||
if let Some(ref plugin) = self.exclusive_blocking_plugin {
|
||||
if let Ok(p) = plugin.downcast_ref::<edit::stop_sign_editor::StopSignEditor>() {
|
||||
return p.show_turn_icons(id);
|
||||
}
|
||||
if let Ok(p) = plugin.downcast_ref::<edit::traffic_signal_editor::TrafficSignalEditor>()
|
||||
{
|
||||
return p.show_turn_icons(id);
|
||||
}
|
||||
}
|
||||
|
||||
self.layers.show_all_turn_icons.is_enabled() || {
|
||||
// TODO This sounds like some old hack, probably remove this?
|
||||
if let Some(ID::Turn(t)) = self.primary.current_selection {
|
||||
t.parent == id
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn show(&self, obj: ID) -> bool {
|
||||
if let Some(ref p) = self.primary_plugins.hider {
|
||||
if !p.show(obj) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
self.layers.show(obj)
|
||||
}
|
||||
}
|
||||
|
||||
// All of the state that's bound to a specific map+edit has to live here.
|
||||
pub struct PerMapUI {
|
||||
pub map: Map,
|
||||
|
@ -2,7 +2,7 @@ use abstutil;
|
||||
//use cpuprofiler;
|
||||
use crate::objects::{Ctx, RenderingHints, ID};
|
||||
use crate::render::{new_draw_vehicle, AgentCache, DrawPedestrian, RenderOptions, Renderable};
|
||||
use crate::state::{ShowObjects, UIState};
|
||||
use crate::state::UIState;
|
||||
use ezgui::{
|
||||
Canvas, Color, EventCtx, EventLoopMode, Folder, GfxCtx, Key, ModalMenu, Prerender, Text,
|
||||
TopMenu, BOTTOM_LEFT, GUI,
|
||||
@ -382,7 +382,8 @@ impl<S: UIState> UI<S> {
|
||||
info!("Saved editor_state");
|
||||
}
|
||||
|
||||
// TODO I guess this technically could go in DrawMap, but we have to pass lots of stuff again.
|
||||
// TODO This could probably belong to DrawMap again, but it's annoying to plumb things that
|
||||
// State does, like show_icons_for() and show().
|
||||
fn get_renderables_back_to_front<'a>(
|
||||
&'a self,
|
||||
bounds: Bounds,
|
||||
|
Loading…
Reference in New Issue
Block a user