]> git.localhorst.tv Git - blank.git/blob - src/app/Runtime.hpp
split chunk stuff
[blank.git] / src / app / Runtime.hpp
1 #ifndef BLANK_RUNTIME_HPP_
2 #define BLANK_RUNTIME_HPP_
3
4 #include "Environment.hpp"
5 #include "../net/Client.hpp"
6 #include "../net/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                 bool vsync = true;
44                 bool doublebuf = true;
45                 int multisampling = 1;
46
47                 Client::Config client = Client::Config();
48                 Generator::Config gen = Generator::Config();
49                 HeadlessEnvironment::Config env = HeadlessEnvironment::Config();
50                 Interface::Config interface = Interface::Config();
51                 Server::Config server = Server::Config();
52                 World::Config world = World::Config();
53         };
54
55         Runtime() noexcept;
56
57         void ReadArgs(int argc, const char *const *argv);
58
59         int Execute();
60
61 private:
62         void RunStandalone();
63         void RunServer();
64         void RunClient();
65
66         void Run(HeadlessApplication &);
67
68 private:
69         const char *name;
70         Mode mode;
71         Target target;
72         std::size_t n;
73         std::size_t t;
74         Config config;
75
76 };
77
78 }
79
80 #endif