1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
/******************************************************************************
File: FEMouse.h
Desc: Interface for the Frontend Mouse class.
- Uses the windows mouse functionality.
Date: June 13, 2003
History:
*****************************************************************************/
#ifndef FEMOUSE_H
#define FEMOUSE_H
#include <input/MouseCursor.h>
enum eFEMouseButton
{
BUTTON_LEFT,
BUTTON_RIGHT,
NUM_BUTTON_TYPES
};
enum eFEMouseHorzDir
{
MDIR_LEFT,
MDIR_RIGHT,
NUM_MOUSE_HORZ_DIRECTIONS,
NO_HORZ_MOVEMENT
};
enum eFEHotspotType
{
HOTSPOT_BUTTON,
HOTSPOT_ARROWLEFT,
HOTSPOT_ARROWRIGHT,
HOTSPOT_ARROWUP,
HOTSPOT_ARROWDOWN,
HOTSPOT_SLIDER,
HOTSPOT_LTRIGGER,
HOTSPOT_RTRIGGER,
NUM_HOTSPOT_TYPES,
HOTSPOT_NONE
};
enum eFEButtonStates
{
BUTTON_IDLE,
BUTTON_CLICKHOLD,
BUTTON_CLICKED,
NUM_BUTTON_STATES
};
class FEMouse
{
public:
FEMouse();
~FEMouse();
MouseCursor* getCursor() const { return m_pCursor; }
bool Moved() const { return m_bMoved; }
bool IsClickable() const { return m_bClickable; }
eFEMouseHorzDir MovedHorizontally() const { return m_horzDir; }
bool IsLeftButtonDown() const { return (m_button[BUTTON_LEFT]==BUTTON_CLICKHOLD); }
eFEHotspotType LeftButtonDownOn() const
{
return ((m_button[BUTTON_LEFT]==BUTTON_CLICKHOLD) ? m_hotSpotType : HOTSPOT_NONE);
}
bool IsRightButtonDown() const { return (m_button[BUTTON_RIGHT]==BUTTON_CLICKHOLD); }
void InitMouseCursor( tDrawable* pCursor );
void SetClickable( bool bClickable ) { m_bClickable = bClickable; }
void SetSelectable( bool bSelectable ) { m_bSelectable = bSelectable; }
void SetClickStopMode( bool bClickAndStop ) { m_bClickAndStop = bClickAndStop; }
void ButtonDown( eFEMouseButton buttonType );
void ButtonUp( eFEMouseButton buttonType );
eFEMouseHorzDir OnSliderHorizontalClickDrag() const; //Is on a slider clicking and dragging horizontally.
bool DidWeMove( int newX, int newY ) const;
void Move( int mouseX, int mouseY, long screenWidth, long screenHeight );
void Update();
void SetInGameMode( bool ingame );
void SetInGameOverride( bool override );
private:
void SetupInGameMode();
private:
MouseCursor* m_pCursor;
bool m_bMoved;
bool m_bClickable;
bool m_bSelectable;
bool m_bMovable;
bool m_bClickAndStop; // if this is on, if a button is clicked, mouse processing stops.
char m_button[ NUM_BUTTON_TYPES ];
eFEHotspotType m_hotSpotType;
eFEMouseHorzDir m_horzDir;
int m_oldPositionX, //We save the last position of the mouse.
m_oldPositionY;
bool m_bInGame;
bool m_bInGameOverride;
int m_inGamePosX;
int m_inGamePosY;
int m_buttonDownSelection;
};
#endif
|