make android and wasm config file paths configurable
This commit is contained in:
parent
8e62f9e0a2
commit
5d950387a8
|
@ -97,8 +97,10 @@ void Configuration::set_defaults()
|
||||||
{"short-name", "spacebox"}
|
{"short-name", "spacebox"}
|
||||||
};
|
};
|
||||||
config["configuration"] = {
|
config["configuration"] = {
|
||||||
{"auto-refresh", false},
|
{"auto refresh", false},
|
||||||
{"auto-refresh-interval", 5.0}
|
{"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
|
#endif
|
||||||
files_to_refresh.push_back(file_to_refresh);
|
files_to_refresh.push_back(file_to_refresh);
|
||||||
auto_refresher.frame_length(config["configuration"]["auto-refresh-interval"].get<float>());
|
auto_refresher.frame_length(config.at("configuration").at("auto refresh interval").get<float>());
|
||||||
auto_refresher.play();
|
auto_refresher.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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. */
|
/* Merge user configuration into the existing configuration and turn on auto refresh if it is enabled by the configuration. */
|
||||||
_configuration.merge(user_config_path);
|
_configuration.merge(user_config_path);
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
_configuration.merge(android_config_path);
|
_configuration.merge(configuration()("configuration", "android config path").get<std::string>());
|
||||||
#elif defined(__EMSCRIPTEN__)
|
#elif defined(__EMSCRIPTEN__)
|
||||||
_configuration.merge(wasm_config_path);
|
_configuration.merge(configuration()("configuration", "wasm config path").get<std::string>());
|
||||||
#endif
|
#endif
|
||||||
if (configuration()["configuration"]["auto-refresh"])
|
if (configuration()("configuration", "auto refresh"))
|
||||||
{
|
{
|
||||||
_configuration.enable_auto_refresh(user_config_path);
|
_configuration.enable_auto_refresh(user_config_path);
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,8 +65,6 @@ private:
|
||||||
std::shared_ptr<TTF_Font> _font;
|
std::shared_ptr<TTF_Font> _font;
|
||||||
|
|
||||||
inline static const std::string user_config_path = "config.json";
|
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
|
* Overrides SDL's default log function to log a message to stdout/stderr and, if log is enabled in the
|
||||||
|
|
Loading…
Reference in New Issue