|
@@ -15,6 +15,7 @@
|
|
|
|
|
|
#include "../CGameInfo.h"
|
|
|
#include "../CPlayerInterface.h"
|
|
|
+#include "../render/Canvas.h"
|
|
|
#include "../widgets/Buttons.h"
|
|
|
#include "../widgets/CArtifactHolder.h"
|
|
|
#include "../widgets/CComponent.h"
|
|
@@ -83,7 +84,6 @@ public:
|
|
|
{
|
|
|
}
|
|
|
|
|
|
-
|
|
|
std::string getName() const
|
|
|
{
|
|
|
if(commander)
|
|
@@ -95,11 +95,14 @@ private:
|
|
|
|
|
|
};
|
|
|
|
|
|
-CCommanderSkillIcon::CCommanderSkillIcon(std::shared_ptr<CIntObject> object_, std::function<void()> callback)
|
|
|
+CCommanderSkillIcon::CCommanderSkillIcon(std::shared_ptr<CIntObject> object_, bool isGrandmasterAbility_, std::function<void()> callback)
|
|
|
: object(),
|
|
|
+ isGrandmasterAbility(isGrandmasterAbility_),
|
|
|
+ isSelected(false),
|
|
|
callback(callback)
|
|
|
{
|
|
|
pos = object_->pos;
|
|
|
+ this->isGrandmasterAbility = isGrandmasterAbility_;
|
|
|
setObject(object_);
|
|
|
}
|
|
|
|
|
@@ -116,6 +119,25 @@ void CCommanderSkillIcon::setObject(std::shared_ptr<CIntObject> newObject)
|
|
|
void CCommanderSkillIcon::clickPressed(const Point & cursorPosition)
|
|
|
{
|
|
|
callback();
|
|
|
+ isSelected = true;
|
|
|
+}
|
|
|
+
|
|
|
+void CCommanderSkillIcon::deselect()
|
|
|
+{
|
|
|
+ isSelected = false;
|
|
|
+}
|
|
|
+
|
|
|
+bool CCommanderSkillIcon::getIsGrandmasterAbility()
|
|
|
+{
|
|
|
+ return isGrandmasterAbility;
|
|
|
+}
|
|
|
+
|
|
|
+void CCommanderSkillIcon::show(Canvas &to)
|
|
|
+{
|
|
|
+ CIntObject::show(to);
|
|
|
+
|
|
|
+ if(isGrandmasterAbility && isSelected)
|
|
|
+ to.drawBorder(pos, Colors::YELLOW, 2);
|
|
|
}
|
|
|
|
|
|
static ImagePath skillToFile(int skill, int level, bool selected)
|
|
@@ -375,7 +397,7 @@ CStackWindow::CommanderMainSection::CommanderMainSection(CStackWindow * owner, i
|
|
|
{
|
|
|
Point skillPos = getSkillPos(index);
|
|
|
|
|
|
- auto icon = std::make_shared<CCommanderSkillIcon>(std::make_shared<CPicture>(getSkillImage(index), skillPos.x, skillPos.y), [=]()
|
|
|
+ auto icon = std::make_shared<CCommanderSkillIcon>(std::make_shared<CPicture>(getSkillImage(index), skillPos.x, skillPos.y), false, [=]()
|
|
|
{
|
|
|
LOCPLINT->showInfoDialog(getSkillDescription(index));
|
|
|
});
|
|
@@ -429,7 +451,7 @@ CStackWindow::CommanderMainSection::CommanderMainSection(CStackWindow * owner, i
|
|
|
{
|
|
|
const auto bonus = CGI->creh->skillRequirements[skillID-100].first;
|
|
|
const CStackInstance * stack = parent->info->commander;
|
|
|
- auto icon = std::make_shared<CCommanderSkillIcon>(std::make_shared<CPicture>(stack->bonusToGraphics(bonus)), [](){});
|
|
|
+ auto icon = std::make_shared<CCommanderSkillIcon>(std::make_shared<CPicture>(stack->bonusToGraphics(bonus)), true, [](){});
|
|
|
icon->callback = [=]()
|
|
|
{
|
|
|
parent->setSelection(skillID, icon);
|
|
@@ -446,6 +468,7 @@ CStackWindow::CommanderMainSection::CommanderMainSection(CStackWindow * owner, i
|
|
|
};
|
|
|
|
|
|
abilities = std::make_shared<CListBox>(onCreate, Point(38, 3+pos.h), Point(63, 0), 6, abilitiesCount);
|
|
|
+ abilities->setRedrawParent(true);
|
|
|
|
|
|
leftBtn = std::make_shared<CButton>(Point(10, pos.h + 6), AnimationPath::builtin("hsbtns3.def"), CButton::tooltip(), [=](){ abilities->moveToPrev(); }, EShortcut::MOVE_LEFT);
|
|
|
rightBtn = std::make_shared<CButton>(Point(411, pos.h + 6), AnimationPath::builtin("hsbtns5.def"), CButton::tooltip(), [=](){ abilities->moveToNext(); }, EShortcut::MOVE_RIGHT);
|
|
@@ -896,13 +919,22 @@ void CStackWindow::setSelection(si32 newSkill, std::shared_ptr<CCommanderSkillIc
|
|
|
selectedIcon->setObject(std::make_shared<CPicture>(getSkillImage(oldSelection)));
|
|
|
|
|
|
if(selectedIcon)
|
|
|
- selectedIcon->text = getSkillDescription(oldSelection, false); //update previously selected icon's message to existing skill level
|
|
|
+ {
|
|
|
+ if(!selectedIcon->getIsGrandmasterAbility()) //unlike WoG, in VCMI grandmaster skill descriptions are taken from bonus descriptions
|
|
|
+ {
|
|
|
+ selectedIcon->text = getSkillDescription(oldSelection, false); //update previously selected icon's message to existing skill level
|
|
|
+ }
|
|
|
+ selectedIcon->deselect();
|
|
|
+ }
|
|
|
|
|
|
selectedIcon = newIcon; // update new selection
|
|
|
if(newSkill < 100)
|
|
|
{
|
|
|
newIcon->setObject(std::make_shared<CPicture>(getSkillImage(newSkill)));
|
|
|
- newIcon->text = getSkillDescription(newSkill, true); //update currently selected icon's message to show upgrade description
|
|
|
+ if(!newIcon->getIsGrandmasterAbility())
|
|
|
+ {
|
|
|
+ newIcon->text = getSkillDescription(newSkill, true); //update currently selected icon's message to show upgrade description
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|