]> git.localhorst.tv Git - blank.git/blob - src/app/Runtime.hpp
81c015c3668456360b1c84dc77587ba026848b1a
[blank.git] / src / app / Runtime.hpp
1 #ifndef BLANK_RUNTIME_HPP_
2 #define BLANK_RUNTIME_HPP_
3
4 #include "../ui/Interface.hpp"
5 #include "../world/World.hpp"
6
7 #include <cstddef>
8 #include <string>
9
10
11 namespace blank {
12
13 /// Parse and interpret arguemnts, then set up the environment and execute.
14 class Runtime {
15
16 public:
17         enum Mode {
18                 /// default behaviour: run until user quits, dynamic timesteps
19                 NORMAL,
20                 /// quit after n frames
21                 FRAME_LIMIT,
22                 /// quit after n milliseconds
23                 TIME_LIMIT,
24                 /// quit after n frames, use fixed timestap
25                 FIXED_FRAME_LIMIT,
26                 /// display error message and quit with failure
27                 ERROR,
28         };
29
30         struct Config {
31                 bool vsync = true;
32                 bool doublebuf = true;
33                 int multisampling = 1;
34
35                 std::string asset_path;
36                 std::string save_path;
37                 std::string world_name = "default";
38
39                 Interface::Config interface = Interface::Config();
40                 World::Config world = World::Config();
41         };
42
43         Runtime() noexcept;
44
45         void ReadArgs(int argc, const char *const *argv);
46
47         int Execute();
48
49 private:
50         const char *name;
51         Mode mode;
52         std::size_t n;
53         std::size_t t;
54         Config config;
55
56 };
57
58 }
59
60 #endif