mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-29 17:34:58 +03:00
make UI generic over UIState
This commit is contained in:
parent
28327b4905
commit
bb71418fd3
@ -33,7 +33,7 @@ fn main() {
|
||||
.start("./profile")
|
||||
.unwrap();*/
|
||||
ezgui::run(
|
||||
ui::UI::new(flags.sim_flags, flags.kml),
|
||||
ui::UI::<state::DefaultUIState>::new(flags.sim_flags, flags.kml),
|
||||
"A/B Street",
|
||||
1024,
|
||||
768,
|
||||
|
@ -17,14 +17,13 @@ use std::process;
|
||||
|
||||
const MIN_ZOOM_FOR_MOUSEOVER: f64 = 4.0;
|
||||
|
||||
pub struct UI {
|
||||
// TODO Use generics instead
|
||||
state: Box<UIState>,
|
||||
pub struct UI<S: UIState> {
|
||||
state: S,
|
||||
canvas: Canvas,
|
||||
cs: ColorScheme,
|
||||
}
|
||||
|
||||
impl GUI<RenderingHints> for UI {
|
||||
impl<S: UIState> GUI<RenderingHints> for UI<S> {
|
||||
fn event(&mut self, mut input: UserInput) -> (EventLoopMode, RenderingHints) {
|
||||
let mut hints = RenderingHints {
|
||||
mode: EventLoopMode::InputOnly,
|
||||
@ -166,10 +165,10 @@ impl PerMapUI {
|
||||
}
|
||||
}
|
||||
|
||||
impl UI {
|
||||
pub fn new(flags: SimFlags, kml: Option<String>) -> UI {
|
||||
impl<S: UIState> UI<S> {
|
||||
pub fn new(flags: SimFlags, kml: Option<String>) -> UI<DefaultUIState> {
|
||||
let canvas = Canvas::new();
|
||||
let state = Box::new(DefaultUIState::new(flags, kml, &canvas));
|
||||
let state = DefaultUIState::new(flags, kml, &canvas);
|
||||
|
||||
let mut ui = UI {
|
||||
state,
|
||||
|
Loading…
Reference in New Issue
Block a user