]> git.localhorst.tv Git - blank.git/blob - src/app/Runtime.hpp
first draft for client/server architecture
[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                 std::string world_name = "default";
48
49                 Client::Config client = Client::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