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