Browse Source

Ability to use random main menu background

George King 9 months ago
parent
commit
b4f6932f36
1 changed files with 7 additions and 1 deletions
  1. 7 1
      client/mainmenu/CMainMenu.cpp

+ 7 - 1
client/mainmenu/CMainMenu.cpp

@@ -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());