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 LASTEXPRESS_EVENTS_H
23 #define LASTEXPRESS_EVENTS_H
24 
25 #include "lastexpress/lastexpress.h"
26 
27 namespace LastExpress {
28 
29 class LastExpressEngine;
30 class LogicManager;
31 
32 struct ConsCallParam {
33  ConsCallParam() : intParam(0), stringParam(nullptr) {}
34 
35  template<typename T>
36  ConsCallParam(T param) : intParam(static_cast<int32>(param)), stringParam(nullptr) {}
37 
38  ConsCallParam(const char *param) : intParam(0), stringParam(param) {}
39  ConsCallParam(char *param) : intParam(0), stringParam(param) {}
40 
41  int32 intParam;
42  const char *stringParam;
43 };
44 
45 typedef struct Message {
46  int receiver;
47  int action;
48  int sender;
49  ConsCallParam param;
50 
51  Message() {
52  clear();
53  }
54 
55  void clear() {
56  receiver = 0;
57  action = 0;
58  sender = 0;
59  }
60 } Message;
61 
62 typedef struct Event {
63  int channel;
64  int x;
65  int y;
66  int flags;
67 
68  Event() {
69  channel = 0;
70  x = 0;
71  y = 0;
72  flags = 0;
73  }
74 } Event;
75 
77  friend class LastExpressEngine;
78  friend class LogicManager;
79  friend class MemoryManager;
80 
81 public:
83  ~MessageManager();
84 
85  void setMessageHandle(int handleChannel, void (LogicManager::*handle)(Message *));
86  void (LogicManager::*getMessageHandle(int handleChannel))(Message *);
87  void setEventHandle(int handleChannel, void (LastExpressEngine::*handle)(Event *));
88  void (LastExpressEngine::*getEventHandle(int handleChannel))(Event *);
89  void addEvent(int channel, int x, int y, int flags);
90  Event *getEvent();
91  void addMessage(int receiver, int actionId, int sender, ConsCallParam param);
92  Message *getMessage();
93  bool process();
94  void flush();
95  void flushTime();
96  void forceMessage(Message *msg);
97  void clearMessageQueue();
98  void clearEventQueue();
99  void clearClickEvents();
100  void saveMessages(CVCRFile *file);
101  void loadMessages(CVCRFile *file);
102 
103 private:
104  LastExpressEngine *_engine = nullptr;
105 
106  Message _messages[128];
107  Message _emptyMessage;
108  void (LogicManager::*_messageHandles[40])(Message *);
109  int _curMsgIndex = 0;
110  int _numMsgsInQueue = 0;
111  int _nextMsgIndex = 0;
112  Message *_autoMessages = nullptr;
113 
114  Event _events[128];
115  void (LastExpressEngine::*_eventHandles[16])(Event *);
116  int _doubleClickMaxFrames = 30;
117  int _latestTickLeftMousePressed = 0;
118  int _lastEventIndex = 128;
119  int _curEventIndex = 0;
120  int _numEventsInQueue = 0;
121  int _nextEventIndex = 0;
122  bool _systemEventRightMouseDown = false;
123  bool _systemEventLeftMouseDown = false;
124 };
125 
126 } // End of namespace LastExpress
127 
128 #endif // LASTEXPRESS_EVENTS_H
Definition: events.h:32
Definition: cvcrfile.h:61
Definition: lastexpress.h:523
Definition: archive.h:29
Definition: events.h:76
Definition: memory.h:63
Definition: events.h:45
Definition: events.h:62
Definition: logic.h:51