mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-11 11:31:52 +02:00
calculate size
This commit is contained in:
parent
18b963f376
commit
b73f9d6e30
@ -424,11 +424,6 @@ OptionsTab::SelectionWindow::SelectionWindow(PlayerColor _color)
|
||||
|
||||
color = _color;
|
||||
|
||||
pos = Rect(0, 0, (ELEMENTS_PER_LINE * 2 + 5) * 58, 700);
|
||||
|
||||
backgroundTexture = std::make_shared<CFilledTexture>("DIBOXBCK", pos);
|
||||
updateShadow();
|
||||
|
||||
initialFraction = SEL->getStartInfo()->playerInfos.find(color)->second.castle;
|
||||
initialHero = SEL->getStartInfo()->playerInfos.find(color)->second.hero;
|
||||
initialBonus = SEL->getStartInfo()->playerInfos.find(color)->second.bonus;
|
||||
@ -436,13 +431,43 @@ OptionsTab::SelectionWindow::SelectionWindow(PlayerColor _color)
|
||||
selectedHero = initialHero;
|
||||
selectedBonus = initialBonus;
|
||||
allowedFactions = SEL->getPlayerInfo(color.getNum()).allowedFactions;
|
||||
allowedHeroes = SEL->getMapInfo()->mapHeader->allowedHeroes;
|
||||
std::vector<bool> allowedHeroesFlag = SEL->getMapInfo()->mapHeader->allowedHeroes;
|
||||
for(int i = 0; i < allowedHeroesFlag.size(); i++)
|
||||
if(allowedHeroesFlag[i])
|
||||
allowedHeroes.insert(HeroTypeID(i));
|
||||
|
||||
pos = Rect(0, 0, (ELEMENTS_PER_LINE * 2 + 5) * 58, calcHeight());
|
||||
|
||||
backgroundTexture = std::make_shared<CFilledTexture>("DIBOXBCK", pos);
|
||||
updateShadow();
|
||||
|
||||
recreate();
|
||||
|
||||
center();
|
||||
}
|
||||
|
||||
int OptionsTab::SelectionWindow::calcHeight()
|
||||
{
|
||||
// size count
|
||||
int max = 0;
|
||||
for(auto & elemf : allowedHeroes)
|
||||
{
|
||||
int count = 0;
|
||||
for(auto & elemh : allowedHeroes)
|
||||
{
|
||||
CHero * type = VLC->heroh->objects[elemh];
|
||||
if(type->heroClass->faction == elemf)
|
||||
count++;
|
||||
}
|
||||
max = std::max(max, count);
|
||||
}
|
||||
max = std::max(max, (int)allowedFactions.size());
|
||||
|
||||
int y = max / ELEMENTS_PER_LINE + 3;
|
||||
|
||||
return y * 64;
|
||||
}
|
||||
|
||||
void OptionsTab::SelectionWindow::apply()
|
||||
{
|
||||
if(GH.windows().isTopWindow(this))
|
||||
@ -555,13 +580,6 @@ void OptionsTab::SelectionWindow::genContentHeroes()
|
||||
CPlayerSettingsHelper helper = CPlayerSettingsHelper(set, SelType::HERO);
|
||||
components.push_back(std::make_shared<CAnimImage>(helper.getImageName(), helper.getImageIndex(), 0, (ELEMENTS_PER_LINE / 2) * 58 + (ELEMENTS_PER_LINE + 1) * 58 + 34, 32 / 2 + 64));
|
||||
|
||||
std::vector<bool> allowedHeroesFlag = allowedHeroes;
|
||||
|
||||
std::set<HeroTypeID> allowedHeroes;
|
||||
for(int i = 0; i < allowedHeroesFlag.size(); i++)
|
||||
if(allowedHeroesFlag[i])
|
||||
allowedHeroes.insert(HeroTypeID(i));
|
||||
|
||||
int i = 0;
|
||||
for(auto & elem : allowedHeroes)
|
||||
{
|
||||
|
@ -115,7 +115,7 @@ public:
|
||||
int selectedBonus;
|
||||
|
||||
std::set<FactionID> allowedFactions;
|
||||
std::vector<bool> allowedHeroes;
|
||||
std::set<HeroTypeID> allowedHeroes;
|
||||
std::vector<bool> allowedBonus;
|
||||
|
||||
void genContentTitle();
|
||||
@ -123,6 +123,7 @@ public:
|
||||
void genContentHeroes();
|
||||
void genContentBonus();
|
||||
|
||||
int calcHeight();
|
||||
void apply();
|
||||
void recreate();
|
||||
void setSelection();
|
||||
|
Loading…
x
Reference in New Issue
Block a user