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;
64  Common::Point _hotspotPos;
65 public:
67  ~Events();
68 
72  void loadCursors(const Common::Path &filename);
73 
77  void setCursor(CursorId cursorId);
78 
82  void setCursor(const Graphics::Surface &src, int hotspotX = 0, int hotspotY = 0);
83 
87  void setCursor(CursorId cursorId, const Common::Point &cursorPos, const Graphics::Surface &surface);
88 
92  void animateCursorIfNeeded();
93 
97  void showCursor();
98 
102  void hideCursor();
103 
107  CursorId getCursor() const;
108 
112  bool isCursorVisible() const;
113 
117  void pollEvents();
118 
123  void pollEventsAndWait();
124 
128  void warpMouse(const Common::Point &pt);
129 
133  void warpMouse();
134 
138  Common::Point screenMousePos() const { return _mousePos; }
139 
143  Common::Point mousePos() const;
144 
148  void setFrameRate(int newRate);
149 
153  void toggleSpeed();
154 
158  uint32 getFrameCounter() const { return _frameCounter; }
159 
163  bool kbHit() const { return !_pendingKeys.empty(); }
164 
169 
173  void clearEvents();
174 
178  void clearKeyboard();
179 
183  void wait(int numFrames);
184 
188  bool delay(uint32 time, bool interruptable = false);
189 
196  void setButtonState();
197 
201  bool checkInput();
202 
206  void incWaitCounter();
207 
211  void decWaitCounter();
212 };
213 
214 } // End of namespace Sherlock
215 
216 #endif /* SHERLOCK_EVENTS_H */
bool isCursorVisible() const
Definition: surface.h:67
Definition: events.h:39
uint32 getFrameCounter() const
Definition: events.h:158
Definition: animation.h:29
void setCursor(CursorId cursorId)
Definition: path.h:52
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:163
void pollEventsAndWait()
Definition: sherlock.h:76
Common::Point screenMousePos() const
Definition: events.h:138
Definition: rect.h:45
Definition: keyboard.h:294
Common::KeyState getKey()
Definition: image_file.h:78
Common::Point mousePos() const
void wait(int numFrames)