1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

Fix highlighting of a selected bonus for campaign. (#432)

This commit is contained in:
Raphnalor
2018-03-17 07:23:22 +03:00
committed by ArseniyShestakov
parent 1e9a3e0fe4
commit 0f00dbf8cf
7 changed files with 34 additions and 8 deletions

View File

@@ -52,6 +52,23 @@ void CButton::update()
redraw();
}
void CButton::setBorderColor(boost::optional<SDL_Color> borderColor)
{
setBorderColor(borderColor, borderColor, borderColor, borderColor);
}
void CButton::setBorderColor(boost::optional<SDL_Color> normalBorderColor,
boost::optional<SDL_Color> pressedBorderColor,
boost::optional<SDL_Color> blockedBorderColor,
boost::optional<SDL_Color> highlightedBorderColor)
{
stateToBorderColor[NORMAL] = normalBorderColor;
stateToBorderColor[PRESSED] = pressedBorderColor;
stateToBorderColor[BLOCKED] = blockedBorderColor;
stateToBorderColor[HIGHLIGHTED] = highlightedBorderColor;
update();
}
void CButton::addCallback(std::function<void()> callback)
{
this->callback += callback;
@@ -273,6 +290,7 @@ void CButton::showAll(SDL_Surface * to)
{
CIntObject::showAll(to);
auto borderColor = stateToBorderColor[getState()];
if (borderColor && borderColor->a == 0)
CSDL_Ext::drawBorder(to, pos.x-1, pos.y-1, pos.w+2, pos.h+2, int3(borderColor->r, borderColor->g, borderColor->b));
}