22#ifndef ULTIMA8_KERNEL_MOUSE_H
23#define ULTIMA8_KERNEL_MOUSE_H
25#include "common/rect.h"
26#include "common/stack.h"
27#include "common/scummsys.h"
29#include "ultima/ultima8/misc/common_types.h"
30#include "ultima/ultima8/misc/direction.h"
35enum MouseButtonState {
47 MButton() : _downGump(0), _curDown(0), _lastDown(0), _state(MBS_HANDLED)
51 bool isState(MouseButtonState state)
const {
52 return _state & state;
54 void setState(MouseButtonState state) {
57 void clearState(MouseButtonState state) {
63 return !isState(MBS_HANDLED) && _curDown > 0 && (now - _curDown) > timeout;
68 return !isState(MBS_HANDLED) && _lastDown > 0 && (_curDown - _lastDown) <= timeout;
103 static Mouse *_instance;
110 uint32 _flashingCursorTime;
113 MButton _mouseButton[MOUSE_LAST];
115 uint16 _mouseOverGump;
118 DraggingState _dragging;
120 ObjId _dragging_objId;
121 uint16 _draggingItem_startGump;
122 uint16 _draggingItem_lastGump;
127 void startDragging(
int mx,
int my);
128 void moveDragging(
int mx,
int my);
129 void stopDragging(
int mx,
int my);
130 int mouseFrameForDir(Direction mousedir)
const;
133 static Mouse *get_instance() {
return _instance; }
181 bool isMouseDownEvent(MouseButton button)
const;
201 DraggingState dragging()
const {
return _dragging; }
203 void setDraggingOffset(int32 x, int32 y) {
204 _draggingOffset.
x = x;
205 _draggingOffset.
y = y;
207 void getDraggingOffset(int32 &x, int32 &y) {
208 x = _draggingOffset.
x;
209 y = _draggingOffset.
y;
212 uint32 getDoubleClickTime()
const;
214 void handleDelayedEvents();
216 Gump *getMouseOverGump()
const;
217 void resetMouseOverGump() { _mouseOverGump = 0; }
void getMouseCoords(int32 &mx, int32 &my) const
get current mouse cursor location
Definition: mouse.h:173
Direction getMouseDirectionScreen(int mx, int my) const
get mouse cursor direction on the screen. 0 = up, 1 = up-right, 2 = right, etc...
int getMouseFrame()
get the current mouse frame
bool buttonUp(MouseButton button)
bool buttonDown(MouseButton button)
int getMouseLength() const
get mouse cursor length for the current coordinates
Definition: mouse.h:152
Direction getMouseDirectionWorld() const
get mouse cursor direction in the world using the current coordinates.
Definition: mouse.h:168
void setMouseCoords(int mx, int my)
set current mouse cursor location
void popAllCursors()
remove all existing cursors
void popMouseCursor()
pop the last mouse cursor from the stack
Direction getMouseDirectionScreen() const
get mouse cursor direction on the screen using the current coordinates.
Definition: mouse.h:160
void flashCrossCursor()
flash the red cross mouse cursor for a brief while
void pushMouseCursor(MouseCursor cursor)
push the current mouse cursor to the stack
Direction getMouseDirectionWorld(int mx, int my) const
get mouse cursor direction in the world. 0 = up, 1 = up-right, 2 = right, etc...
int getMouseLength(int mx, int my) const
get mouse cursor length. 0 = short, 1 = medium, 2 = long
void setMouseCursor(MouseCursor cursor)
set the current mouse cursor