]> git.localhorst.tv Git - blank.git/blob - src/app/Runtime.hpp
cleanup
[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 Initialize(int argc, const char *const *argv);
52
53         int Execute();
54
55 private:
56         void ReadArgs(int argc, const char *const *argv);
57         void ReadPreferences();
58
59         void RunStandalone();
60         void RunServer();
61         void RunClient();
62
63         void Run(HeadlessApplication &);
64
65 private:
66         const char *name;
67         Mode mode;
68         Target target;
69         std::size_t n;
70         std::size_t t;
71         Config config;
72
73 };
74
75 }
76
77 #endif