diff --git a/client/windows/CCreatureWindow.cpp b/client/windows/CCreatureWindow.cpp index 1dc950fec..956a7ea99 100644 --- a/client/windows/CCreatureWindow.cpp +++ b/client/windows/CCreatureWindow.cpp @@ -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" @@ -84,7 +85,6 @@ public: { } - std::string getName() const { if(commander) @@ -96,11 +96,14 @@ private: }; -CCommanderSkillIcon::CCommanderSkillIcon(std::shared_ptr object_, std::function callback) +CCommanderSkillIcon::CCommanderSkillIcon(std::shared_ptr object_, bool isGrandmasterAbility_, std::function callback) : object(), + isGrandmasterAbility(isGrandmasterAbility_), + isSelected(false), callback(callback) { pos = object_->pos; + this->isGrandmasterAbility = isGrandmasterAbility_; setObject(object_); } @@ -117,6 +120,20 @@ void CCommanderSkillIcon::setObject(std::shared_ptr newObject) void CCommanderSkillIcon::clickPressed(const Point & cursorPosition) { callback(); + isSelected = true; +} + +void CCommanderSkillIcon::deselect() +{ + isSelected = false; +} + +void CCommanderSkillIcon::show(Canvas &to) +{ + CIntObject::show(to); + + if(isGrandmasterAbility && isSelected) + to.drawBorder(pos, Colors::YELLOW, 2); } static std::string skillToFile(int skill, int level, bool selected) @@ -376,7 +393,7 @@ CStackWindow::CommanderMainSection::CommanderMainSection(CStackWindow * owner, i { Point skillPos = getSkillPos(index); - auto icon = std::make_shared(std::make_shared(getSkillImage(index), skillPos.x, skillPos.y), [=]() + auto icon = std::make_shared(std::make_shared(getSkillImage(index), skillPos.x, skillPos.y), false, [=]() { LOCPLINT->showInfoDialog(getSkillDescription(index)); }); @@ -430,7 +447,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(std::make_shared(stack->bonusToGraphics(bonus)), [](){}); + auto icon = std::make_shared(std::make_shared(stack->bonusToGraphics(bonus)), true, [](){}); icon->callback = [=]() { parent->setSelection(skillID, icon); @@ -897,7 +914,10 @@ void CStackWindow::setSelection(si32 newSkill, std::shared_ptrsetObject(std::make_shared(getSkillImage(oldSelection))); if(selectedIcon) + { 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) diff --git a/client/windows/CCreatureWindow.h b/client/windows/CCreatureWindow.h index 0ffe83a88..2a82d4f0a 100644 --- a/client/windows/CCreatureWindow.h +++ b/client/windows/CCreatureWindow.h @@ -32,14 +32,19 @@ class CCommanderArtPlace; class CCommanderSkillIcon : public LRClickableAreaWText //TODO: maybe bring commander skill button initialization logic inside? { std::shared_ptr object; // passive object that will be used to determine clickable area + bool isGrandmasterAbility; // refers to WoG abilities obtainable via combining grandmaster skills (for example attack + speed unlocks shoot) + bool isSelected; // used only for programatically created border around selected "grandmaster abilities" public: - CCommanderSkillIcon(std::shared_ptr object_, std::function callback); + CCommanderSkillIcon(std::shared_ptr object_, bool isGrandmasterAbility, std::function callback); std::function callback; void clickPressed(const Point & cursorPosition) override; void setObject(std::shared_ptr object); + void deselect(); //TODO: consider using observer pattern instead? + + void show(Canvas &to) override; }; class CStackWindow : public CWindowObject