mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-28 20:29:04 +03:00
move state stuff into game.rs too
This commit is contained in:
parent
6c6299c1d0
commit
965a458b15
@ -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};
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::state::{State, Transition};
|
||||
use crate::game::{State, Transition};
|
||||
use crate::ui::PerMapUI;
|
||||
use crate::ui::UI;
|
||||
use ezgui::{
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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};
|
||||
|
@ -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::{
|
||||
|
@ -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;
|
||||
|
@ -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::{
|
||||
|
@ -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>),
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ mod mission;
|
||||
mod render;
|
||||
mod sandbox;
|
||||
mod splash_screen;
|
||||
mod state;
|
||||
mod tutorial;
|
||||
mod ui;
|
||||
|
||||
|
@ -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::{
|
||||
|
@ -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::{
|
||||
|
@ -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};
|
||||
|
@ -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};
|
||||
|
@ -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,
|
||||
|
@ -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::{
|
||||
|
@ -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};
|
||||
|
@ -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};
|
||||
|
@ -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,
|
||||
|
@ -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};
|
||||
|
@ -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;
|
||||
|
@ -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>),
|
||||
}
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user