move state stuff into game.rs too

This commit is contained in:
Dustin Carlino 2019-06-22 17:03:30 -07:00
parent 6c6299c1d0
commit 965a458b15
25 changed files with 37 additions and 41 deletions

View File

@ -2,8 +2,8 @@ mod score;
pub mod setup;
use crate::common::{CommonState, SpeedControls};
use crate::game::{State, Transition};
use crate::render::MIN_ZOOM_FOR_DETAIL;
use crate::state::{State, Transition};
use crate::ui::{PerMapUI, ShowEverything, UI};
use ezgui::{hotkey, Color, EventCtx, EventLoopMode, GeomBatch, GfxCtx, Key, ModalMenu, Text};
use geom::{Circle, Distance, Duration, Line, PolyLine};

View File

@ -1,4 +1,4 @@
use crate::state::{State, Transition};
use crate::game::{State, Transition};
use crate::ui::PerMapUI;
use crate::ui::UI;
use ezgui::{

View File

@ -1,7 +1,7 @@
use crate::abtest::{ABTestMode, ABTestSavestate};
use crate::edit::apply_map_edits;
use crate::game::{State, Transition};
use crate::render::DrawMap;
use crate::state::{State, Transition};
use crate::ui::{Flags, PerMapUI, UI};
use ezgui::{
hotkey, EventCtx, EventLoopMode, GfxCtx, Key, LogScroller, ModalMenu, Wizard, WrappedWizard,

View File

@ -1,6 +1,6 @@
use crate::common::CommonState;
use crate::game::{State, Transition};
use crate::helpers::ID;
use crate::state::{State, Transition};
use crate::ui::{ShowEverything, UI};
use ezgui::{EventCtx, EventLoopMode, GfxCtx, Key, Text, WarpingItemSlider};
use geom::Pt2D;

View File

@ -1,4 +1,4 @@
use crate::state::{State, Transition};
use crate::game::{State, Transition};
use crate::ui::UI;
use ezgui::{
hotkey, Canvas, Color, EventCtx, EventLoopMode, GfxCtx, InputResult, Key, ModalMenu, ScreenPt,

View File

@ -8,9 +8,9 @@ mod polygons;
use crate::common::CommonState;
use crate::edit::EditMode;
use crate::game::{State, Transition};
use crate::helpers::ID;
use crate::sandbox::SandboxMode;
use crate::state::{State, Transition};
use crate::ui::{ShowLayers, ShowObject, UI};
use abstutil::wraparound_get;
use abstutil::Timer;

View File

@ -1,6 +1,6 @@
use crate::game::{State, Transition};
use crate::helpers::ID;
use crate::render::calculate_corners;
use crate::state::{State, Transition};
use crate::ui::UI;
use abstutil::Timer;
use ezgui::{hotkey, EventCtx, EventLoopMode, GfxCtx, ItemSlider, Key, Text};

View File

@ -3,13 +3,13 @@ mod traffic_signals;
use crate::common::CommonState;
use crate::debug::DebugMode;
use crate::game::{State, Transition};
use crate::helpers::{ColorScheme, ID};
use crate::render::{
DrawCtx, DrawIntersection, DrawLane, DrawMap, DrawOptions, DrawTurn, Renderable,
MIN_ZOOM_FOR_DETAIL,
};
use crate::sandbox::SandboxMode;
use crate::state::{State, Transition};
use crate::ui::{PerMapUI, ShowEverything, UI};
use abstutil::Timer;
use ezgui::{

View File

@ -1,8 +1,8 @@
use crate::common::CommonState;
use crate::edit::apply_map_edits;
use crate::game::{State, Transition};
use crate::helpers::ID;
use crate::render::{DrawIntersection, DrawOptions, DrawTurn};
use crate::state::{State, Transition};
use crate::ui::{ShowEverything, UI};
use ezgui::{hotkey, Color, EventCtx, EventLoopMode, GeomBatch, GfxCtx, Key, ModalMenu, Text};
use geom::Polygon;

View File

@ -1,8 +1,8 @@
use crate::common::CommonState;
use crate::edit::apply_map_edits;
use crate::game::{State, Transition};
use crate::helpers::ID;
use crate::render::{draw_signal_cycle, draw_signal_diagram, DrawCtx, DrawOptions, DrawTurn};
use crate::state::{State, Transition};
use crate::ui::{ShowEverything, UI};
use abstutil::Timer;
use ezgui::{

View File

@ -1,7 +1,6 @@
use crate::render::DrawOptions;
use crate::sandbox::SandboxMode;
use crate::splash_screen::SplashScreen;
use crate::state::{State, Transition};
use crate::ui::{EditorState, Flags, ShowEverything, UI};
use ezgui::{Canvas, EventCtx, EventLoopMode, GfxCtx, GUI};
@ -114,3 +113,18 @@ impl GUI for Game {
self.ui.primary.current_flags.enable_profiler
}
}
pub trait State {
fn event(&mut self, ctx: &mut EventCtx, ui: &mut UI) -> (Transition, EventLoopMode);
fn draw(&self, g: &mut GfxCtx, ui: &UI);
fn draw_default_ui(&self) -> bool {
true
}
}
pub enum Transition {
Keep,
Pop,
Push(Box<State>),
Replace(Box<State>),
}

View File

@ -8,7 +8,6 @@ mod mission;
mod render;
mod sandbox;
mod splash_screen;
mod state;
mod tutorial;
mod ui;

View File

@ -1,6 +1,6 @@
use crate::common::{CommonState, SpeedControls};
use crate::game::{State, Transition};
use crate::mission::trips::{clip_trips, Trip};
use crate::state::{State, Transition};
use crate::ui::{ShowEverything, UI};
use abstutil::prettyprint_usize;
use ezgui::{

View File

@ -1,6 +1,6 @@
use crate::common::CommonState;
use crate::game::{State, Transition};
use crate::helpers::{rotating_color_total, ID};
use crate::state::{State, Transition};
use crate::ui::UI;
use abstutil::{prettyprint_usize, Timer};
use ezgui::{

View File

@ -1,7 +1,7 @@
use crate::common::CommonState;
use crate::game::{State, Transition};
use crate::helpers::ID;
use crate::mission::trips::{clip_trips, Trip, TripEndpt};
use crate::state::{State, Transition};
use crate::ui::{ShowEverything, UI};
use ezgui::{hotkey, Color, EventCtx, EventLoopMode, GfxCtx, ItemSlider, Key, Text};
use geom::{Circle, Distance, Line, Speed};

View File

@ -6,8 +6,8 @@ mod scenario;
mod trips;
use self::trips::{pick_time_range, trips_to_scenario};
use crate::game::{State, Transition};
use crate::sandbox::SandboxMode;
use crate::state::{State, Transition};
use crate::ui::UI;
use abstutil::Timer;
use ezgui::{hotkey, EventCtx, EventLoopMode, GfxCtx, Key, ModalMenu, Wizard, WrappedWizard};

View File

@ -1,4 +1,4 @@
use crate::state::{State, Transition};
use crate::game::{State, Transition};
use crate::ui::UI;
use ezgui::{
hotkey, Color, EventCtx, EventLoopMode, GfxCtx, Key, ModalMenu, Wizard, WrappedWizard,

View File

@ -1,6 +1,6 @@
use crate::game::{State, Transition};
use crate::mission::input_time;
use crate::sandbox::SandboxMode;
use crate::state::{State, Transition};
use crate::ui::UI;
use abstutil::WeightedUsizeChoice;
use ezgui::{

View File

@ -8,7 +8,7 @@ mod time_travel;
use crate::common::{CommonState, SpeedControls};
use crate::debug::DebugMode;
use crate::edit::EditMode;
use crate::state::{State, Transition};
use crate::game::{State, Transition};
//use crate::mission::input_time;
use crate::ui::{ShowEverything, UI};
use ezgui::{hotkey, lctrl, EventCtx, EventLoopMode, GfxCtx, Key, ModalMenu, Text, Wizard};

View File

@ -1,6 +1,6 @@
use crate::common::CommonState;
use crate::game::{State, Transition};
use crate::render::DrawTurn;
use crate::state::{State, Transition};
use crate::ui::{ShowEverything, UI};
use ezgui::{Color, EventCtx, EventLoopMode, GfxCtx, Key, Text, WarpingItemSlider};
use geom::{Distance, Polygon, Pt2D};

View File

@ -1,4 +1,4 @@
use crate::state::{State, Transition};
use crate::game::{State, Transition};
use crate::ui::UI;
use ezgui::{
hotkey, EventCtx, EventLoopMode, GfxCtx, HorizontalAlignment, Key, ModalMenu, Text,

View File

@ -1,7 +1,7 @@
use crate::common::CommonState;
use crate::game::{State, Transition};
use crate::helpers::ID;
use crate::render::DrawOptions;
use crate::state::{State, Transition};
use crate::ui::{ShowEverything, UI};
use abstutil::Timer;
use ezgui::{hotkey, EventCtx, EventLoopMode, GfxCtx, Key, ModalMenu};

View File

@ -1,9 +1,9 @@
use crate::abtest::setup::PickABTest;
use crate::debug::DebugMode;
use crate::edit::EditMode;
use crate::game::{State, Transition};
use crate::mission::MissionEditMode;
use crate::sandbox::SandboxMode;
use crate::state::{State, Transition};
use crate::tutorial::TutorialMode;
use crate::ui::UI;
use abstutil::elapsed_seconds;

View File

@ -1,17 +0,0 @@
use crate::ui::UI;
use ezgui::{EventCtx, EventLoopMode, GfxCtx};
pub trait State {
fn event(&mut self, ctx: &mut EventCtx, ui: &mut UI) -> (Transition, EventLoopMode);
fn draw(&self, g: &mut GfxCtx, ui: &UI);
fn draw_default_ui(&self) -> bool {
true
}
}
pub enum Transition {
Keep,
Pop,
Push(Box<State>),
Replace(Box<State>),
}

View File

@ -1,4 +1,4 @@
use crate::state::{State, Transition};
use crate::game::{State, Transition};
use crate::ui::UI;
use ezgui::{hotkey, EventCtx, EventLoopMode, GfxCtx, Key, ModalMenu, Text};
use geom::Pt2D;