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 MADS_EVENTS_H
23 #define MADS_EVENTS_H
24 
25 #include "common/scummsys.h"
26 #include "common/events.h"
27 #include "common/stack.h"
28 #include "mads/assets.h"
29 #include "mads/sprites.h"
30 
31 namespace MADS {
32 
33 enum CursorType { CURSOR_NONE = 0, CURSOR_ARROW = 1, CURSOR_WAIT = 2, CURSOR_GO_DOWN = 3,
34  CURSOR_GO_UP = 4, CURSOR_GO_LEFT = 5, CURSOR_GO_RIGHT = 6 };
35 
36 #define GAME_FRAME_RATE 50
37 #define GAME_FRAME_TIME (1000 / GAME_FRAME_RATE)
38 
39 class MADSEngine;
40 
41 class EventTarget {
42 public:
43  virtual ~EventTarget() {}
44  virtual bool onEvent(Common::Event &event) { return false; }
45 };
46 
48 private:
49  MADSEngine *_vm;
50  uint32 _frameCounter;
51  uint32 _priorFrameTime;
52  Common::Point _mousePos;
53  Common::Point _currentPos;
54  EventTarget *_eventTarget;
55 
59  void changeCursor();
60 public:
61  SpriteAsset *_cursorSprites;
62  CursorType _cursorId;
63  CursorType _newCursorId;
64  bool _mouseClicked;
65  bool _mouseReleased;
66  byte _mouseButtons;
67  bool _rightMousePressed;
68  int _mouseStatus;
69  int _strokeGoing;
70  int _mouseStatusCopy;
71  bool _mouseMoved;
74 public:
79 
83  ~EventsManager();
84 
88  void loadCursors(const Common::Path &spritesName);
89 
93  void setCursor(CursorType cursorId);
94 
98  void setCursor2(CursorType cursorId);
99 
103  void showCursor();
104 
108  void hideCursor();
109 
113  bool isCursorVisible();
114 
118  void waitCursor();
119 
123  void freeCursors();
124 
128  void pollEvents();
129 
133  void setEventTarget(EventTarget *target) { _eventTarget = target; }
134 
138  Common::Point mousePos() const { return _mousePos; }
139 
143  Common::Point currentPos() const { return _currentPos; }
144 
148  void delay(int amount);
149 
153  void waitForNextFrame();
154 
158  bool checkForNextFrameCounter();
159 
163  uint32 getFrameCounter() const { return _frameCounter; }
164 
165  void initVars();
166 
170  void clearEvents();
171 
175  bool isKeyPressed() const { return !_pendingKeys.empty(); }
176 
180  bool isActionTriggered() const { return !_pendingActions.empty(); }
181 
185  Common::KeyState getKey() { return _pendingKeys.pop(); }
186 
190  Common::CustomEventType getAction() { return _pendingActions.pop(); }
191 };
192 
193 } // End of namespace MADS
194 
195 #endif /* MADS_EVENTS_H */
Common::Point mousePos() const
Definition: events.h:138
Definition: events.h:41
uint32 getFrameCounter() const
Definition: events.h:163
Definition: events.h:47
void setEventTarget(EventTarget *target)
Definition: events.h:133
Definition: path.h:52
uint32 CustomEventType
Definition: events.h:193
bool isKeyPressed() const
Definition: events.h:175
bool isActionTriggered() const
Definition: events.h:180
Definition: events.h:199
Definition: rect.h:45
Common::Point currentPos() const
Definition: events.h:143
Definition: mads.h:87
Definition: assets.h:61
Definition: keyboard.h:294
Definition: action.h:28
Common::KeyState getKey()
Definition: events.h:185
Common::CustomEventType getAction()
Definition: events.h:190