mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Extracted too big lambda into a separate helper method
This commit is contained in:
parent
20f7071d11
commit
ac6cfdfb92
@ -228,7 +228,6 @@ void CStackWindow::CWindowSection::createStackInfo(bool showExp, bool showArt)
|
||||
|
||||
//TODO: stack artifact
|
||||
|
||||
//TODO: stack experience
|
||||
if (showExp)
|
||||
{
|
||||
const CStackInstance * stack = parent->info->stackNode;
|
||||
@ -384,6 +383,29 @@ void CStackWindow::CWindowSection::createCommander()
|
||||
//TODO: commander artifacts
|
||||
}
|
||||
|
||||
CIntObject * CStackWindow::createSkillEntry(int index)
|
||||
{
|
||||
for (auto skillID : info->levelupInfo->skills)
|
||||
{
|
||||
if (index == 0 && skillID >= 100)
|
||||
{
|
||||
const Bonus *bonus = CGI->creh->skillRequirements[skillID-100].first;
|
||||
const CStackInstance *stack = info->commander;
|
||||
CClickableObject * icon = new CClickableObject(new CPicture(stack->bonusToGraphics(bonus)), []{});
|
||||
icon->callback = [=]
|
||||
{
|
||||
setSelection(skillID, icon);
|
||||
};
|
||||
icon->text = stack->bonusToString(bonus, true);
|
||||
icon->hoverText = stack->bonusToString(bonus, false);
|
||||
return icon;
|
||||
}
|
||||
if (skillID >= 100)
|
||||
index--;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CStackWindow::CWindowSection::createCommanderAbilities()
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
@ -395,27 +417,9 @@ void CStackWindow::CWindowSection::createCommanderAbilities()
|
||||
return skillID >= 100;
|
||||
});
|
||||
|
||||
auto list = new CListBox([=] (si32 index) -> CIntObject*
|
||||
auto list = new CListBox([=] (int index)
|
||||
{
|
||||
for (auto skillID : parent->info->levelupInfo->skills)
|
||||
{
|
||||
if (index == 0 && skillID >= 100)
|
||||
{
|
||||
const Bonus *bonus = CGI->creh->skillRequirements[skillID-100].first;
|
||||
const CStackInstance *stack = parent->info->commander;
|
||||
CClickableObject * icon = new CClickableObject(new CPicture(stack->bonusToGraphics(bonus)), []{});
|
||||
icon->callback = [=]
|
||||
{
|
||||
parent->setSelection(skillID, icon);
|
||||
};
|
||||
icon->text = stack->bonusToString(bonus, true);
|
||||
icon->hoverText = stack->bonusToString(bonus, false);
|
||||
return icon;
|
||||
}
|
||||
if (skillID >= 100)
|
||||
index--;
|
||||
}
|
||||
return nullptr;
|
||||
return parent->createSkillEntry(index);
|
||||
},
|
||||
[=] (CIntObject * elem)
|
||||
{
|
||||
|
@ -89,6 +89,8 @@ class CStackWindow : public CWindowObject
|
||||
|
||||
std::string generateStackExpDescription();
|
||||
|
||||
CIntObject * createSkillEntry(int index);
|
||||
|
||||
public:
|
||||
// for battles
|
||||
CStackWindow(const CStack * stack, bool popup);
|
||||
|
Loading…
Reference in New Issue
Block a user