From 5d950387a872e6043ea40387bc31b80559084bc6 Mon Sep 17 00:00:00 2001 From: frank Date: Tue, 26 Dec 2023 20:26:31 -0500 Subject: [PATCH] make android and wasm config file paths configurable --- BPmono.ttf | Bin src/Configuration.cpp | 8 +++++--- src/Game.cpp | 6 +++--- src/Game.hpp | 2 -- 4 files changed, 8 insertions(+), 8 deletions(-) mode change 100755 => 100644 BPmono.ttf diff --git a/BPmono.ttf b/BPmono.ttf old mode 100755 new mode 100644 diff --git a/src/Configuration.cpp b/src/Configuration.cpp index b44d4b2..e09a279 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -97,8 +97,10 @@ void Configuration::set_defaults() {"short-name", "spacebox"} }; config["configuration"] = { - {"auto-refresh", false}, - {"auto-refresh-interval", 5.0} + {"auto refresh", false}, + {"auto refresh interval", 5.0}, + {"android config path", "config_android.json"}, + {"wasm config path", "config_wasm.json"} }; } @@ -214,7 +216,7 @@ void Configuration::enable_auto_refresh(const fs::path& file_to_refresh) } #endif files_to_refresh.push_back(file_to_refresh); - auto_refresher.frame_length(config["configuration"]["auto-refresh-interval"].get()); + auto_refresher.frame_length(config.at("configuration").at("auto refresh interval").get()); auto_refresher.play(); } diff --git a/src/Game.cpp b/src/Game.cpp index 30e3880..a55f265 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -20,11 +20,11 @@ Game::Game() /* Merge user configuration into the existing configuration and turn on auto refresh if it is enabled by the configuration. */ _configuration.merge(user_config_path); #ifdef __ANDROID__ - _configuration.merge(android_config_path); + _configuration.merge(configuration()("configuration", "android config path").get()); #elif defined(__EMSCRIPTEN__) - _configuration.merge(wasm_config_path); + _configuration.merge(configuration()("configuration", "wasm config path").get()); #endif - if (configuration()["configuration"]["auto-refresh"]) + if (configuration()("configuration", "auto refresh")) { _configuration.enable_auto_refresh(user_config_path); } diff --git a/src/Game.hpp b/src/Game.hpp index 6972f8d..5e2593e 100644 --- a/src/Game.hpp +++ b/src/Game.hpp @@ -65,8 +65,6 @@ private: std::shared_ptr _font; inline static const std::string user_config_path = "config.json"; - inline static const std::string android_config_path = "config_android.json"; - inline static const std::string wasm_config_path = "config_wasm.json"; /*! * Overrides SDL's default log function to log a message to stdout/stderr and, if log is enabled in the