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 * Additional copyright for this file:
8 * Copyright (C) 1994-1998 Revolution Software Ltd.
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 */
23
24#ifndef SWORD2_MOUSE_H
25#define SWORD2_MOUSE_H
26
27#include "common/rect.h"
28
29#define MENU_MASTER_OBJECT 44
30
31#define MAX_SUBJECT_LIST 30 // is that enough?
32
33#define TOTAL_subjects (375 - 256 + 1) // the speech subject bar
34#define TOTAL_engine_pockets (15 + 10) // +10 for overflow
35#define TOTAL_mouse_list 50
36
37namespace Sword2 {
38
39struct MenuObject;
40struct BuildUnit;
41
42// Menubar defines.
43
44#define RDMENU_TOP 0
45#define RDMENU_BOTTOM 1
46
47enum {
48 MOUSE_normal = 0, // normal in game
49 MOUSE_menu = 1, // menu chooser
50 MOUSE_drag = 2, // dragging luggage
51 MOUSE_system_menu = 3, // system menu chooser
52 MOUSE_holding = 4 // special
53};
54
55enum {
56 RDMOUSE_NOFLASH,
57 RDMOUSE_FLASH
58};
59
60enum {
61 RDMENU_HIDDEN,
62 RDMENU_SHOWN,
63 RDMENU_OPENING,
64 RDMENU_CLOSING,
65 RDMENU_ALMOST_HIDDEN
66};
67
68#define RDMENU_ICONWIDE 35
69#define RDMENU_PSXICONWIDE 36
70#define RDMENU_ICONDEEP 30
71#define RDMENU_ICONSTART 24
72#define RDMENU_ICONSPACING 5
73#define RDMENU_MAXPOCKETS 15
74
75#define MOUSE_ANIM_HEADER_SIZE 6
76
77struct MouseAnim {
78 uint8 runTimeComp; // type of runtime compression used for the
79 // frame data
80 uint8 noAnimFrames; // number of frames in the anim
81 int8 xHotSpot;
82 int8 yHotSpot;
83 uint8 mousew;
84 uint8 mouseh;
85
86 byte *data;
87};
88
89// The MOUSE_holding mode is entered when the conversation menu is closed, and
90// exited when the mouse cursor moves off that menu area. I don't know why yet.
91
92// mouse unit - like ObjectMouse, but with anim resource & pc (needed if
93// sprite is to act as mouse detection mask)
94
95struct MouseUnit {
96 // Basically the same information as in ObjectMouse, except the
97 // coordinates are adjusted to conform to standard ScummVM usage.
98
99 Common::Rect rect;
100 int32 priority;
101 int32 pointer;
102
103 // In addition, we need an id when checking the mouse list, and a
104 // text id for mouse-overs.
105
106 int32 id;
107 int32 pointer_text;
108
109 void clear() {
110 rect.top = 0;
111 rect.left = 0;
112 rect.bottom = 0;
113 rect.right = 0;
114 priority = 0;
115 pointer = 0;
116 id = 0;
117 pointer_text = 0;
118 }
119};
120
121// Array of these for subject menu build up
122
123 struct SubjectUnit {
124 uint32 res;
125 uint32 ref;
126};
127
128// define these in a script and then register them with the system
129
131 int32 icon_resource; // icon graphic graphic
132 int32 luggage_resource; // luggage icon resource (for attaching to
133 // mouse pointer)
134};
135
136class Mouse {
137private:
138 Sword2Engine *_vm;
139
140 MouseUnit _mouseList[TOTAL_mouse_list];
141 uint32 _curMouse;
142
143 MenuObject _tempList[TOTAL_engine_pockets];
144 uint32 _totalTemp;
145
146 MenuObject _masterMenuList[TOTAL_engine_pockets];
147 uint32 _totalMasters;
148
149 SubjectUnit _subjectList[MAX_SUBJECT_LIST];
150
151 // ref number for default response when luggage icon is used on a
152 // person & it doesn't match any of the icons which would have been in
153 // the chooser
154
155 uint32 _defaultResponseId;
156
157 // could alternately use logic->looping of course
158 bool _choosing;
159
160 uint8 _menuStatus[2];
161 byte *_icons[2][RDMENU_MAXPOCKETS];
162 uint8 _pocketStatus[2][RDMENU_MAXPOCKETS];
163
164 uint8 _iconCount;
165
166 // If it's NORMAL_MOUSE_ID (ie. normal pointer) then it's over a floor
167 // area (or hidden hot-zone)
168
169 uint32 _mousePointerRes;
170
171 MouseAnim _mouseAnim;
172 MouseAnim _luggageAnim;
173
174 uint8 _mouseFrame;
175
176 uint32 _mouseMode;
177
178 bool _mouseStatus; // Human 0 on/1 off
179 bool _mouseModeLocked; // 0 not !0 mode cannot be changed from
180 // normal mouse to top menu (i.e. when
181 // carrying big objects)
182 uint32 _realLuggageItem; // Last minute for pause mode
183 uint32 _currentLuggageResource;
184 uint32 _oldButton; // For the re-click stuff - must be
185 // the same button you see
186 uint32 _buttonClick;
187 uint32 _pointerTextBlocNo;
188 uint32 _playerActivityDelay; // Player activity delay counter
189
190 bool _examiningMenuIcon;
191
192 // Set by checkMouseList()
193 uint32 _mouseTouching;
194 uint32 _oldMouseTouching;
195
196 bool _objectLabels;
197
198 uint32 _menuSelectedPos;
199
200 void decompressMouse(byte *decomp, byte *comp, uint8 frame, int width, int height, int pitch, int xOff = 0, int yOff = 0);
201
202 int32 setMouseAnim(byte *ma, int32 size, int32 mouseFlash);
203 int32 setLuggageAnim(byte *la, int32 size);
204
205 void clearIconArea(int menu, int pocket, Common::Rect *r);
206
207public:
208 Mouse(Sword2Engine *vm);
209 ~Mouse();
210
211 void getPos(int &x, int &y);
212 int getX();
213 int getY();
214
215 bool getObjectLabels() { return _objectLabels; }
216 void setObjectLabels(bool b) { _objectLabels = b; }
217
218 bool getMouseStatus() { return _mouseStatus; }
219 uint32 getMouseTouching() { return _mouseTouching; }
220 void setMouseTouching(uint32 touching) { _mouseTouching = touching; }
221
222 void pauseEngine(bool pause);
223
224 void setMouse(uint32 res);
225 void setLuggage(uint32 res);
226
227 void setObjectHeld(uint32 res);
228
229 void resetMouseList();
230
231 void registerMouse(byte *ob_mouse, BuildUnit *build_unit);
232 void registerPointerText(int32 text_id);
233
234 void createPointerText(uint32 text_id, uint32 pointer_res);
235 void clearPointerText();
236
237 void drawMouse();
238 int32 animateMouse();
239
240 void processMenu();
241
242 void addMenuObject(byte *ptr);
243 void addSubject(int32 id, int32 ref);
244
245 void buildMenu();
246 void buildSystemMenu();
247
248 int32 showMenu(uint8 menu);
249 int32 hideMenu(uint8 menu);
250 int32 setMenuIcon(uint8 menu, uint8 pocket, byte *icon);
251
252 void closeMenuImmediately();
253
254 void refreshInventory();
255
256 void startConversation();
257 void endConversation();
258
259 void hideMouse();
260 void noHuman();
261 void addHuman();
262
263 void resetPlayerActivityDelay() { _playerActivityDelay = 0; }
264 void monitorPlayerActivity();
265 void checkPlayerActivity(uint32 seconds);
266
267 void mouseOnOff();
268 uint32 checkMouseList();
269 void mouseEngine();
270
271 void normalMouse();
272 void menuMouse();
273 void dragMouse();
274 void systemMenuMouse();
275
276 bool isChoosing() { return _choosing; }
277 uint32 chooseMouse();
278
279 int menuClick(int menu_items);
280
281 int getMouseMode();
282
283 void setMouseMode(int mouseMode); // Used to force mouse mode
284};
285
286} // End of namespace Sword2
287
288#endif
Definition: mouse.h:136
Definition: sword2.h:99
Definition: animation.h:37
Definition: rect.h:536
Definition: screen.h:108
Definition: mouse.h:130
Definition: mouse.h:77
Definition: mouse.h:95
Definition: mouse.h:123