4 * Created on: Apr 8, 2012
8 #ifndef APP_APPLICATION_H_
9 #define APP_APPLICATION_H_
14 #include "../sdl/InitScreen.h"
23 /// Application controller class.
24 /// Operates on a state stack that can be modified via ChangeState, PushState,
26 /// All state changes are delayed until the looping mechanism gets control again
27 /// (i.e. after a top level state function returns, not during).
28 /// SDL key events are preprocessed, see app::Input.
29 /// The quit event (typically window closed or signal received) is caught and
30 /// results in immediate (that is, after the next input loop) termination.
31 /// Popped states will be deleted via the plain delete operator on an app::State
33 /// Timers created by GlobalTimers() operate on actual application time and are
34 /// not paused when the current state is paused (as are the timers started by
35 /// the app::State members).
39 Application(sdl::InitScreen &screen, State *initialState);
42 Application(const Application &);
43 Application &operator =(const Application &);
50 void ChangeState(State *);
51 void PushState(State *);
54 Input &Buttons() { return input; }
55 const Input &Buttons() const { return input; }
56 Timers<Uint32> &GlobalTimers() { return globalTimers; }
67 State *CurrentState();
68 bool StateChangePending() const { return !stateChanges.empty(); }
70 void RealChangeState(State *);
71 void RealPushState(State *);
77 void UpdateWorld(Uint32 deltaT);
81 sdl::InitScreen &screen;
82 std::stack<State *> states;
83 std::queue<StateCommand> stateChanges;
84 Timers<Uint32> globalTimers;
93 #endif /* APP_APPLICATION_H_ */