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:
parent
695a51d8c8
commit
44ece25042
BIN
Mods/vcmi/Data/lobby/townBorderBigGrayedOut.png
Normal file
BIN
Mods/vcmi/Data/lobby/townBorderBigGrayedOut.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 604 B |
@ -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)
|
||||
|
@ -114,6 +114,7 @@ private:
|
||||
|
||||
std::vector<FactionID> factions;
|
||||
std::vector<HeroTypeID> heroes;
|
||||
std::vector<HeroTypeID> unusableHeroes;
|
||||
|
||||
FactionID initialFaction;
|
||||
HeroTypeID initialHero;
|
||||
|
Loading…
x
Reference in New Issue
Block a user