1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-03 13:01:33 +02:00

disable unavailable heroes

This commit is contained in:
Michael 2023-08-29 00:14:49 +02:00 committed by GitHub
parent 695a51d8c8
commit 44ece25042
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 B

View File

@ -612,6 +612,12 @@ OptionsTab::SelectionWindow::SelectionWindow(PlayerColor _color, SelType _type)
if(allowedHeroesFlag[i])
allowedHeroes.insert(HeroTypeID(i));
for(auto & player : SEL->getStartInfo()->playerInfos)
{
if(player.first != color && (int)player.second.hero > PlayerSettings::RANDOM)
unusableHeroes.push_back(player.second.hero);
}
allowedBonus.push_back(-1); // random
if(initialHero.getNum() >= -1)
allowedBonus.push_back(0); // artifact
@ -795,8 +801,13 @@ void OptionsTab::SelectionWindow::genContentHeroes()
CPlayerSettingsHelper helper = CPlayerSettingsHelper(set, SelType::HERO);
components.push_back(std::make_shared<CAnimImage>(helper.getImageName(true), helper.getImageIndex(true), 0, x * (ICON_BIG_WIDTH-1), y * (ICON_BIG_HEIGHT-1)));
components.push_back(std::make_shared<CPicture>(selectedHero == elem ? "lobby/townBorderBigActivated" : "lobby/townBorderBig", x * (ICON_BIG_WIDTH-1), y * (ICON_BIG_HEIGHT-1)));
drawOutlinedText(x * (ICON_BIG_WIDTH-1) + TEXT_POS_X, y * (ICON_BIG_HEIGHT-1) + TEXT_POS_Y, (selectedHero == elem) ? Colors::YELLOW : Colors::WHITE, helper.getName());
std::string image = "lobby/townBorderBig";
if(selectedHero == elem)
image = "lobby/townBorderBigActivated";
if(std::find(unusableHeroes.begin(), unusableHeroes.end(), elem) != unusableHeroes.end())
image = "lobby/townBorderBigGrayedOut";
components.push_back(std::make_shared<CPicture>(image, x * (ICON_BIG_WIDTH-1), y * (ICON_BIG_HEIGHT-1)));
heroes.push_back(elem);
i++;
@ -876,6 +887,10 @@ void OptionsTab::SelectionWindow::setElement(int elem, bool doApply)
{
set.hero = PlayerSettings::RANDOM;
}
if(doApply && std::find(unusableHeroes.begin(), unusableHeroes.end(), heroes[elem]) != unusableHeroes.end())
return;
if(set.hero.getNum() != PlayerSettings::NONE)
{
if(!doApply)

View File

@ -114,6 +114,7 @@ private:
std::vector<FactionID> factions;
std::vector<HeroTypeID> heroes;
std::vector<HeroTypeID> unusableHeroes;
FactionID initialFaction;
HeroTypeID initialHero;