mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-07 00:58:39 +02:00
Added 1.6 fallback + code cleanup
This commit is contained in:
@ -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<CPicture>(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<CPicture>(ImagePath::fromJson(*RandomGeneratorUtil::nextItem(sublogoConfig["name"].Vector(), CRandomGenerator::getDefault())), Point(sublogoConfig["x"].Integer(), sublogoConfig["y"].Integer()));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user