1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

check if used in mainmenu

This commit is contained in:
Laserlicht 2024-11-11 23:52:35 +01:00
parent 44561a55db
commit 33220b2eb3

View File

@ -876,6 +876,7 @@ void SelectionTab::parseSaves(const std::unordered_set<ResourcePath> & files)
void SelectionTab::parseCampaigns(const std::unordered_set<ResourcePath> & files)
{
auto campaignSets = JsonNode(JsonPath::builtin("config/campaignSets.json"));
auto mainmenu = JsonNode(JsonPath::builtin("config/mainmenu.json"));
allItems.reserve(files.size());
for(auto & file : files)
@ -886,13 +887,21 @@ void SelectionTab::parseCampaigns(const std::unordered_set<ResourcePath> & files
info->name = info->getNameForList();
// skip campaigns organized in sets
bool foundInSet = false;
std::string foundInSet = "";
for (auto const & set : campaignSets.Struct())
for (auto const & item : set.second["items"].Vector())
if(file.getName() == ResourcePath(item["file"].String()).getName())
foundInSet = true;
if(info->campaign && !foundInSet)
foundInSet = set.first;
// set has to be used in main menu
bool setInMainmenu = false;
if(!foundInSet.empty())
for (auto const & item : mainmenu["window"]["items"].Vector())
for (auto const & button : item["buttons"].Vector())
if(boost::algorithm::contains(boost::algorithm::to_lower_copy(button["command"].String()), boost::algorithm::to_lower_copy(foundInSet)))
setInMainmenu = true;
if(info->campaign && !setInMainmenu)
allItems.push_back(info);
}
}