]> git.localhorst.tv Git - l2e.git/blob - src/app/Application.h
added interpretation of battle resources
[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 "Timer.h"
13 #include "../sdl/InitScreen.h"
14
15 #include <stack>
16 #include <queue>
17 #include <SDL.h>
18
19
20 namespace app {
21
22 class State;
23
24 class Application {
25
26 public:
27         Application(sdl::InitScreen *screen, State *initialState);
28         ~Application();
29 private:
30         Application(const Application &);
31         Application &operator =(const Application &);
32
33 public:
34         void Run();
35         void Loop();
36
37 public:
38         void ChangeState(State *);
39         void PushState(State *);
40         void PopState();
41         void Quit();
42         Input &Buttons() { return input; }
43         const Input &Buttons() const { return input; }
44         Timers<Uint32> &GlobalTimers() { return globalTimers; }
45
46 private:
47         struct StateCommand {
48                 enum Type {
49                         PUSH, POP, CHANGE
50                 } type;
51                 State *state;
52         };
53
54 private:
55         State *CurrentState();
56         bool StateChangePending() const { return !stateChanges.empty(); }
57         void UpdateState();
58         void RealChangeState(State *);
59         void RealPushState(State *);
60         void RealPopState();
61         void PopAllStates();
62
63 private:
64         void HandleEvents();
65         void UpdateWorld(Uint32 deltaT);
66         void Render();
67
68 private:
69         sdl::InitScreen *screen;
70         std::stack<State *> states;
71         std::queue<StateCommand> stateChanges;
72         Timers<Uint32> globalTimers;
73         Input input;
74         Uint32 last;
75
76 };
77
78 }
79
80 #endif /* APP_APPLICATION_H_ */