ScummVM API documentation
events.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 SHERLOCK_EVENTS_H
23 #define SHERLOCK_EVENTS_H
24 
25 #include "common/scummsys.h"
26 #include "common/events.h"
27 #include "common/queue.h"
28 #include "sherlock/image_file.h"
29 
30 namespace Sherlock {
31 
32 #define GAME_FRAME_RATE 30
33 #define GAME_FRAME_TIME (1000 / GAME_FRAME_RATE)
34 
35 enum CursorId { ARROW = 0, MAGNIFY = 1, WAIT = 2, EXIT_ZONES_START = 5, INVALID_CURSOR = -1 };
36 
37 class SherlockEngine;
38 
39 class Events {
40 private:
41  SherlockEngine *_vm;
42  uint32 _frameCounter;
43  uint32 _priorFrameTime;
44  ImageFile *_cursorImages;
45  int _mouseButtons;
46  Common::Point _mousePos;
47  int _waitCounter;
48  uint _frameRate;
49 
53  bool checkForNextFrameCounter();
54 public:
55  CursorId _cursorId;
56  bool _pressed;
57  bool _released;
58  bool _rightPressed;
59  bool _rightReleased;
60  bool _oldButtons;
61  bool _oldRightButton;
62  bool _firstPress;
65  Common::Point _hotspotPos;
66 public:
68  ~Events();
69 
73  void loadCursors(const Common::Path &filename);
74 
78  void setCursor(CursorId cursorId);
79 
83  void setCursor(const Graphics::Surface &src, int hotspotX = 0, int hotspotY = 0);
84 
88  void setCursor(CursorId cursorId, const Common::Point &cursorPos, const Graphics::Surface &surface);
89 
93  void animateCursorIfNeeded();
94 
98  void showCursor();
99 
103  void hideCursor();
104 
108  CursorId getCursor() const;
109 
113  bool isCursorVisible() const;
114 
118  void pollEvents();
119 
124  void pollEventsAndWait();
125 
129  void warpMouse(const Common::Point &pt);
130 
134  void warpMouse();
135 
139  Common::Point screenMousePos() const { return _mousePos; }
140 
144  Common::Point mousePos() const;
145 
149  void setFrameRate(int newRate);
150 
154  void toggleSpeed();
155 
159  uint32 getFrameCounter() const { return _frameCounter; }
160 
164  bool kbHit() const { return !_pendingKeys.empty(); }
165 
169  bool actionHit() const { return !_pendingActions.empty(); }
170 
175 
180 
184  void clearEvents();
185 
189  void clearKeyboard();
190 
194  void clearActions();
195 
199  void wait(int numFrames);
200 
204  bool delay(uint32 time, bool interruptable = false);
205 
212  void setButtonState();
213 
217  bool checkInput();
218 
222  void incWaitCounter();
223 
227  void decWaitCounter();
228 };
229 
230 } // End of namespace Sherlock
231 
232 #endif /* SHERLOCK_EVENTS_H */
bool isCursorVisible() const
Common::CustomEventType getAction()
Definition: surface.h:67
Definition: events.h:39
bool actionHit() const
Definition: events.h:169
uint32 getFrameCounter() const
Definition: events.h:159
Definition: animation.h:29
void setCursor(CursorId cursorId)
Definition: path.h:52
uint32 CustomEventType
Definition: events.h:204
void setFrameRate(int newRate)
CursorId getCursor() const
void loadCursors(const Common::Path &filename)
bool delay(uint32 time, bool interruptable=false)
void animateCursorIfNeeded()
bool kbHit() const
Definition: events.h:164
void pollEventsAndWait()
Definition: sherlock.h:206
Common::Point screenMousePos() const
Definition: events.h:139
Definition: rect.h:144
Definition: keyboard.h:294
Common::KeyState getKey()
Definition: image_file.h:78
Common::Point mousePos() const
void wait(int numFrames)