22 #ifndef ULTIMA8_KERNEL_MOUSE_H 23 #define ULTIMA8_KERNEL_MOUSE_H 25 #include "common/system.h" 26 #include "common/rect.h" 27 #include "ultima/ultima8/misc/common_types.h" 28 #include "ultima/ultima8/misc/direction.h" 33 enum MouseButtonState {
45 MButton() : _downGump(0), _curDown(0), _lastDown(0), _state(MBS_HANDLED)
49 bool isState(MouseButtonState state)
const {
50 return _state & state;
52 void setState(MouseButtonState state) {
55 void clearState(MouseButtonState state) {
61 return !isState(MBS_HANDLED) && _curDown > 0 && (now - _curDown) > timeout;
66 return !isState(MBS_HANDLED) && _lastDown > 0 && (_curDown - _lastDown) <= timeout;
101 static Mouse *_instance;
108 uint32 _flashingCursorTime;
111 MButton _mouseButton[MOUSE_LAST];
113 uint16 _mouseOverGump;
116 DraggingState _dragging;
118 ObjId _dragging_objId;
119 uint16 _draggingItem_startGump;
120 uint16 _draggingItem_lastGump;
125 void startDragging(
int mx,
int my);
126 void moveDragging(
int mx,
int my);
127 void stopDragging(
int mx,
int my);
128 int mouseFrameForDir(Direction mousedir)
const;
131 static Mouse *get_instance() {
return _instance; }
139 bool buttonDown(MouseButton button);
144 bool buttonUp(MouseButton button);
147 int getMouseLength(
int mx,
int my)
const;
151 return getMouseLength(_mousePos.
x, _mousePos.
y);
155 Direction getMouseDirectionScreen(
int mx,
int my)
const;
159 return getMouseDirectionScreen(_mousePos.
x, _mousePos.
y);
163 Direction getMouseDirectionWorld(
int mx,
int my)
const;
167 return getMouseDirectionWorld(_mousePos.
x, _mousePos.
y);
177 void setMouseCoords(
int mx,
int my);
179 bool isMouseDownEvent(MouseButton button)
const;
182 void popAllCursors();
185 void setMouseCursor(MouseCursor cursor);
188 void flashCrossCursor();
191 void pushMouseCursor(MouseCursor cursor);
194 void popMouseCursor();
199 DraggingState dragging()
const {
return _dragging; }
201 void setDraggingOffset(int32 x, int32 y) {
202 _draggingOffset.
x = x;
203 _draggingOffset.
y = y;
205 void getDraggingOffset(int32 &x, int32 &y) {
206 x = _draggingOffset.
x;
207 y = _draggingOffset.
y;
210 uint32 getDoubleClickTime()
const;
212 void handleDelayedEvents();
214 Gump *getMouseOverGump()
const;
215 void resetMouseOverGump() { _mouseOverGump = 0; }
Direction getMouseDirectionScreen() const
get mouse cursor direction on the screen using the current coordinates.
Definition: mouse.h:158
int getMouseLength() const
get mouse cursor length for the current coordinates
Definition: mouse.h:150
Definition: detection.h:27
void getMouseCoords(int32 &mx, int32 &my) const
get current mouse cursor location
Definition: mouse.h:171
int16 x
Definition: rect.h:46
int16 y
Definition: rect.h:47
Direction getMouseDirectionWorld() const
get mouse cursor direction in the world using the current coordinates.
Definition: mouse.h:166