From 11c8abcc5441db15dbdcbb9cce8c42fc37803607 Mon Sep 17 00:00:00 2001 From: frank Date: Tue, 26 Dec 2023 22:31:28 -0500 Subject: [PATCH] support for merging an optional list of config files at the beginning of the program --- src/Game.cpp | 9 +++++++-- src/Game.hpp | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Game.cpp b/src/Game.cpp index a55f265..5a8d73a 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -10,20 +10,25 @@ #include "Game.hpp" -Game::Game() +Game::Game(std::initializer_list 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()); #elif defined(__EMSCRIPTEN__) _configuration.merge(configuration()("configuration", "wasm config path").get()); #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); diff --git a/src/Game.hpp b/src/Game.hpp index 5e2593e..0092bd3 100644 --- a/src/Game.hpp +++ b/src/Game.hpp @@ -109,7 +109,7 @@ public: Input input {this}; std::vector frame_length_history; - Game(); + Game(std::initializer_list configuration_merge); virtual void reset() { activate(); } void print_frame_length_history(); void load_sdl_context();