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/nebular/core/assets.h"
29 #include "mads/nebular/core/sprites.h"
30 
31 namespace MADS {
32 namespace Nebular {
33 
34 enum CursorType {
35  CURSOR_NONE = 0, CURSOR_ARROW = 1, CURSOR_WAIT = 2, CURSOR_GO_DOWN = 3,
36  CURSOR_GO_UP = 4, CURSOR_GO_LEFT = 5, CURSOR_GO_RIGHT = 6
37 };
38 
39 #define GAME_FRAME_RATE 50
40 #define GAME_FRAME_TIME (1000 / GAME_FRAME_RATE)
41 
42 class RexNebularEngine;
43 
44 class EventTarget {
45 public:
46  virtual ~EventTarget() {
47  }
48  virtual bool onEvent(Common::Event &event) {
49  return false;
50  }
51 };
52 
54 private:
55  RexNebularEngine *_vm;
56  uint32 _frameCounter;
57  uint32 _priorFrameTime;
58  Common::Point _mousePos;
59  Common::Point _currentPos;
60  EventTarget *_eventTarget;
61 
65  void changeCursor();
66 public:
67  SpriteAsset *_cursorSprites;
68  CursorType _cursorId;
69  CursorType _newCursorId;
70  bool _mouseClicked;
71  bool _mouseReleased;
72  byte _mouseButtons;
73  bool _rightMousePressed;
74  int _mouseStatus;
75  int _strokeGoing;
76  int _mouseStatusCopy;
77  bool _mouseMoved;
80 public:
85 
89  ~EventsManager();
90 
94  void loadCursors(const Common::Path &spritesName);
95 
99  void setCursor(CursorType cursorId);
100 
104  void setCursor2(CursorType cursorId);
105 
109  void showCursor();
110 
114  void hideCursor();
115 
119  bool isCursorVisible();
120 
124  void waitCursor();
125 
129  void freeCursors();
130 
134  void pollEvents();
135 
139  void setEventTarget(EventTarget *target) {
140  _eventTarget = target;
141  }
142 
147  return _mousePos;
148  }
149 
154  return _currentPos;
155  }
156 
160  void delay(int amount);
161 
165  void waitForNextFrame();
166 
170  bool checkForNextFrameCounter();
171 
175  uint32 getFrameCounter() const {
176  return _frameCounter;
177  }
178 
179  void initVars();
180 
184  void clearEvents();
185 
189  bool isKeyPressed() const {
190  return !_pendingKeys.empty();
191  }
192 
196  bool isActionTriggered() const {
197  return !_pendingActions.empty();
198  }
199 
204  return _pendingKeys.pop();
205  }
206 
211  return _pendingActions.pop();
212  }
213 };
214 
215 } // namespace Nebular
216 } // namespace MADS
217 
218 #endif
void setEventTarget(EventTarget *target)
Definition: events.h:139
Definition: nebular.h:51
Common::Point currentPos() const
Definition: events.h:153
Definition: path.h:52
uint32 CustomEventType
Definition: events.h:204
Definition: events.h:44
Common::CustomEventType getAction()
Definition: events.h:210
bool isKeyPressed() const
Definition: events.h:189
uint32 getFrameCounter() const
Definition: events.h:175
bool isActionTriggered() const
Definition: events.h:196
Definition: events.h:210
Definition: rect.h:144
Common::KeyState getKey()
Definition: events.h:203
Common::Point mousePos() const
Definition: events.h:146
Definition: assets.h:63
Definition: keyboard.h:294
Definition: sound_manager.h:38
Definition: events.h:53