support for merging an optional list of config files at the beginning of the program

This commit is contained in:
ohsqueezy 2023-12-26 22:31:28 -05:00
parent 5d950387a8
commit 11c8abcc54
2 changed files with 8 additions and 3 deletions

View File

@ -10,20 +10,25 @@
#include "Game.hpp"
Game::Game()
Game::Game(std::initializer_list<std::string> configuration_merge)
{
/* Set custom log function that prints to stdout/stderr and to file if enabled. Temporarily set to DEBUG priority before loading
* user setting. */
SDL_LogSetOutputFunction(&Game::sdl_log_override, this);
SDL_LogSetPriority(sb::Log::DEFAULT_CATEGORY, SDL_LOG_PRIORITY_DEBUG);
/* Merge user configuration into the existing configuration and turn on auto refresh if it is enabled by the configuration. */
/* Merge user configuration into the existing configuration and turn on auto refresh if it is enabled by the configuration. Merge
* configuration file paths passed into the contructor as well. */
_configuration.merge(user_config_path);
#ifdef __ANDROID__
_configuration.merge(configuration()("configuration", "android config path").get<std::string>());
#elif defined(__EMSCRIPTEN__)
_configuration.merge(configuration()("configuration", "wasm config path").get<std::string>());
#endif
for (const std::string& extra_configuration_path : configuration_merge)
{
_configuration.merge(extra_configuration_path);
}
if (configuration()("configuration", "auto refresh"))
{
_configuration.enable_auto_refresh(user_config_path);

View File

@ -109,7 +109,7 @@ public:
Input input {this};
std::vector<float> frame_length_history;
Game();
Game(std::initializer_list<std::string> configuration_merge);
virtual void reset() { activate(); }
void print_frame_length_history();
void load_sdl_context();