|
1 | 1 | #ifndef CONFIG_H |
2 | 2 | #define CONFIG_H |
3 | 3 |
|
| 4 | +#include "Util/Logger.hpp" |
4 | 5 | #include "pch.hpp" // IWYU pragma: export |
5 | 6 |
|
6 | | -#include "Util/Logger.hpp" |
| 7 | +namespace Core { |
| 8 | +class Context; |
| 9 | +} |
7 | 10 |
|
8 | | -constexpr const char *TITLE = "Practical Tools for Simple Design"; |
| 11 | +// clang-format off |
| 12 | +/** |
| 13 | + * To use, place a config.json file either in the current directory (.) or |
| 14 | + * the parent directory (..). If both directories contain the file, the one |
| 15 | + * in the current directory will be read. |
| 16 | + * |
| 17 | + * Example directory structure: |
| 18 | + * |
| 19 | + * @code{.md} |
| 20 | + * ├── build/ |
| 21 | + * │ ├── YOUR_GAME |
| 22 | + * │ └── config.json <- place here |
| 23 | + * └── config.json <- or here |
| 24 | + * @endcode |
| 25 | + * |
| 26 | + * The config.json file can contain any number of configurations, each in |
| 27 | + * the following format: |
| 28 | + * |
| 29 | + * @code{.json} |
| 30 | + * { |
| 31 | + * "title": "<string, default is 'Practice-Tools-for-Simple-Design'>", |
| 32 | + * "window_pos_x": <int, default is SDL_WINDOWPOS_UNDEFINED (wherever the OS places the window)>, |
| 33 | + * "window_pos_y": <int, default is SDL_WINDOWPOS_UNDEFINED (wherever the OS places the window)>, |
| 34 | + * "window_width": <int, default is 1280>, |
| 35 | + * "window_height": <int, default is 720>, |
| 36 | + * "default_log_level": <int in range [0, 5], default is 2 (Util::Logger::Level::INFO)>, |
| 37 | + * "fps_cap": <int, default is 60> |
| 38 | + * } |
| 39 | + * @endcode |
| 40 | + * |
| 41 | + * If a key is not present in the config.json, the default value will be |
| 42 | + * used. |
| 43 | + */ |
| 44 | +// clang-format on |
| 45 | +struct PTSD_Config { |
| 46 | +public: |
| 47 | + static std::string_view TITLE; |
9 | 48 |
|
10 | | -constexpr int WINDOW_POS_X = SDL_WINDOWPOS_UNDEFINED; |
11 | | -constexpr int WINDOW_POS_Y = SDL_WINDOWPOS_UNDEFINED; |
| 49 | + static int WINDOW_POS_X; |
12 | 50 |
|
13 | | -constexpr unsigned int WINDOW_WIDTH = 1280; |
14 | | -constexpr unsigned int WINDOW_HEIGHT = 720; |
| 51 | + static int WINDOW_POS_Y; |
| 52 | + static unsigned int WINDOW_WIDTH; |
15 | 53 |
|
16 | | -constexpr Util::Logger::Level DEFAULT_LOG_LEVEL = Util::Logger::Level::DEBUG; |
| 54 | + static unsigned int WINDOW_HEIGHT; |
| 55 | + static Util::Logger::Level DEFAULT_LOG_LEVEL; |
17 | 56 |
|
18 | | -/** |
19 | | - * @brief FPS limit |
20 | | - * |
21 | | - * Set value to 0 to turn off FPS cap |
22 | | - */ |
23 | | -constexpr unsigned int FPS_CAP = 60; |
| 57 | + /** |
| 58 | + * @brief FPS limit |
| 59 | + * |
| 60 | + * Set value to 0 to turn off FPS cap |
| 61 | + */ |
| 62 | + static unsigned int FPS_CAP; |
| 63 | + |
| 64 | +private: |
| 65 | + friend class Core::Context; |
| 66 | + static void Init(); |
| 67 | +}; // namespace PTSD_Config |
24 | 68 |
|
25 | 69 | #endif |
0 commit comments