1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-29 21:56:54 +02:00

Replaced isMouseButtonPressed with isMouseLeftButtonPressed

This commit is contained in:
Ivan Savenko 2023-06-13 19:27:43 +03:00
parent 82288996a2
commit 8ad577255f
7 changed files with 13 additions and 13 deletions

View File

@ -164,7 +164,7 @@ void CMinimap::hover(bool on)
void CMinimap::mouseMoved(const Point & cursorPosition) void CMinimap::mouseMoved(const Point & cursorPosition)
{ {
if(isMouseButtonPressed(MouseButton::LEFT)) if(isMouseLeftButtonPressed())
moveAdvMapSelection(cursorPosition); moveAdvMapSelection(cursorPosition);
} }

View File

@ -692,7 +692,7 @@ std::optional<uint32_t> StackQueue::getHoveredUnitIdIfAny() const
{ {
for(const auto & stackBox : stackBoxes) for(const auto & stackBox : stackBoxes)
{ {
if(stackBox->isHovered() || stackBox->isMouseButtonPressed(MouseButton::RIGHT)) if(stackBox->isHovered())
{ {
return stackBox->getBoundUnitID(); return stackBox->getBoundUnitID();
} }

View File

@ -175,15 +175,15 @@ void EventDispatcher::handleLeftButtonClick(bool isPressed)
if(!vstd::contains(lclickable, i)) if(!vstd::contains(lclickable, i))
continue; continue;
auto prev = i->isMouseButtonPressed(MouseButton::LEFT); auto prev = i->isMouseLeftButtonPressed();
if(!isPressed) if(!isPressed)
i->currentMouseState[MouseButton::LEFT] = isPressed; i->mouseClickedState = isPressed;
if( i->receiveEvent(GH.getCursorPosition(), AEventsReceiver::LCLICK)) if( i->receiveEvent(GH.getCursorPosition(), AEventsReceiver::LCLICK))
{ {
if(isPressed) if(isPressed)
i->currentMouseState[MouseButton::LEFT] = isPressed; i->mouseClickedState = isPressed;
i->clickLeft(isPressed, prev); i->clickLeft(isPressed, prev);
} }
else if(!isPressed) else if(!isPressed)

View File

@ -18,6 +18,7 @@ AEventsReceiver::AEventsReceiver()
: activeState(0) : activeState(0)
, hoveredState(false) , hoveredState(false)
, panningState(false) , panningState(false)
, mouseClickedState(false)
{ {
} }
@ -36,9 +37,9 @@ bool AEventsReceiver::isActive() const
return activeState; return activeState;
} }
bool AEventsReceiver::isMouseButtonPressed(MouseButton btn) const bool AEventsReceiver::isMouseLeftButtonPressed() const
{ {
return currentMouseState.count(btn) ? currentMouseState.at(btn) : false; return mouseClickedState;
} }
void AEventsReceiver::activateEvents(ui16 what) void AEventsReceiver::activateEvents(ui16 what)

View File

@ -14,7 +14,6 @@ class Point;
VCMI_LIB_NAMESPACE_END VCMI_LIB_NAMESPACE_END
class EventDispatcher; class EventDispatcher;
enum class MouseButton;
enum class EShortcut; enum class EShortcut;
using boost::logic::tribool; using boost::logic::tribool;
@ -24,10 +23,10 @@ class AEventsReceiver
{ {
friend class EventDispatcher; friend class EventDispatcher;
std::map<MouseButton, bool> currentMouseState;
ui16 activeState; ui16 activeState;
bool hoveredState; bool hoveredState;
bool panningState; bool panningState;
bool mouseClickedState;
protected: protected:
/// Activates particular events for this UI element. Uses unnamed enum from this class /// Activates particular events for this UI element. Uses unnamed enum from this class
@ -82,6 +81,6 @@ public:
/// Returns true if element is currently active and may receive events /// Returns true if element is currently active and may receive events
bool isActive() const; bool isActive() const;
/// Returns true if particular mouse button was pressed when inside this element /// Returns true if left mouse button was pressed when inside this element
bool isMouseButtonPressed(MouseButton btn) const; bool isMouseLeftButtonPressed() const;
}; };

View File

@ -474,7 +474,7 @@ void TemplatesDropBox::clickLeft(tribool down, bool previousState)
auto w = widget<CSlider>("slider"); auto w = widget<CSlider>("slider");
// pop the interface only if the mouse is not clicking on the slider // pop the interface only if the mouse is not clicking on the slider
if (!w || !w->isMouseButtonPressed(MouseButton::LEFT)) if (!w || !w->isMouseLeftButtonPressed())
{ {
assert(GH.windows().isTopWindow(this)); assert(GH.windows().isTopWindow(this));
GH.windows().popWindows(1); GH.windows().popWindows(1);

View File

@ -142,7 +142,7 @@ void CSlider::clickLeft(tribool down, bool previousState)
return; return;
// if (rw>1) return; // if (rw>1) return;
// if (rw<0) return; // if (rw<0) return;
slider->clickLeft(true, slider->isMouseButtonPressed(MouseButton::LEFT)); slider->clickLeft(true, slider->isMouseLeftButtonPressed());
scrollTo((int)(rw * positions + 0.5)); scrollTo((int)(rw * positions + 0.5));
return; return;
} }