mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-30 08:57:00 +02:00
selectable fix
This commit is contained in:
parent
989394de53
commit
1a8a14a56d
@ -428,8 +428,13 @@ QuickSpellPanel::QuickSpellPanel(std::shared_ptr<CButton> initWidget)
|
||||
background = std::make_shared<CFilledTexture>(ImagePath::builtin("DIBOXBCK"), pos);
|
||||
rect = std::make_shared<TransparentFilledRectangle>(Rect(0, 0, pos.w + 1, pos.h + 1), ColorRGBA(0, 0, 0, 0), ColorRGBA(241, 216, 120, 255));
|
||||
|
||||
panelSelect = std::make_shared<QuickSpellPanelSelect>();
|
||||
panelSelect = std::make_shared<QuickSpellPanelSelect>(this);
|
||||
|
||||
create();
|
||||
}
|
||||
|
||||
void QuickSpellPanel::create()
|
||||
{
|
||||
for(int i = 0; i < 10; i++) {
|
||||
SpellID id = 14;
|
||||
auto button = std::make_shared<CButton>(Point(2, 1 + 37 * i), AnimationPath::builtin("spellint"), CButton::tooltip(), [&](){ std::cout << "test"; });
|
||||
@ -457,7 +462,7 @@ void QuickSpellPanel::show(Canvas & to)
|
||||
|
||||
void QuickSpellPanel::clickReleased(const Point & cursorPosition)
|
||||
{
|
||||
if(!pos.isInside(cursorPosition) && (!panelSelect->isActive() || !panelSelect->pos.isInside(cursorPosition)))
|
||||
if(!pos.isInside(cursorPosition) && (!(panelSelect->isActive() || panelSelect->wasEnabled) || !panelSelect->pos.isInside(cursorPosition)))
|
||||
close();
|
||||
|
||||
if(initWidget->pos.isInside(cursorPosition))
|
||||
@ -469,7 +474,7 @@ void QuickSpellPanel::clickReleased(const Point & cursorPosition)
|
||||
|
||||
void QuickSpellPanel::showPopupWindow(const Point & cursorPosition)
|
||||
{
|
||||
if(!pos.isInside(cursorPosition) && (!panelSelect->isActive() || !panelSelect->pos.isInside(cursorPosition)))
|
||||
if(!pos.isInside(cursorPosition) && (!(panelSelect->isActive() || panelSelect->wasEnabled) || !panelSelect->pos.isInside(cursorPosition)))
|
||||
close();
|
||||
|
||||
if(initWidget->pos.isInside(cursorPosition))
|
||||
@ -484,9 +489,12 @@ void QuickSpellPanel::mouseMoved(const Point & cursorPosition, const Point & las
|
||||
cursorPosition.x >= initWidget->pos.x + initWidget->pos.w + 20 ||
|
||||
cursorPosition.y <= initWidget->pos.y - pos.h - 20 ||
|
||||
(cursorPosition.y >= initWidget->pos.y && !initWidget->pos.isInside(cursorPosition))) &&
|
||||
(!panelSelect->isActive() || !panelSelect->pos.resize(20).isInside(cursorPosition))
|
||||
(!(panelSelect->isActive() || panelSelect->wasEnabled) || !panelSelect->pos.resize(20).isInside(cursorPosition))
|
||||
)
|
||||
close();
|
||||
|
||||
if(initWidget->pos.isInside(cursorPosition))
|
||||
panelSelect->wasEnabled = false;
|
||||
}
|
||||
|
||||
bool QuickSpellPanel::receiveEvent(const Point & position, int eventType) const
|
||||
@ -494,7 +502,8 @@ bool QuickSpellPanel::receiveEvent(const Point & position, int eventType) const
|
||||
return true; // capture click also outside of window
|
||||
}
|
||||
|
||||
QuickSpellPanelSelect::QuickSpellPanelSelect()
|
||||
QuickSpellPanelSelect::QuickSpellPanelSelect(QuickSpellPanel * Parent)
|
||||
: parent(Parent), wasEnabled(false)
|
||||
{
|
||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||
|
||||
@ -516,7 +525,12 @@ QuickSpellPanelSelect::QuickSpellPanelSelect()
|
||||
{
|
||||
int y = i % 10;
|
||||
int x = i / 10;
|
||||
auto button = std::make_shared<CButton>(Point(2 + 50 * x, 1 + 37 * y), AnimationPath::builtin("spellint"), CButton::tooltip(), [&](){ std::cout << "test"; });
|
||||
auto button = std::make_shared<CButton>(Point(2 + 50 * x, 1 + 37 * y), AnimationPath::builtin("spellint"), CButton::tooltip(), [this](){
|
||||
setEnabled(false);
|
||||
GH.windows().totalRedraw();
|
||||
wasEnabled = true;
|
||||
parent->create();
|
||||
});
|
||||
button->setOverlay(std::make_shared<CAnimImage>(AnimationPath::builtin("spellint"), spellList[i]->getId().num + 1));
|
||||
buttons.push_back(button);
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ class TransparentFilledRectangle;
|
||||
class CPlayerInterface;
|
||||
class BattleRenderer;
|
||||
class VideoWidget;
|
||||
class QuickSpellPanel;
|
||||
|
||||
/// Class which shows the console at the bottom of the battle screen and manages the text of the console
|
||||
class BattleConsole : public CIntObject, public IStatusBar
|
||||
@ -153,9 +154,10 @@ private:
|
||||
std::shared_ptr<CFilledTexture> background;
|
||||
std::shared_ptr<TransparentFilledRectangle> rect;
|
||||
std::vector<std::shared_ptr<CButton>> buttons;
|
||||
|
||||
QuickSpellPanel * parent;
|
||||
public:
|
||||
QuickSpellPanelSelect();
|
||||
QuickSpellPanelSelect(QuickSpellPanel * Parent);
|
||||
bool wasEnabled; // was the panel opened? -> don't close window because mouse is not in area
|
||||
};
|
||||
|
||||
class QuickSpellPanel : public CWindowObject
|
||||
@ -178,6 +180,8 @@ private:
|
||||
public:
|
||||
QuickSpellPanel(std::shared_ptr<CButton> initWidget);
|
||||
|
||||
void create();
|
||||
|
||||
void show(Canvas & to) override;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user