X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fapp%2FApplication.h;h=5e9e88838dfb05db9ae0dc4d11dc64dacd8b7275;hb=25d7499f7923291d7287123320e7563a367e92e7;hp=f70dd69a29185383f395566397769e980c32aff1;hpb=867fd5d9b79c3b9c1d0fb17ba9f55cfe971b93d5;p=l2e.git diff --git a/src/app/Application.h b/src/app/Application.h index f70dd69..5e9e888 100644 --- a/src/app/Application.h +++ b/src/app/Application.h @@ -12,6 +12,7 @@ #include "../sdl/InitScreen.h" #include +#include #include @@ -23,37 +24,49 @@ class Application { public: Application(sdl::InitScreen *screen, State *initialState); - ~Application(void); + ~Application(); private: Application(const Application &); Application &operator =(const Application &); public: - void Run(void); - void Loop(void); + void Run(); + void Loop(); public: void ChangeState(State *); void PushState(State *); - void PopState(void); - void Quit(void); + void PopState(); + void Quit(); Input &Buttons() { return input; } const Input &Buttons() const { return input; } private: - State *CurrentState(void); + struct StateCommand { + enum Type { + PUSH, POP, CHANGE + } type; + State *state; + }; + +private: + State *CurrentState(); + bool StateChangePending() const { return !stateChanges.empty(); } + void UpdateState(); + void RealChangeState(State *); void RealPushState(State *); - void RealPopState(void); - void PopAllStates(void); + void RealPopState(); + void PopAllStates(); private: - void HandleEvents(void); + void HandleEvents(); void UpdateWorld(Uint32 deltaT); - void Render(void); + void Render(); private: sdl::InitScreen *screen; std::stack states; + std::queue stateChanges; Input input; Uint32 last;