diff --git a/Mods/vcmi/Data/lobby/townBorderBigGrayedOut.png b/Mods/vcmi/Data/lobby/townBorderBigGrayedOut.png new file mode 100644 index 000000000..c7b672338 Binary files /dev/null and b/Mods/vcmi/Data/lobby/townBorderBigGrayedOut.png differ diff --git a/client/lobby/OptionsTab.cpp b/client/lobby/OptionsTab.cpp index 59f77054f..eb5353db8 100644 --- a/client/lobby/OptionsTab.cpp +++ b/client/lobby/OptionsTab.cpp @@ -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(helper.getImageName(true), helper.getImageIndex(true), 0, x * (ICON_BIG_WIDTH-1), y * (ICON_BIG_HEIGHT-1))); - components.push_back(std::make_shared(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(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) diff --git a/client/lobby/OptionsTab.h b/client/lobby/OptionsTab.h index f9a5a6778..2d5cc43d6 100644 --- a/client/lobby/OptionsTab.h +++ b/client/lobby/OptionsTab.h @@ -114,6 +114,7 @@ private: std::vector factions; std::vector heroes; + std::vector unusableHeroes; FactionID initialFaction; HeroTypeID initialHero;