mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +02:00
Renamed CGuiHandler to GameEngine
- class CGuiHandler is now called GameEngine to better describe its functionality - renamed global GH to more clear ENGINE - GH/ENGINE is now unique_ptr to make construction / deconstruction order more clear and to allow interface / implementation split - CGuiHandler.cpp/h is now called GameEngine.cpp/h and located in root directory of client dir
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
#include "InputSourceMouse.h"
|
||||
#include "InputHandler.h"
|
||||
|
||||
#include "../gui/CGuiHandler.h"
|
||||
#include "../GameEngine.h"
|
||||
#include "../gui/EventDispatcher.h"
|
||||
#include "../gui/MouseButton.h"
|
||||
|
||||
@@ -33,39 +33,39 @@ InputSourceMouse::InputSourceMouse()
|
||||
|
||||
void InputSourceMouse::handleEventMouseMotion(const SDL_MouseMotionEvent & motion)
|
||||
{
|
||||
Point newPosition = Point(motion.x, motion.y) / GH.screenHandler().getScalingFactor();
|
||||
Point distance = Point(-motion.xrel, -motion.yrel) / GH.screenHandler().getScalingFactor();
|
||||
Point newPosition = Point(motion.x, motion.y) / ENGINE->screenHandler().getScalingFactor();
|
||||
Point distance = Point(-motion.xrel, -motion.yrel) / ENGINE->screenHandler().getScalingFactor();
|
||||
|
||||
mouseButtonsMask = motion.state;
|
||||
|
||||
if (mouseButtonsMask & SDL_BUTTON(SDL_BUTTON_MIDDLE))
|
||||
GH.events().dispatchGesturePanning(middleClickPosition, newPosition, distance);
|
||||
ENGINE->events().dispatchGesturePanning(middleClickPosition, newPosition, distance);
|
||||
else if (mouseButtonsMask & SDL_BUTTON(SDL_BUTTON_LEFT))
|
||||
GH.events().dispatchMouseDragged(newPosition, distance);
|
||||
ENGINE->events().dispatchMouseDragged(newPosition, distance);
|
||||
else if (mouseButtonsMask & SDL_BUTTON(SDL_BUTTON_RIGHT))
|
||||
GH.events().dispatchMouseDraggedPopup(newPosition, distance);
|
||||
ENGINE->events().dispatchMouseDraggedPopup(newPosition, distance);
|
||||
else
|
||||
GH.input().setCursorPosition(newPosition);
|
||||
ENGINE->input().setCursorPosition(newPosition);
|
||||
}
|
||||
|
||||
void InputSourceMouse::handleEventMouseButtonDown(const SDL_MouseButtonEvent & button)
|
||||
{
|
||||
Point position = Point(button.x, button.y) / GH.screenHandler().getScalingFactor();
|
||||
Point position = Point(button.x, button.y) / ENGINE->screenHandler().getScalingFactor();
|
||||
|
||||
switch(button.button)
|
||||
{
|
||||
case SDL_BUTTON_LEFT:
|
||||
if(button.clicks > 1)
|
||||
GH.events().dispatchMouseDoubleClick(position, mouseToleranceDistance);
|
||||
ENGINE->events().dispatchMouseDoubleClick(position, mouseToleranceDistance);
|
||||
else
|
||||
GH.events().dispatchMouseLeftButtonPressed(position, mouseToleranceDistance);
|
||||
ENGINE->events().dispatchMouseLeftButtonPressed(position, mouseToleranceDistance);
|
||||
break;
|
||||
case SDL_BUTTON_RIGHT:
|
||||
GH.events().dispatchShowPopup(position, mouseToleranceDistance);
|
||||
ENGINE->events().dispatchShowPopup(position, mouseToleranceDistance);
|
||||
break;
|
||||
case SDL_BUTTON_MIDDLE:
|
||||
middleClickPosition = position;
|
||||
GH.events().dispatchGesturePanningStarted(position);
|
||||
ENGINE->events().dispatchGesturePanningStarted(position);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -75,26 +75,26 @@ void InputSourceMouse::handleEventMouseWheel(const SDL_MouseWheelEvent & wheel)
|
||||
//NOTE: while mouseX / mouseY properties are available since 2.26.0, they are not converted into logical coordinates so don't account for resolution scaling
|
||||
// This SDL bug was fixed in 2.30.1: https://github.com/libsdl-org/SDL/issues/9097
|
||||
#if SDL_VERSION_ATLEAST(2,30,1)
|
||||
GH.events().dispatchMouseScrolled(Point(wheel.x, wheel.y), Point(wheel.mouseX, wheel.mouseY) / GH.screenHandler().getScalingFactor());
|
||||
ENGINE->events().dispatchMouseScrolled(Point(wheel.x, wheel.y), Point(wheel.mouseX, wheel.mouseY) / ENGINE->screenHandler().getScalingFactor());
|
||||
#else
|
||||
GH.events().dispatchMouseScrolled(Point(wheel.x, wheel.y), GH.getCursorPosition());
|
||||
ENGINE->events().dispatchMouseScrolled(Point(wheel.x, wheel.y), ENGINE->getCursorPosition());
|
||||
#endif
|
||||
}
|
||||
|
||||
void InputSourceMouse::handleEventMouseButtonUp(const SDL_MouseButtonEvent & button)
|
||||
{
|
||||
Point position = Point(button.x, button.y) / GH.screenHandler().getScalingFactor();
|
||||
Point position = Point(button.x, button.y) / ENGINE->screenHandler().getScalingFactor();
|
||||
|
||||
switch(button.button)
|
||||
{
|
||||
case SDL_BUTTON_LEFT:
|
||||
GH.events().dispatchMouseLeftButtonReleased(position, mouseToleranceDistance);
|
||||
ENGINE->events().dispatchMouseLeftButtonReleased(position, mouseToleranceDistance);
|
||||
break;
|
||||
case SDL_BUTTON_RIGHT:
|
||||
GH.events().dispatchClosePopup(position);
|
||||
ENGINE->events().dispatchClosePopup(position);
|
||||
break;
|
||||
case SDL_BUTTON_MIDDLE:
|
||||
GH.events().dispatchGesturePanningEnded(middleClickPosition, position);
|
||||
ENGINE->events().dispatchGesturePanningEnded(middleClickPosition, position);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user