mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-23 21:29:13 +02:00
Split mouseDragged event from mouseMoved
This commit is contained in:
parent
0cd19b0a9f
commit
4e7412faa6
@ -88,7 +88,7 @@ void CMinimapInstance::showAll(Canvas & to)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CMinimap::CMinimap(const Rect & position)
|
CMinimap::CMinimap(const Rect & position)
|
||||||
: CIntObject(LCLICK | SHOW_POPUP | HOVER | MOVE | GESTURE, position.topLeft()),
|
: CIntObject(LCLICK | SHOW_POPUP | DRAG | MOVE | GESTURE, position.topLeft()),
|
||||||
level(0)
|
level(0)
|
||||||
{
|
{
|
||||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||||
@ -162,9 +162,8 @@ void CMinimap::hover(bool on)
|
|||||||
GH.statusbar()->clear();
|
GH.statusbar()->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMinimap::mouseMoved(const Point & cursorPosition)
|
void CMinimap::mouseDragged(const Point & cursorPosition, const Point & lastUpdateDistance)
|
||||||
{
|
{
|
||||||
if(isMouseLeftButtonPressed())
|
|
||||||
moveAdvMapSelection(cursorPosition);
|
moveAdvMapSelection(cursorPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ class CMinimap : public CIntObject
|
|||||||
void clickLeft(tribool down, bool previousState) override;
|
void clickLeft(tribool down, bool previousState) override;
|
||||||
void showPopupWindow() override;
|
void showPopupWindow() override;
|
||||||
void hover(bool on) override;
|
void hover(bool on) override;
|
||||||
void mouseMoved (const Point & cursorPosition) override;
|
void mouseDragged(const Point & cursorPosition, const Point & lastUpdateDistance) override;
|
||||||
|
|
||||||
/// relocates center of adventure map screen to currently hovered tile
|
/// relocates center of adventure map screen to currently hovered tile
|
||||||
void moveAdvMapSelection(const Point & positionGlobal);
|
void moveAdvMapSelection(const Point & positionGlobal);
|
||||||
|
@ -197,7 +197,7 @@ void BattleFieldController::gesturePanning(const Point & initialPosition, const
|
|||||||
owner.actionsController->onHexHovered(getHoveredHex());
|
owner.actionsController->onHexHovered(getHoveredHex());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattleFieldController::mouseMoved(const Point & cursorPosition)
|
void BattleFieldController::mouseMoved(const Point & cursorPosition, const Point & lastUpdateDistance)
|
||||||
{
|
{
|
||||||
hoveredHex = getHexAtPosition(cursorPosition);
|
hoveredHex = getHexAtPosition(cursorPosition);
|
||||||
currentAttackOriginPoint = cursorPosition;
|
currentAttackOriginPoint = cursorPosition;
|
||||||
|
@ -90,7 +90,7 @@ class BattleFieldController : public CIntObject
|
|||||||
|
|
||||||
void gesture(bool on, const Point & initialPosition, const Point & finalPosition) override;
|
void gesture(bool on, const Point & initialPosition, const Point & finalPosition) override;
|
||||||
void gesturePanning(const Point & initialPosition, const Point & currentPosition, const Point & lastUpdateDistance) override;
|
void gesturePanning(const Point & initialPosition, const Point & currentPosition, const Point & lastUpdateDistance) override;
|
||||||
void mouseMoved(const Point & cursorPosition) override;
|
void mouseMoved(const Point & cursorPosition, const Point & lastUpdateDistance) override;
|
||||||
void clickLeft(tribool down, bool previousState) override;
|
void clickLeft(tribool down, bool previousState) override;
|
||||||
void showPopupWindow() override;
|
void showPopupWindow() override;
|
||||||
void activate() override;
|
void activate() override;
|
||||||
|
@ -75,7 +75,7 @@ void InputHandler::handleCurrentEvent(const SDL_Event & current)
|
|||||||
void InputHandler::processEvents()
|
void InputHandler::processEvents()
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> lock(eventsMutex);
|
boost::unique_lock<boost::mutex> lock(eventsMutex);
|
||||||
for (auto const & currentEvent : eventsQueue)
|
for(const auto & currentEvent : eventsQueue)
|
||||||
handleCurrentEvent(currentEvent);
|
handleCurrentEvent(currentEvent);
|
||||||
|
|
||||||
eventsQueue.clear();
|
eventsQueue.clear();
|
||||||
@ -87,7 +87,7 @@ bool InputHandler::ignoreEventsUntilInput()
|
|||||||
bool inputFound = false;
|
bool inputFound = false;
|
||||||
|
|
||||||
boost::unique_lock<boost::mutex> lock(eventsMutex);
|
boost::unique_lock<boost::mutex> lock(eventsMutex);
|
||||||
for (auto const & event : eventsQueue)
|
for(const auto & event : eventsQueue)
|
||||||
{
|
{
|
||||||
switch(event.type)
|
switch(event.type)
|
||||||
{
|
{
|
||||||
@ -226,7 +226,7 @@ void InputHandler::moveCursorPosition(const Point & distance)
|
|||||||
void InputHandler::setCursorPosition(const Point & position)
|
void InputHandler::setCursorPosition(const Point & position)
|
||||||
{
|
{
|
||||||
cursorPosition = position;
|
cursorPosition = position;
|
||||||
GH.events().dispatchMouseMoved(position);
|
GH.events().dispatchMouseMoved(Point(0, 0), position);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputHandler::startTextInput(const Rect & where)
|
void InputHandler::startTextInput(const Rect & where)
|
||||||
|
@ -26,6 +26,8 @@ void InputSourceMouse::handleEventMouseMotion(const SDL_MouseMotionEvent & motio
|
|||||||
|
|
||||||
if (mouseButtonsMask & SDL_BUTTON(SDL_BUTTON_MIDDLE))
|
if (mouseButtonsMask & SDL_BUTTON(SDL_BUTTON_MIDDLE))
|
||||||
GH.events().dispatchGesturePanning(middleClickPosition, newPosition, distance);
|
GH.events().dispatchGesturePanning(middleClickPosition, newPosition, distance);
|
||||||
|
else if (mouseButtonsMask & SDL_BUTTON(SDL_BUTTON_LEFT))
|
||||||
|
GH.events().dispatchMouseDragged(newPosition, distance);
|
||||||
else
|
else
|
||||||
GH.input().setCursorPosition(newPosition);
|
GH.input().setCursorPosition(newPosition);
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ void UserEventHandler::handleUserEvent(const SDL_UserEvent & user)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EUserEvent::FAKE_MOUSE_MOVE:
|
case EUserEvent::FAKE_MOUSE_MOVE:
|
||||||
GH.events().dispatchMouseMoved(GH.getCursorPosition());
|
GH.events().dispatchMouseMoved(Point(0, 0), GH.getCursorPosition());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logGlobal->error("Unknown user event. Code %d", user.code);
|
logGlobal->error("Unknown user event. Code %d", user.code);
|
||||||
|
@ -31,6 +31,7 @@ void EventDispatcher::processLists(ui16 activityFlag, const Functor & cb)
|
|||||||
processList(AEventsReceiver::SHOW_POPUP, rclickable);
|
processList(AEventsReceiver::SHOW_POPUP, rclickable);
|
||||||
processList(AEventsReceiver::HOVER, hoverable);
|
processList(AEventsReceiver::HOVER, hoverable);
|
||||||
processList(AEventsReceiver::MOVE, motioninterested);
|
processList(AEventsReceiver::MOVE, motioninterested);
|
||||||
|
processList(AEventsReceiver::DRAG, draginterested);
|
||||||
processList(AEventsReceiver::KEYBOARD, keyinterested);
|
processList(AEventsReceiver::KEYBOARD, keyinterested);
|
||||||
processList(AEventsReceiver::TIME, timeinterested);
|
processList(AEventsReceiver::TIME, timeinterested);
|
||||||
processList(AEventsReceiver::WHEEL, wheelInterested);
|
processList(AEventsReceiver::WHEEL, wheelInterested);
|
||||||
@ -63,7 +64,7 @@ void EventDispatcher::dispatchTimer(uint32_t msPassed)
|
|||||||
for (auto & elem : hlp)
|
for (auto & elem : hlp)
|
||||||
{
|
{
|
||||||
if(!vstd::contains(timeinterested,elem)) continue;
|
if(!vstd::contains(timeinterested,elem)) continue;
|
||||||
(elem)->tick(msPassed);
|
elem->tick(msPassed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,7 +271,7 @@ void EventDispatcher::dispatchGesturePinch(const Point & initialPosition, double
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventDispatcher::dispatchMouseMoved(const Point & position)
|
void EventDispatcher::dispatchMouseMoved(const Point & distance, const Point & position)
|
||||||
{
|
{
|
||||||
EventReceiversList newlyHovered;
|
EventReceiversList newlyHovered;
|
||||||
|
|
||||||
@ -288,8 +289,8 @@ void EventDispatcher::dispatchMouseMoved(const Point & position)
|
|||||||
{
|
{
|
||||||
if (elem->isHovered())
|
if (elem->isHovered())
|
||||||
{
|
{
|
||||||
(elem)->hover(false);
|
elem->hover(false);
|
||||||
(elem)->hoveredState = false;
|
elem->hoveredState = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -305,8 +306,16 @@ void EventDispatcher::dispatchMouseMoved(const Point & position)
|
|||||||
for(auto & elem : miCopy)
|
for(auto & elem : miCopy)
|
||||||
{
|
{
|
||||||
if(elem->receiveEvent(position, AEventsReceiver::HOVER))
|
if(elem->receiveEvent(position, AEventsReceiver::HOVER))
|
||||||
|
elem->mouseMoved(position, distance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventDispatcher::dispatchMouseDragged(const Point & currentPosition, const Point & lastUpdateDistance)
|
||||||
{
|
{
|
||||||
(elem)->mouseMoved(position);
|
EventReceiversList diCopy = draginterested;
|
||||||
}
|
for(auto & elem : diCopy)
|
||||||
|
{
|
||||||
|
if (elem->mouseClickedState)
|
||||||
|
elem->mouseDragged(currentPosition, lastUpdateDistance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ class EventDispatcher
|
|||||||
EventReceiversList hoverable;
|
EventReceiversList hoverable;
|
||||||
EventReceiversList keyinterested;
|
EventReceiversList keyinterested;
|
||||||
EventReceiversList motioninterested;
|
EventReceiversList motioninterested;
|
||||||
|
EventReceiversList draginterested;
|
||||||
EventReceiversList timeinterested;
|
EventReceiversList timeinterested;
|
||||||
EventReceiversList wheelInterested;
|
EventReceiversList wheelInterested;
|
||||||
EventReceiversList doubleClickInterested;
|
EventReceiversList doubleClickInterested;
|
||||||
@ -59,7 +60,9 @@ public:
|
|||||||
void dispatchMouseLeftButtonReleased(const Point & position);
|
void dispatchMouseLeftButtonReleased(const Point & position);
|
||||||
void dispatchMouseScrolled(const Point & distance, const Point & position);
|
void dispatchMouseScrolled(const Point & distance, const Point & position);
|
||||||
void dispatchMouseDoubleClick(const Point & position);
|
void dispatchMouseDoubleClick(const Point & position);
|
||||||
void dispatchMouseMoved(const Point & distance);
|
void dispatchMouseMoved(const Point & distance, const Point & position);
|
||||||
|
|
||||||
|
void dispatchMouseDragged(const Point & currentPosition, const Point & lastUpdateDistance);
|
||||||
|
|
||||||
void dispatchShowPopup(const Point & position);
|
void dispatchShowPopup(const Point & position);
|
||||||
void dispatchClosePopup(const Point & position);
|
void dispatchClosePopup(const Point & position);
|
||||||
|
@ -45,7 +45,8 @@ protected:
|
|||||||
virtual void gesturePinch(const Point & centerPosition, double lastUpdateFactor) {}
|
virtual void gesturePinch(const Point & centerPosition, double lastUpdateFactor) {}
|
||||||
|
|
||||||
virtual void wheelScrolled(int distance) {}
|
virtual void wheelScrolled(int distance) {}
|
||||||
virtual void mouseMoved(const Point & cursorPosition) {}
|
virtual void mouseMoved(const Point & cursorPosition, const Point & lastUpdateDistance) {}
|
||||||
|
virtual void mouseDragged(const Point & cursorPosition, const Point & lastUpdateDistance) {}
|
||||||
|
|
||||||
/// Called when UI element hover status changes
|
/// Called when UI element hover status changes
|
||||||
virtual void hover(bool on) {}
|
virtual void hover(bool on) {}
|
||||||
@ -84,6 +85,7 @@ public:
|
|||||||
DOUBLECLICK = 256,
|
DOUBLECLICK = 256,
|
||||||
TEXTINPUT = 512,
|
TEXTINPUT = 512,
|
||||||
GESTURE = 1024,
|
GESTURE = 1024,
|
||||||
|
DRAG = 2048,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Returns true if element is currently hovered by mouse
|
/// Returns true if element is currently hovered by mouse
|
||||||
|
@ -63,7 +63,7 @@ void MapViewActions::showPopupWindow()
|
|||||||
adventureInt->onTileRightClicked(tile);
|
adventureInt->onTileRightClicked(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapViewActions::mouseMoved(const Point & cursorPosition)
|
void MapViewActions::mouseMoved(const Point & cursorPosition, const Point & lastUpdateDistance)
|
||||||
{
|
{
|
||||||
handleHover(cursorPosition);
|
handleHover(cursorPosition);
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,6 @@ public:
|
|||||||
void gesturePinch(const Point & centerPosition, double lastUpdateFactor) override;
|
void gesturePinch(const Point & centerPosition, double lastUpdateFactor) override;
|
||||||
void hover(bool on) override;
|
void hover(bool on) override;
|
||||||
void gesture(bool on, const Point & initialPosition, const Point & finalPosition) override;
|
void gesture(bool on, const Point & initialPosition, const Point & finalPosition) override;
|
||||||
void mouseMoved(const Point & cursorPosition) override;
|
void mouseMoved(const Point & cursorPosition, const Point & lastUpdateDistance) override;
|
||||||
void wheelScrolled(int distance) override;
|
void wheelScrolled(int distance) override;
|
||||||
};
|
};
|
||||||
|
@ -18,26 +18,17 @@
|
|||||||
#include "../gui/CGuiHandler.h"
|
#include "../gui/CGuiHandler.h"
|
||||||
#include "../render/Canvas.h"
|
#include "../render/Canvas.h"
|
||||||
|
|
||||||
void CSlider::sliderClicked()
|
void CSlider::mouseDragged(const Point & cursorPosition, const Point & lastUpdateDistance)
|
||||||
{
|
|
||||||
addUsedEvents(MOVE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSlider::mouseMoved (const Point & cursorPosition)
|
|
||||||
{
|
{
|
||||||
double v = 0;
|
double v = 0;
|
||||||
if(getOrientation() == Orientation::HORIZONTAL)
|
if(getOrientation() == Orientation::HORIZONTAL)
|
||||||
{
|
{
|
||||||
if( std::abs(cursorPosition.y-(pos.y+pos.h/2)) > pos.h/2+40 || std::abs(cursorPosition.x-(pos.x+pos.w/2)) > pos.w/2 )
|
|
||||||
return;
|
|
||||||
v = cursorPosition.x - pos.x - 24;
|
v = cursorPosition.x - pos.x - 24;
|
||||||
v *= positions;
|
v *= positions;
|
||||||
v /= (pos.w - 48);
|
v /= (pos.w - 48);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(std::abs(cursorPosition.x-(pos.x+pos.w/2)) > pos.w/2+40 || std::abs(cursorPosition.y-(pos.y+pos.h/2)) > pos.h/2 )
|
|
||||||
return;
|
|
||||||
v = cursorPosition.y - pos.y - 24;
|
v = cursorPosition.y - pos.y - 24;
|
||||||
v *= positions;
|
v *= positions;
|
||||||
v /= (pos.h - 48);
|
v /= (pos.h - 48);
|
||||||
@ -138,15 +129,11 @@ void CSlider::clickLeft(tribool down, bool previousState)
|
|||||||
pw = GH.getCursorPosition().y-pos.y-24;
|
pw = GH.getCursorPosition().y-pos.y-24;
|
||||||
rw = pw / (pos.h-48);
|
rw = pw / (pos.h-48);
|
||||||
}
|
}
|
||||||
if(pw < -8 || pw > (getOrientation() == Orientation::HORIZONTAL ? pos.w : pos.h) - 40)
|
|
||||||
return;
|
|
||||||
// if (rw>1) return;
|
|
||||||
// if (rw<0) return;
|
|
||||||
slider->clickLeft(true, slider->isMouseLeftButtonPressed());
|
slider->clickLeft(true, slider->isMouseLeftButtonPressed());
|
||||||
scrollTo((int)(rw * positions + 0.5));
|
scrollTo((int)(rw * positions + 0.5));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
removeUsedEvents(MOVE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSlider::receiveEvent(const Point &position, int eventType) const
|
bool CSlider::receiveEvent(const Point &position, int eventType) const
|
||||||
@ -165,7 +152,7 @@ bool CSlider::receiveEvent(const Point &position, int eventType) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
CSlider::CSlider(Point position, int totalw, std::function<void(int)> Moved, int Capacity, int Amount, int Value, bool Horizontal, CSlider::EStyle style)
|
CSlider::CSlider(Point position, int totalw, std::function<void(int)> Moved, int Capacity, int Amount, int Value, bool Horizontal, CSlider::EStyle style)
|
||||||
: Scrollable(LCLICK, position, Horizontal ? Orientation::HORIZONTAL : Orientation::VERTICAL ),
|
: Scrollable(LCLICK | DRAG, position, Horizontal ? Orientation::HORIZONTAL : Orientation::VERTICAL ),
|
||||||
capacity(Capacity),
|
capacity(Capacity),
|
||||||
amount(Amount),
|
amount(Amount),
|
||||||
value(Value),
|
value(Value),
|
||||||
@ -207,7 +194,6 @@ CSlider::CSlider(Point position, int totalw, std::function<void(int)> Moved, int
|
|||||||
|
|
||||||
left->addCallback(std::bind(&CSlider::scrollPrev,this));
|
left->addCallback(std::bind(&CSlider::scrollPrev,this));
|
||||||
right->addCallback(std::bind(&CSlider::scrollNext,this));
|
right->addCallback(std::bind(&CSlider::scrollNext,this));
|
||||||
slider->addCallback(std::bind(&CSlider::sliderClicked,this));
|
|
||||||
|
|
||||||
if(getOrientation() == Orientation::HORIZONTAL)
|
if(getOrientation() == Orientation::HORIZONTAL)
|
||||||
{
|
{
|
||||||
|
@ -37,7 +37,6 @@ class CSlider : public Scrollable
|
|||||||
CFunctionList<void(int)> moved;
|
CFunctionList<void(int)> moved;
|
||||||
|
|
||||||
void updateSliderPos();
|
void updateSliderPos();
|
||||||
void sliderClicked();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum EStyle
|
enum EStyle
|
||||||
@ -71,7 +70,7 @@ public:
|
|||||||
bool receiveEvent(const Point & position, int eventType) const override;
|
bool receiveEvent(const Point & position, int eventType) const override;
|
||||||
void keyPressed(EShortcut key) override;
|
void keyPressed(EShortcut key) override;
|
||||||
void clickLeft(tribool down, bool previousState) override;
|
void clickLeft(tribool down, bool previousState) override;
|
||||||
void mouseMoved (const Point & cursorPosition) override;
|
void mouseDragged(const Point & cursorPosition, const Point & lastUpdateDistance) override;
|
||||||
void showAll(Canvas & to) override;
|
void showAll(Canvas & to) override;
|
||||||
|
|
||||||
/// @param position coordinates of slider
|
/// @param position coordinates of slider
|
||||||
|
@ -69,7 +69,7 @@ CBuildingRect::CBuildingRect(CCastleBuildings * Par, const CGTownInstance * Town
|
|||||||
area(nullptr),
|
area(nullptr),
|
||||||
stateTimeCounter(BUILD_ANIMATION_FINISHED_TIMEPOINT)
|
stateTimeCounter(BUILD_ANIMATION_FINISHED_TIMEPOINT)
|
||||||
{
|
{
|
||||||
addUsedEvents(LCLICK | SHOW_POPUP | HOVER | TIME);
|
addUsedEvents(LCLICK | SHOW_POPUP | MOVE | HOVER | TIME);
|
||||||
pos.x += str->pos.x;
|
pos.x += str->pos.x;
|
||||||
pos.y += str->pos.y;
|
pos.y += str->pos.y;
|
||||||
|
|
||||||
@ -108,19 +108,24 @@ const CBuilding * CBuildingRect::getBuilding()
|
|||||||
bool CBuildingRect::operator<(const CBuildingRect & p2) const
|
bool CBuildingRect::operator<(const CBuildingRect & p2) const
|
||||||
{
|
{
|
||||||
return (str->pos.z) < (p2.str->pos.z);
|
return (str->pos.z) < (p2.str->pos.z);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBuildingRect::hover(bool on)
|
void CBuildingRect::hover(bool on)
|
||||||
{
|
{
|
||||||
|
if (!area)
|
||||||
|
return;
|
||||||
|
|
||||||
if(on)
|
if(on)
|
||||||
{
|
{
|
||||||
addUsedEvents(MOVE);
|
if(! parent->selectedBuilding //no building hovered
|
||||||
|
|| (*parent->selectedBuilding)<(*this)) //or we are on top
|
||||||
|
{
|
||||||
|
parent->selectedBuilding = this;
|
||||||
|
GH.statusbar()->write(getSubtitle());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
removeUsedEvents(MOVE);
|
|
||||||
|
|
||||||
if(parent->selectedBuilding == this)
|
if(parent->selectedBuilding == this)
|
||||||
{
|
{
|
||||||
parent->selectedBuilding = nullptr;
|
parent->selectedBuilding = nullptr;
|
||||||
@ -132,21 +137,17 @@ void CBuildingRect::hover(bool on)
|
|||||||
void CBuildingRect::clickLeft(tribool down, bool previousState)
|
void CBuildingRect::clickLeft(tribool down, bool previousState)
|
||||||
{
|
{
|
||||||
if(previousState && getBuilding() && area && !down && (parent->selectedBuilding==this))
|
if(previousState && getBuilding() && area && !down && (parent->selectedBuilding==this))
|
||||||
{
|
|
||||||
if(!area->isTransparent(GH.getCursorPosition() - pos.topLeft())) //inside building image
|
|
||||||
{
|
{
|
||||||
auto building = getBuilding();
|
auto building = getBuilding();
|
||||||
parent->buildingClicked(building->bid, building->subId, building->upgrade);
|
parent->buildingClicked(building->bid, building->subId, building->upgrade);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void CBuildingRect::showPopupWindow()
|
void CBuildingRect::showPopupWindow()
|
||||||
{
|
{
|
||||||
if((!area) || (this!=parent->selectedBuilding) || getBuilding() == nullptr)
|
if((!area) || (this!=parent->selectedBuilding) || getBuilding() == nullptr)
|
||||||
return;
|
return;
|
||||||
if( !area->isTransparent(GH.getCursorPosition() - pos.topLeft()) ) //inside building image
|
|
||||||
{
|
|
||||||
BuildingID bid = getBuilding()->bid;
|
BuildingID bid = getBuilding()->bid;
|
||||||
const CBuilding *bld = town->town->buildings.at(bid);
|
const CBuilding *bld = town->town->buildings.at(bid);
|
||||||
if (bid < BuildingID::DWELL_FIRST)
|
if (bid < BuildingID::DWELL_FIRST)
|
||||||
@ -160,7 +161,6 @@ void CBuildingRect::showPopupWindow()
|
|||||||
GH.windows().createAndPushWindow<CDwellingInfoBox>(parent->pos.x+parent->pos.w / 2, parent->pos.y+parent->pos.h /2, town, level);
|
GH.windows().createAndPushWindow<CDwellingInfoBox>(parent->pos.x+parent->pos.w / 2, parent->pos.y+parent->pos.h /2, town, level);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void CBuildingRect::show(Canvas & to)
|
void CBuildingRect::show(Canvas & to)
|
||||||
{
|
{
|
||||||
@ -245,28 +245,20 @@ std::string CBuildingRect::getSubtitle()//hover text for building
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBuildingRect::mouseMoved (const Point & cursorPosition)
|
void CBuildingRect::mouseMoved (const Point & cursorPosition, const Point & lastUpdateDistance)
|
||||||
{
|
{
|
||||||
if(area && pos.isInside(cursorPosition.x, cursorPosition.y))
|
hover(true);
|
||||||
{
|
|
||||||
if(area->isTransparent(cursorPosition - pos.topLeft())) //hovered pixel is inside this building
|
|
||||||
{
|
|
||||||
if(parent->selectedBuilding == this)
|
|
||||||
{
|
|
||||||
parent->selectedBuilding = nullptr;
|
|
||||||
GH.statusbar()->clear();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else //inside the area of this building
|
bool CBuildingRect::receiveEvent(const Point & position, int eventType) const
|
||||||
{
|
{
|
||||||
if(! parent->selectedBuilding //no building hovered
|
if (!pos.isInside(position.x, position.y))
|
||||||
|| (*parent->selectedBuilding)<(*this)) //or we are on top
|
return false;
|
||||||
{
|
|
||||||
parent->selectedBuilding = this;
|
if(area && area->isTransparent(position - pos.topLeft()))
|
||||||
GH.statusbar()->write(getSubtitle());
|
return false;
|
||||||
}
|
|
||||||
}
|
return CIntObject::receiveEvent(position, eventType);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CDwellingInfoBox::CDwellingInfoBox(int centerX, int centerY, const CGTownInstance * Town, int level)
|
CDwellingInfoBox::CDwellingInfoBox(int centerX, int centerY, const CGTownInstance * Town, int level)
|
||||||
|
@ -68,7 +68,8 @@ public:
|
|||||||
void hover(bool on) override;
|
void hover(bool on) override;
|
||||||
void clickLeft(tribool down, bool previousState) override;
|
void clickLeft(tribool down, bool previousState) override;
|
||||||
void showPopupWindow() override;
|
void showPopupWindow() override;
|
||||||
void mouseMoved (const Point & cursorPosition) override;
|
void mouseMoved (const Point & cursorPosition, const Point & lastUpdateDistance) override;
|
||||||
|
bool receiveEvent(const Point & position, int eventType) const override;
|
||||||
void tick(uint32_t msPassed) override;
|
void tick(uint32_t msPassed) override;
|
||||||
void show(Canvas & to) override;
|
void show(Canvas & to) override;
|
||||||
void showAll(Canvas & to) override;
|
void showAll(Canvas & to) override;
|
||||||
|
@ -66,7 +66,7 @@ class CQuestMinimap : public CMinimap
|
|||||||
|
|
||||||
void clickLeft(tribool down, bool previousState) override{}; //minimap ignores clicking on its surface
|
void clickLeft(tribool down, bool previousState) override{}; //minimap ignores clicking on its surface
|
||||||
void iconClicked();
|
void iconClicked();
|
||||||
void mouseMoved (const Point & cursorPosition) override{};
|
void mouseDragged(const Point & cursorPosition, const Point & lastUpdateDistance) override{};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const QuestInfo * currentQuest;
|
const QuestInfo * currentQuest;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user