allow multiple backgrounds

Game_title_background can be a comma separted list of backgrounds.
if multiple backgrounds are present, one of them will be chosen at random when the UI reloaded.
This commit is contained in:
Subhraman Sarkar 2024-07-16 11:19:56 +05:30
parent 43f0e05d57
commit a973fd4ab3

View file

@ -23,6 +23,7 @@
#include "serialization/string_utils.hpp"
#include <cmath>
#include <random>
static lg::log_domain log_engine("engine");
#define LOG_NG LOG_STREAM(info, log_engine)
@ -313,8 +314,19 @@ void load_config(const config &v)
if(auto i = v.optional_child("images")){
using namespace game_config::images;
if (!i["game_title_background"].blank()) {
// Select a background at random
const auto backgrounds = utils::split(i["game_title_background"].str());
if (backgrounds.size() > 1) {
int r = rand() % (backgrounds.size());
game_title_background = backgrounds.at(r);
} else if (backgrounds.size() == 1) {
game_title_background = backgrounds.at(0);
}
}
// Allow game_title to be empty
game_title = i["game_title"].str();
game_title_background = i["game_title_background"].str();
game_logo = i["game_logo"].str();
game_logo_background = i["game_logo_background"].str();