]> git.localhorst.tv Git - l2e.git/blob - src/app/Application.h
delayed state pushing/popping till the end of each loop
[l2e.git] / src / app / Application.h
1 /*
2  * Application.h
3  *
4  *  Created on: Apr 8, 2012
5  *      Author: holy
6  */
7
8 #ifndef APP_APPLICATION_H_
9 #define APP_APPLICATION_H_
10
11 #include "Input.h"
12 #include "../sdl/InitScreen.h"
13
14 #include <stack>
15 #include <queue>
16 #include <SDL.h>
17
18
19 namespace app {
20
21 class State;
22
23 class Application {
24
25 public:
26         Application(sdl::InitScreen *screen, State *initialState);
27         ~Application();
28 private:
29         Application(const Application &);
30         Application &operator =(const Application &);
31
32 public:
33         void Run();
34         void Loop();
35
36 public:
37         void ChangeState(State *);
38         void PushState(State *);
39         void PopState();
40         void Quit();
41         Input &Buttons() { return input; }
42         const Input &Buttons() const { return input; }
43
44 private:
45         State *CurrentState();
46         void UpdateState();
47         void RealPushState(State *);
48         void RealPopState();
49         void PopAllStates();
50
51 private:
52         void HandleEvents();
53         void UpdateWorld(Uint32 deltaT);
54         void Render();
55
56 private:
57         sdl::InitScreen *screen;
58         std::stack<State *> states;
59         std::queue<State *> toPush;
60         Input input;
61         Uint32 last;
62         int toPop;
63
64 };
65
66 }
67
68 #endif /* APP_APPLICATION_H_ */