]> git.localhorst.tv Git - gong.git/blob - src/app/HeadlessApplication.hpp
code, assets, and other stuff stolen from blank
[gong.git] / src / app / HeadlessApplication.hpp
1 #ifndef GONG_APP_HEADLESSAPPLICATION_HPP_
2 #define GONG_APP_HEADLESSAPPLICATION_HPP_
3
4 #include <SDL.h>
5 #include <stack>
6
7
8 namespace gong {
9 namespace app {
10
11 class HeadlessEnvironment;
12 class State;
13
14
15 class HeadlessApplication {
16
17 public:
18         explicit HeadlessApplication(HeadlessEnvironment &);
19         ~HeadlessApplication();
20
21         void PushState(State *);
22         State *PopState();
23         State *SwitchState(State *);
24         State &GetState();
25         void CommitStates();
26         bool HasState() const noexcept;
27
28         /// run until out of states
29         void Run();
30         /// evaluate a single frame of dt milliseconds
31         virtual void Loop(int dt);
32
33         /// run for n frames
34         void RunN(size_t n);
35         /// run for t milliseconds
36         void RunT(size_t t);
37         /// run for n frames, assuming t milliseconds for each
38         void RunS(size_t n, size_t t);
39
40         /// process all events in SDL's queue
41         void HandleEvents();
42         void Handle(const SDL_Event &);
43         /// integrate to the next step with dt milliseconds passed
44         void Update(int dt);
45
46 private:
47         HeadlessEnvironment &env;
48         std::stack<State *> states;
49
50 };
51
52 }
53 }
54
55 #endif