]> git.localhorst.tv Git - l2e.git/blob - src/app/Application.h
reworked gauges to better reflect the original ones
[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         struct StateCommand {
46                 enum Type {
47                         PUSH, POP, CHANGE
48                 } type;
49                 State *state;
50         };
51
52 private:
53         State *CurrentState();
54         bool StateChangePending() const { return !stateChanges.empty(); }
55         void UpdateState();
56         void RealChangeState(State *);
57         void RealPushState(State *);
58         void RealPopState();
59         void PopAllStates();
60
61 private:
62         void HandleEvents();
63         void UpdateWorld(Uint32 deltaT);
64         void Render();
65
66 private:
67         sdl::InitScreen *screen;
68         std::stack<State *> states;
69         std::queue<StateCommand> stateChanges;
70         Input input;
71         Uint32 last;
72
73 };
74
75 }
76
77 #endif /* APP_APPLICATION_H_ */