From 5a78538ebf7be796b9d1fc5170e8074892912f77 Mon Sep 17 00:00:00 2001 From: George King <98261225+GeorgeK1ng@users.noreply.github.com> Date: Mon, 3 Mar 2025 17:40:11 +0100 Subject: [PATCH] Added 1.6 fallback + code cleanup --- client/lobby/CSelectionBase.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/client/lobby/CSelectionBase.cpp b/client/lobby/CSelectionBase.cpp index a5d6b7c5c..f0abf65d3 100644 --- a/client/lobby/CSelectionBase.cpp +++ b/client/lobby/CSelectionBase.cpp @@ -92,25 +92,38 @@ CSelectionBase::CSelectionBase(ESelectionScreen type) pos.h = 584; if(screenType == ESelectionScreen::campaignList) { - setBackground(ImagePath::builtin("CamCust.bmp")); + //setBackground(ImagePath::builtin("CamCust.bmp")); + + const JsonNode& gameSelectConfig = CMainMenuConfig::get().getConfig()["campaign-selection"]; + const JsonVector& bgNames = gameSelectConfig["background"].Vector(); + + setBackground(ImagePath::fromJson(*RandomGeneratorUtil::nextItem(bgNames, CRandomGenerator::getDefault()))); + pos = background->center(); } else { - const JsonNode& gameSelectConfig = CMainMenuConfig::get().getConfig()["scenario-selection"]; - const JsonVector& bgNames = gameSelectConfig["background"].Vector(); - setBackground(ImagePath::fromJson(*RandomGeneratorUtil::nextItem(bgNames, CRandomGenerator::getDefault()))); + const JsonNode& gameSelectConfig = CMainMenuConfig::get().getConfig()["scenario-selection"]; + const JsonVector* bgNames = nullptr; + + if (!gameSelectConfig.isStruct()) + bgNames = &CMainMenuConfig::get().getConfig()["game-select"].Vector(); // Fallback for 1.6 mods + else + bgNames = &gameSelectConfig["background"].Vector(); + + + setBackground(ImagePath::fromJson(*RandomGeneratorUtil::nextItem(*bgNames, CRandomGenerator::getDefault()))); pos = background->center(); // Set logo const auto& logoConfig = gameSelectConfig["logo"]; - if (!logoConfig.isNull() && logoConfig["name"].isVector() && !logoConfig["name"].Vector().empty()) + if (!logoConfig["name"].Vector().empty()) logo = std::make_shared(ImagePath::fromJson(*RandomGeneratorUtil::nextItem(logoConfig["name"].Vector(), CRandomGenerator::getDefault())), Point(logoConfig["x"].Integer(), logoConfig["y"].Integer())); - + // Set sublogo const auto& sublogoConfig = gameSelectConfig["sublogo"]; - if (!sublogoConfig.isNull() && sublogoConfig["name"].isVector() && !sublogoConfig["name"].Vector().empty()) + if (!logoConfig["name"].Vector().empty()) sublogo = std::make_shared(ImagePath::fromJson(*RandomGeneratorUtil::nextItem(sublogoConfig["name"].Vector(), CRandomGenerator::getDefault())), Point(sublogoConfig["x"].Integer(), sublogoConfig["y"].Integer())); }