From 57dba9433c8fe249e55a43ba793d4620dc9386d5 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sun, 18 Dec 2022 14:34:38 +0200 Subject: [PATCH] Correctly update drag-and-drop cursor if our window gets deactivated --- client/gui/CCursorHandler.cpp | 2 ++ client/widgets/CArtifactHolder.cpp | 16 ++++++++++++++++ client/widgets/CArtifactHolder.h | 3 +++ 3 files changed, 21 insertions(+) diff --git a/client/gui/CCursorHandler.cpp b/client/gui/CCursorHandler.cpp index 43e5999ad..af33ed182 100644 --- a/client/gui/CCursorHandler.cpp +++ b/client/gui/CCursorHandler.cpp @@ -67,6 +67,8 @@ void CCursorHandler::initCursor() void CCursorHandler::changeGraphic(ECursor::ECursorTypes type, int index) { + assert(dndObject == nullptr); + if(type != this->type) { this->type = type; diff --git a/client/widgets/CArtifactHolder.cpp b/client/widgets/CArtifactHolder.cpp index 814fc3c07..78d422cc8 100644 --- a/client/widgets/CArtifactHolder.cpp +++ b/client/widgets/CArtifactHolder.cpp @@ -254,6 +254,22 @@ void CHeroArtPlace::clickRight(tribool down, bool previousState) } } +void CArtifactsOfHero::activate() +{ + if (commonInfo->src.AOH == this && commonInfo->src.art) + CCS->curh->dragAndDropCursor(make_unique("artifact", commonInfo->src.art->artType->getIconIndex())); + + CIntObject::activate(); +} + +void CArtifactsOfHero::deactivate() +{ + if (commonInfo->src.AOH == this && commonInfo->src.art) + CCS->curh->dragAndDropCursor(nullptr); + + CIntObject::deactivate(); +} + /** * Selects artifact slot so that the containing artifact looks like it's picked up. */ diff --git a/client/widgets/CArtifactHolder.h b/client/widgets/CArtifactHolder.h index 215d41d3a..36e16e547 100644 --- a/client/widgets/CArtifactHolder.h +++ b/client/widgets/CArtifactHolder.h @@ -148,6 +148,9 @@ public: void dispose(); //free resources not needed after closing windows and reset state void scrollBackpack(int dir); //dir==-1 => to left; dir==1 => to right + void activate() override; + void deactivate() override; + void safeRedraw(); void markPossibleSlots(const CArtifactInstance* art); void unmarkSlots(bool withRedraw = true); //unmarks slots in all visible AOHs