]> git.localhorst.tv Git - gong.git/blob - src/app/Runtime.hpp
code, assets, and other stuff stolen from blank
[gong.git] / src / app / Runtime.hpp
1 #ifndef GONG_APP_RUNTIME_HPP_
2 #define GONG_APP_RUNTIME_HPP_
3
4 #include "Config.hpp"
5 #include "HeadlessEnvironment.hpp"
6
7 #include <cstddef>
8 #include <string>
9
10
11 namespace gong {
12 namespace app {
13
14 class HeadlessApplication;
15
16 /// Parse and interpret arguemnts, then set up the environment and execute.
17 class Runtime {
18
19 public:
20         enum Mode {
21                 /// default behaviour: run until user quits, dynamic timesteps
22                 NORMAL,
23                 /// quit after n frames
24                 FRAME_LIMIT,
25                 /// quit after n milliseconds
26                 TIME_LIMIT,
27                 /// quit after n frames, use fixed timestap
28                 FIXED_FRAME_LIMIT,
29                 /// display error message and quit with failure
30                 ERROR,
31         };
32
33         enum Target {
34                 STANDALONE,
35                 SERVER,
36                 CLIENT,
37         };
38
39         struct Config {
40                 app::Config game = app::Config();
41                 HeadlessEnvironment::Config env = HeadlessEnvironment::Config();
42         };
43
44         Runtime() noexcept;
45
46         void Initialize(int argc, const char *const *argv);
47
48         int Execute();
49
50 private:
51         void ReadArgs(int argc, const char *const *argv);
52         void ReadPreferences();
53
54         void RunStandalone();
55         void RunServer();
56         void RunClient();
57
58         void Run(HeadlessApplication &);
59
60 private:
61         const char *name;
62         Mode mode;
63         Target target;
64         std::size_t n;
65         std::size_t t;
66         Config config;
67
68 };
69
70 }
71 }
72
73 #endif