ScummVM API documentation
messages.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 NGI_MESSAGEQUEUE_H
23 #define NGI_MESSAGEQUEUE_H
24 
25 #include "ngi/utils.h"
26 #include "ngi/inventory.h"
27 #include "ngi/gfx.h"
28 #include "ngi/sound.h"
29 #include "ngi/scene.h"
30 
31 namespace NGI {
32 
33 enum QueueFlags {
34  kInGlobalQueue = 2
35 };
36 
37 class Message : public CObject {
38  public:
39  int _messageKind;
40  int16 _parentId;
41  int _x;
42  int _y;
43  int _z;
44  int _sceneClickX;
45  int _sceneClickY;
46  int _invId;
47  int _field_24;
48  int _param;
49  int _field_2C;
50  int _field_30;
51  int _field_34;
52 
53  public:
54  Message();
55 
56  Message(int16 parentId, int messageKind, int x, int y, int a6, int a7, int sceneClickX, int sceneClickY, int a10);
57 };
58 
59 class ExCommand : public Message {
60  public:
61  int _messageNum;
62  int _field_3C;
63  int _excFlags;
64  int _parId;
65 
66  ExCommand();
67  ExCommand(ExCommand *src);
68  ExCommand(int16 parentId, int messageKind, int messageNum, int x, int y, int a7, int a8, int sceneClickX, int sceneClickY, int a11);
69  ~ExCommand() override {}
70 
71  bool load(MfcArchive &file) override;
72 
73  virtual ExCommand *createClone();
74 
75  bool handleMessage();
76  void sendMessage();
77  void postMessage();
78  void handle();
79 
80  void firef34();
81  void setf3c(int val);
82 };
83 
84 class ExCommand2 : public ExCommand {
85  public:
86  PointList _points;
87 
88  ExCommand2(int messageKind, int parentId, const PointList &points);
89  ExCommand2(ExCommand2 *src);
90 
91  ExCommand2 *createClone() override;
92 };
93 
94 class ObjstateCommand : public ExCommand {
95  public:
96  Common::String _objCommandName;
97  int _value;
98 
99  public:
100  ObjstateCommand();
102 
103  bool load(MfcArchive &file) override;
104 
105  ObjstateCommand *createClone() override;
106 };
107 
108 class MessageQueue : public CObject {
109  public:
110  int _id;
111  int _flags;
112  Common::String _queueName;
113  int16 _dataId;
114  CObject *_field_14;
115  int _counter;
116  int _field_38;
117  int _isFinished;
118  int _parId;
119  int _flag1;
120 
121  private:
122  Common::List<ExCommand *> _exCommands;
123 
124  public:
125  MessageQueue();
126  MessageQueue(int dataId);
127  MessageQueue(MessageQueue *src, int parId, int field_38);
128  ~MessageQueue() override;
129 
130  bool load(MfcArchive &file) override;
131 
132  int getFlags() { return _flags; }
133  void setFlags(int flags) { _flags = flags; }
134 
135  uint getCount() { return _exCommands.size(); }
136 
137  void addExCommand(ExCommand *ex);
138  void addExCommandToEnd(ExCommand *ex);
139  void insertExCommandAt(int pos, ExCommand *ex);
140  ExCommand *getExCommandByIndex(uint idx);
141  void deleteExCommandByIndex(uint idx, bool doFree);
142 
143  void mergeQueue(MessageQueue *mq);
144 
145  void setParamInt(int key1, int key2);
146 
148  bool chain(StaticANIObject *ani);
149  void update();
150  void sendNextCommand();
151  void finish();
152 
153  void messageQueueCallback1(int par);
154 
155  bool checkGlobalExCommandList1();
156  bool checkGlobalExCommandList2();
157 
158  int calcDuration(StaticANIObject *obj);
159  void changeParam28ForObjectId(int objId, int oldParam28, int newParam28);
160 
161  int activateExCommandsByKind(int kind);
162 };
163 
164 class GlobalMessageQueueList : public Common::Array<MessageQueue *> {
165 public:
166  MessageQueue *getMessageQueueById(int id);
167  void deleteQueueById(int id);
168  void removeQueueById(int id);
169  void disableQueueById(int id);
171  void addMessageQueue(MessageQueue *msg);
172  void clear();
173 
174  int compact();
175 };
176 
178  int (*callback)(ExCommand *cmd);
179  int16 id;
180  int16 field_6;
181  int index;
182  MessageHandler *nextItem;
183 };
184 
185 bool removeMessageHandler(int16 id, int pos);
186 void updateMessageHandlerIndex(MessageHandler *msg, int offset);
187 void addMessageHandler(int (*callback)(ExCommand *), int16 id);
188 MessageHandler *getMessageHandlerById(int16 id);
189 bool allocMessageHandler(MessageHandler *where, int16 id, int (*callback)(ExCommand *), int index);
190 int getMessageHandlersCount();
191 bool addMessageHandlerByIndex(int (*callback)(ExCommand *), int index, int16 id);
192 bool insertMessageHandler(int (*callback)(ExCommand *), int index, int16 id);
193 void clearMessageHandlers();
194 void processMessages();
195 void updateGlobalMessageQueue(int id, int objid);
196 void clearMessages();
197 void clearGlobalMessageQueueList();
198 void clearGlobalMessageQueueList1();
199 
200 bool chainQueue(int queueId, int flags);
201 bool chainObjQueue(StaticANIObject *obj, int queueId, int flags);
202 void postExCommand(int parentId, int keyCode, int x, int y, int f20, int f16);
203 
204 } // End of namespace NGI
205 
206 #endif /* NGI_MESSAGEQUEUE_H */
Definition: messages.h:177
Definition: str.h:59
Definition: utils.h:39
Definition: list.h:44
size_type size() const
Definition: list.h:197
Definition: messages.h:108
Definition: messages.h:37
Definition: messages.h:164
Definition: statics.h:172
Definition: messages.h:59
Definition: anihandler.h:25
Definition: messages.h:84
Definition: utils.h:106
Definition: messages.h:94