]> git.localhorst.tv Git - l2e.git/blob - src/app/Application.h
added initializer lists to Hero and Monster models
[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         void UpdateState();
55         void RealChangeState(State *);
56         void RealPushState(State *);
57         void RealPopState();
58         void PopAllStates();
59
60 private:
61         void HandleEvents();
62         void UpdateWorld(Uint32 deltaT);
63         void Render();
64
65 private:
66         sdl::InitScreen *screen;
67         std::stack<State *> states;
68         std::queue<StateCommand> stateChanges;
69         Input input;
70         Uint32 last;
71
72 };
73
74 }
75
76 #endif /* APP_APPLICATION_H_ */