ScummVM API documentation
mouse.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef SKY_MOUSE_H
23#define SKY_MOUSE_H
24
25
26#include "common/scummsys.h"
27#include "common/hashmap.h"
28
29class OSystem;
30
31namespace Sky {
32
33// max click cycles before interact is not valid upon release
34#define CLICK_THRESHOLD 10
35// cycles before inv use-on trigger
36#define USEON_THRESHOLD 5
37// time till hotspot fades out after stopped touching
38#define HOTSPOT_FADEOUT 36
39// hotspot icon size
40#define HOTSPOT_DIM 36
41// exit is just one icon, so half width as straddles centre point
42#define HOTSPOT_EXIT_DIM (HOTSPOT_DIM >> 1)
43// how far the popup icons sit above the midy
44#define HOTSPOT_YOFF 48
45// differentiate exits, just incase
46#define HOTSPOT_EXIT_YOFF 48
47
48// use on cursor offset
49#define HOTSPOT_USE_ON_YOFF (-55)
50
51// inv button (bottom left)
52#define HOTSPOT_INVX (TOP_LEFT_X + 40)
53#define HOTSPOT_INVY (TOP_LEFT_Y + FULL_SCREEN_HEIGHT-35)
54
55// control panel button (top left)
56#define HOTSPOT_OPTIONSX (TOP_LEFT_X + 30)
57#define HOTSPOT_OPTIONSY (TOP_LEFT_Y + 30)
58
59// help button (top right)
60#define HOTSPOT_helpx (TOP_LEFT_X + FULL_SCREEN_WIDTH-30)
61#define HOTSPOT_helpy (TOP_LEFT_Y + 30)
62
63// glow proximity
64#define GLOW_DIST 150
65// drag to use on distance
66#define USE_ON_DIST 40
67
68// fix super deep exits
69#define TWEEKY_EXIT_ADJUST (FULL_SCREEN_HEIGHT + TOP_LEFT_Y - 40)
70
71
72// inv item sizes
73#define XWIDTH 32
74#define YDEPTH 32
75
76// action flash
77#define ACTION_FLASH_TIME 7
78
79class Disk;
80class Logic;
81class SkyCompact;
82class Text;
83class Screen;
84class Control;
85struct Compact;
86enum UIIcon : uint8;
87
88class Mouse {
89
90public:
91
92 Mouse(OSystem *system, Disk *skyDisk, SkyCompact *skyCompact, Screen *skyScreen);
93 ~Mouse();
94
95 void mouseEngine();
96 void mouseEngineIBASS();
97 void replaceMouseCursors(uint16 fileNo);
98 bool fnAddHuman();
99 void fnSaveCoods();
100 void fnOpenCloseHand(bool open);
101 uint16 findMouseCursor(uint32 itemNum);
102 void lockMouse();
103 void unlockMouse();
104 void restoreMouseData(uint16 frameNum);
105 void drawNewMouse();
106 void spriteMouse(uint16 frameNum, uint8 mouseX, uint8 mouseY);
107 void useLogicInstance(Logic *skyLogic) { _skyLogic = skyLogic; }
108 void useControlInstance(Control *control) { _skyControl = control; }
109 void buttonPressed(uint8 button);
110 void mouseMoved(uint16 mouseX, uint16 mouseY);
111 void waitMouseNotPressed(int minDelay = 0);
112 uint16 giveMouseX() { return _mouseX; }
113 uint16 giveMouseY() { return _mouseY; }
114 uint16 giveCurrentMouseType() { return _currentCursor; }
115 bool wasClicked();
116 void logicClick() { _logicClick = true; }
117 void resetCursor();
118 void setInvDims(uint16 x, uint16 y, uint16 w, uint16 h) {
119 _invX = x;
120 _invY = y;
121 _invW = w;
122 _invH = h;
123 }
124 bool isUILive();
125 void setTextChooserMode() {
126 _mMode = TEXT_CHOOSER;
127 }
128 void resetUI();
129 OSystem *giveSystem(){
130 return _system;
131 }
132 int doProximityHighlights(uint16 xPos, uint16 yPos);
133 uint16 giveXCood(Compact *itemData, uint32 id);
134 uint16 giveYCood(Compact *itemData, uint32 id);
135 void setLincInv(bool inv) {
136 _isLincInv = inv;
137 }
138 bool isLincInv() {
139 return _isLincInv;
140 }
141 void incLincMenuRef() {
142 _lincMenuRef++ ;
143 }
144 void pushInvY(uint16 y) {
145 _invYCoord = y;
146 }
147 uint16 popInvY() {
148 return _invYCoord;
149 }
150 UIIcon getInteractIcon(uint32 id);
151 bool hasSingleInteractIcon(uint32 id);
152 void updateHotspotCoordinate(uint16 xPos);
153 int touchingFloor(uint16 xPos, uint16 yPos);
154
155protected:
156
157 void pointerEngine(uint16 xPos, uint16 yPos);
158 void pointerEngineIBASS(uint16 xPos, uint16 yPos);
159 void buttonEngine1();
160 void invMouse(uint16 xPos, uint16 yPos);
161 void lincInvMouse(uint16 xPos, uint16 yPos);
162 void invUseOn(uint16 xPos, uint16 yPos);
163 void textChooser(uint16 xPos, uint16 yPos);
164
165 bool _logicClick;
166
167 uint16 _mouseB; //mouse button
168 uint16 _mouseX; //actual mouse coordinates
169 uint16 _mouseY;
170
171 int16 _mouseXOff;
172 int16 _mouseYOff;
173 uint16 _timeOn; // how long have we held on this item
174 uint16 _clickedNum; // remmebers what we clicked last
175 uint16 _fadeOut; // how long before current hotspot fades out when let go
176 bool _prevMouseOn; // touching yes/no last cycle
177 uint16 _touchId;
178 uint16 _touchIdLegacy;
179 uint16 _hoverId; // inv drag over inv
180 bool _holding;
181 bool _isExit; // cur hotspot an exit?
182 uint32 _exitType; // what type of exit
183 bool _isFloor;
184 bool _isLincInv; // current inventory is in LINC which works weirdly differently
185 uint32 _lincMenuRef; // used to check if a linc inv menu restarted the inv
186 uint16 _invYCoord; // store inv item y coords ready for patching back in
187 int _nearestProximityIconId;
188 bool _floorLock; // stop moving off hotpots onto floors then releasing to get an interaction
189
190 uint16 _invX; // inventory bounds x
191 uint16 _invY; // inventory bounds y
192 uint16 _invW; // inventory bounds w
193 uint16 _invH; // inventory bounds h
194
195 bool _actionFlash = false; // clicked on action icon flasher
196 int _actionFlashTime = 0; // counts down
197 int _actionFlashIcon = 0;
198 int _actionFlashX = 0;
199 int _actionFlashY = 0;
200 void initExitIcon(uint32 type, int iconx, int icony);
201
202
203 uint16 _currentCursor;
204
205 byte *_miceData; //address of mouse sprites
206 byte *_objectMouseData; //address of object mouse sprites
207
208 int _proxFrame;
209 int _proxFrameSpeed;
210
211 Common::HashMap<int, int> _hotspotXMap;
212 Common::HashMap<int, int> _hotspotYMap;
213
214 static uint32 _mouseMainObjects[24];
215 static uint32 _mouseLincObjects[21];
216
217 OSystem *_system;
218 Disk *_skyDisk;
219 Logic *_skyLogic;
220 SkyCompact *_skyCompact;
221 Screen *_skyScreen;
222 Control *_skyControl;
223
224 enum : uint8 {
225 GAMEPLAY,
226 PRE_INVENTORY,
227 INVENTORY,
228 INV_TEMP_EXAMINE,
229 INVENTORY_USE_ON,
230 TEXT_CHOOSER,
231 MUST_RELEASE,
232 ALERT_TO_GAME, // new game alert box
233 } _mMode;
234};
235
236} // End of namespace Sky
237
238#endif //SKYMOUSE_H
Definition: system.h:166
Definition: control.h:192
Definition: disk.h:59
Definition: logic.h:136
Definition: mouse.h:88
Definition: screen.h:80
Definition: compact.h:58
Definition: autoroute.h:28
Definition: atari-screen.h:58
Definition: struc.h:112