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