X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fapp%2FApplication.h;h=b7b0001f7bbbf874a193f7a8dbaeb0e2cd50a07a;hb=aa1a197e532673f0c4d33dee5bed27298c050d38;hp=159f627c0a87f1c4ab62e63eaf67594d4d30de9d;hpb=ef384cccd0e23a5de0a82f35ef3367754a8c3719;p=l2e.git diff --git a/src/app/Application.h b/src/app/Application.h index 159f627..b7b0001 100644 --- a/src/app/Application.h +++ b/src/app/Application.h @@ -8,49 +8,68 @@ #ifndef APP_APPLICATION_H_ #define APP_APPLICATION_H_ +#include "fwd.h" +#include "Input.h" +#include "Timer.h" #include "../sdl/InitScreen.h" #include +#include #include namespace app { -class State; - class Application { public: - explicit Application(SDL_Surface *screen, State *initialState); - ~Application(void); + Application(sdl::InitScreen *screen, State *initialState); + ~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; } + Timers &GlobalTimers() { return globalTimers; } + +private: + struct StateCommand { + enum Type { + PUSH, POP, CHANGE + } type; + State *state; + }; private: - State *CurrentState(void); + 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_Surface *screen; + sdl::InitScreen *screen; std::stack states; + std::queue stateChanges; + Timers globalTimers; + Input input; Uint32 last; };