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