From f9db3d131ffcb4ce7d90f34247949c9ebe1935fb Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Tue, 10 Oct 2023 23:51:05 +0200 Subject: [PATCH] lastActivated with overload --- client/adventureMap/CInfoBar.cpp | 7 +++++-- client/adventureMap/CInfoBar.h | 2 +- client/gui/EventDispatcher.cpp | 9 ++++++++- client/gui/EventsReceiver.h | 2 ++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/client/adventureMap/CInfoBar.cpp b/client/adventureMap/CInfoBar.cpp index 7b0f7628f..360dd4946 100644 --- a/client/adventureMap/CInfoBar.cpp +++ b/client/adventureMap/CInfoBar.cpp @@ -289,13 +289,16 @@ void CInfoBar::tick(uint32_t msPassed) } } -void CInfoBar::clickReleased(const Point & cursorPosition) +void CInfoBar::clickReleased(const Point & cursorPosition, bool lastActivated) { timerCounter = 0; removeUsedEvents(TIME); //expiration trigger from just clicked element is not valid anymore if(state == HERO || state == TOWN) - showGameStatus(); + { + if(lastActivated) + showGameStatus(); + } else if(state == GAME) showDate(); else diff --git a/client/adventureMap/CInfoBar.h b/client/adventureMap/CInfoBar.h index 8dc8c88cb..5800377b7 100644 --- a/client/adventureMap/CInfoBar.h +++ b/client/adventureMap/CInfoBar.h @@ -159,7 +159,7 @@ private: void tick(uint32_t msPassed) override; - void clickReleased(const Point & cursorPosition) override; + void clickReleased(const Point & cursorPosition, bool lastActivated) override; void showPopupWindow(const Point & cursorPosition) override; void hover(bool on) override; diff --git a/client/gui/EventDispatcher.cpp b/client/gui/EventDispatcher.cpp index 08e4c6b44..721954848 100644 --- a/client/gui/EventDispatcher.cpp +++ b/client/gui/EventDispatcher.cpp @@ -203,6 +203,7 @@ void EventDispatcher::handleLeftButtonClick(const Point & position, int toleranc // POSSIBLE SOLUTION: make EventReceivers inherit from create_shared_from this and store weak_ptr's in lists AEventsReceiver * nearestElement = findElementInToleranceRange(lclickable, position, AEventsReceiver::LCLICK, tolerance); auto hlp = lclickable; + bool lastActivated = true; for(auto & i : hlp) { @@ -212,13 +213,19 @@ void EventDispatcher::handleLeftButtonClick(const Point & position, int toleranc if( i->receiveEvent(position, AEventsReceiver::LCLICK) || i == nearestElement) { if(isPressed) + { i->clickPressed(position); + i->clickPressed(position, lastActivated); + } if (i->mouseClickedState && !isPressed) + { i->clickReleased(position); + i->clickReleased(position, lastActivated); + } i->mouseClickedState = isPressed; - return; + lastActivated = false; } else { diff --git a/client/gui/EventsReceiver.h b/client/gui/EventsReceiver.h index 2206c70bf..690c9b9a8 100644 --- a/client/gui/EventsReceiver.h +++ b/client/gui/EventsReceiver.h @@ -45,6 +45,8 @@ protected: public: virtual void clickPressed(const Point & cursorPosition) {} virtual void clickReleased(const Point & cursorPosition) {} + virtual void clickPressed(const Point & cursorPosition, bool lastActivated) {} + virtual void clickReleased(const Point & cursorPosition, bool lastActivated) {} virtual void clickCancel(const Point & cursorPosition) {} virtual void showPopupWindow(const Point & cursorPosition) {} virtual void clickDouble(const Point & cursorPosition) {}