1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-25 21:38:59 +02:00

Merge pull request #5216 from GeorgeK1ng/random_menu_background

Ability to use random main menu background
This commit is contained in:
Ivan Savenko 2025-01-06 21:52:58 +02:00 committed by GitHub
commit 08b513a7cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -76,7 +76,13 @@ CMenuScreen::CMenuScreen(const JsonNode & configNode)
{
OBJECT_CONSTRUCTION;
background = std::make_shared<CPicture>(ImagePath::fromJson(config["background"]));
const auto& bgConfig = config["background"];
if (bgConfig.isVector() && !bgConfig.Vector().empty())
background = std::make_shared<CPicture>(ImagePath::fromJson(*RandomGeneratorUtil::nextItem(bgConfig.Vector(), CRandomGenerator::getDefault())));
if (bgConfig.isString())
background = std::make_shared<CPicture>(ImagePath::fromJson(bgConfig));
if(config["scalable"].Bool())
background->scaleTo(GH.screenDimensions());