2013-07-20 16:08:05 +03:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2014-02-18 02:34:20 +01:00
|
|
|
*
|
2013-07-20 16:08:05 +03:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2014-02-18 02:34:20 +01:00
|
|
|
*
|
2013-07-20 16:08:05 +03:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-10-04 00:02:37 +02:00
|
|
|
#ifndef NGI_MESSAGEQUEUE_H
|
|
|
|
#define NGI_MESSAGEQUEUE_H
|
2013-07-20 16:08:05 +03:00
|
|
|
|
2020-10-03 23:47:47 +02:00
|
|
|
#include "ngi/utils.h"
|
|
|
|
#include "ngi/inventory.h"
|
|
|
|
#include "ngi/gfx.h"
|
|
|
|
#include "ngi/sound.h"
|
|
|
|
#include "ngi/scene.h"
|
2013-07-20 16:08:05 +03:00
|
|
|
|
2020-10-03 23:55:39 +02:00
|
|
|
namespace NGI {
|
2013-07-20 16:08:05 +03:00
|
|
|
|
2017-11-14 20:50:13 -06:00
|
|
|
enum QueueFlags {
|
|
|
|
kInGlobalQueue = 2
|
|
|
|
};
|
|
|
|
|
2013-07-26 15:47:12 +03:00
|
|
|
class Message : public CObject {
|
|
|
|
public:
|
|
|
|
int _messageKind;
|
|
|
|
int16 _parentId;
|
|
|
|
int _x;
|
|
|
|
int _y;
|
2017-12-03 20:07:35 +01:00
|
|
|
int _z;
|
2013-07-26 15:47:12 +03:00
|
|
|
int _sceneClickX;
|
|
|
|
int _sceneClickY;
|
2020-09-15 11:27:52 +02:00
|
|
|
int _invId;
|
2013-07-26 15:47:12 +03:00
|
|
|
int _field_24;
|
2016-09-04 23:54:43 +02:00
|
|
|
int _param;
|
2013-07-26 15:47:12 +03:00
|
|
|
int _field_2C;
|
|
|
|
int _field_30;
|
|
|
|
int _field_34;
|
|
|
|
|
|
|
|
public:
|
|
|
|
Message();
|
2013-08-10 23:41:38 +03:00
|
|
|
|
2013-07-29 22:16:14 +03:00
|
|
|
Message(int16 parentId, int messageKind, int x, int y, int a6, int a7, int sceneClickX, int sceneClickY, int a10);
|
2013-07-26 15:47:12 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
class ExCommand : public Message {
|
2013-08-07 00:43:08 +03:00
|
|
|
public:
|
2013-07-26 15:47:12 +03:00
|
|
|
int _messageNum;
|
|
|
|
int _field_3C;
|
|
|
|
int _excFlags;
|
|
|
|
int _parId;
|
|
|
|
|
|
|
|
ExCommand();
|
|
|
|
ExCommand(ExCommand *src);
|
2013-07-29 22:16:14 +03:00
|
|
|
ExCommand(int16 parentId, int messageKind, int messageNum, int x, int y, int a7, int a8, int sceneClickX, int sceneClickY, int a11);
|
2020-02-09 12:05:28 +01:00
|
|
|
~ExCommand() override {}
|
2013-07-26 15:47:12 +03:00
|
|
|
|
2020-02-09 12:05:28 +01:00
|
|
|
bool load(MfcArchive &file) override;
|
2013-07-31 20:06:13 +03:00
|
|
|
|
2014-01-04 17:06:23 +02:00
|
|
|
virtual ExCommand *createClone();
|
2014-01-04 15:01:27 +02:00
|
|
|
|
2013-08-02 02:04:03 +03:00
|
|
|
bool handleMessage();
|
2013-08-03 00:26:34 +03:00
|
|
|
void sendMessage();
|
2013-08-11 17:18:42 +03:00
|
|
|
void postMessage();
|
2013-08-09 01:19:57 +03:00
|
|
|
void handle();
|
2014-01-04 15:01:27 +02:00
|
|
|
|
|
|
|
void firef34();
|
|
|
|
void setf3c(int val);
|
2013-07-26 15:47:12 +03:00
|
|
|
};
|
|
|
|
|
2013-08-11 22:47:46 +03:00
|
|
|
class ExCommand2 : public ExCommand {
|
|
|
|
public:
|
2017-11-16 10:31:59 -06:00
|
|
|
PointList _points;
|
2014-01-04 15:01:27 +02:00
|
|
|
|
2017-11-16 10:31:59 -06:00
|
|
|
ExCommand2(int messageKind, int parentId, const PointList &points);
|
2014-01-04 15:01:27 +02:00
|
|
|
ExCommand2(ExCommand2 *src);
|
|
|
|
|
2020-02-09 12:05:28 +01:00
|
|
|
ExCommand2 *createClone() override;
|
2013-08-11 22:47:46 +03:00
|
|
|
};
|
|
|
|
|
2014-01-08 11:35:23 +02:00
|
|
|
class ObjstateCommand : public ExCommand {
|
2013-08-26 22:17:20 +03:00
|
|
|
public:
|
2016-12-20 02:17:58 +02:00
|
|
|
Common::String _objCommandName;
|
2013-07-26 15:47:12 +03:00
|
|
|
int _value;
|
|
|
|
|
|
|
|
public:
|
2013-09-18 19:28:44 +04:00
|
|
|
ObjstateCommand();
|
2014-01-08 15:26:19 +02:00
|
|
|
ObjstateCommand(ObjstateCommand *src);
|
2014-01-08 11:35:23 +02:00
|
|
|
|
2020-02-09 12:05:28 +01:00
|
|
|
bool load(MfcArchive &file) override;
|
2014-01-08 11:35:23 +02:00
|
|
|
|
2020-02-09 12:05:28 +01:00
|
|
|
ObjstateCommand *createClone() override;
|
2013-07-26 15:47:12 +03:00
|
|
|
};
|
|
|
|
|
2013-07-20 16:08:05 +03:00
|
|
|
class MessageQueue : public CObject {
|
2013-08-10 23:41:38 +03:00
|
|
|
public:
|
2013-07-20 16:08:05 +03:00
|
|
|
int _id;
|
|
|
|
int _flags;
|
2016-12-20 02:17:58 +02:00
|
|
|
Common::String _queueName;
|
2013-07-20 16:08:05 +03:00
|
|
|
int16 _dataId;
|
2013-08-10 23:41:38 +03:00
|
|
|
CObject *_field_14;
|
2013-07-20 16:08:05 +03:00
|
|
|
int _counter;
|
|
|
|
int _field_38;
|
|
|
|
int _isFinished;
|
|
|
|
int _parId;
|
|
|
|
int _flag1;
|
|
|
|
|
2013-12-11 22:51:49 +02:00
|
|
|
private:
|
|
|
|
Common::List<ExCommand *> _exCommands;
|
|
|
|
|
2013-07-20 16:08:05 +03:00
|
|
|
public:
|
|
|
|
MessageQueue();
|
2013-11-17 12:19:25 +02:00
|
|
|
MessageQueue(int dataId);
|
2013-07-29 22:16:14 +03:00
|
|
|
MessageQueue(MessageQueue *src, int parId, int field_38);
|
2020-02-09 12:05:28 +01:00
|
|
|
~MessageQueue() override;
|
2013-08-10 23:41:38 +03:00
|
|
|
|
2020-02-09 12:05:28 +01:00
|
|
|
bool load(MfcArchive &file) override;
|
2013-07-20 16:08:05 +03:00
|
|
|
|
|
|
|
int getFlags() { return _flags; }
|
2013-07-29 22:16:14 +03:00
|
|
|
void setFlags(int flags) { _flags = flags; }
|
|
|
|
|
2013-08-10 23:41:38 +03:00
|
|
|
uint getCount() { return _exCommands.size(); }
|
|
|
|
|
2013-10-17 00:35:02 +03:00
|
|
|
void addExCommand(ExCommand *ex);
|
2013-12-11 22:51:49 +02:00
|
|
|
void addExCommandToEnd(ExCommand *ex);
|
2014-01-01 15:27:30 +02:00
|
|
|
void insertExCommandAt(int pos, ExCommand *ex);
|
2013-08-10 23:41:38 +03:00
|
|
|
ExCommand *getExCommandByIndex(uint idx);
|
2013-10-17 00:35:02 +03:00
|
|
|
void deleteExCommandByIndex(uint idx, bool doFree);
|
2013-08-10 23:41:38 +03:00
|
|
|
|
2016-08-14 21:24:51 +02:00
|
|
|
void mergeQueue(MessageQueue *mq);
|
2013-10-24 01:08:24 +03:00
|
|
|
|
2016-09-04 23:54:43 +02:00
|
|
|
void setParamInt(int key1, int key2);
|
2013-08-15 00:46:19 +03:00
|
|
|
|
2017-11-14 20:50:13 -06:00
|
|
|
/** `ani` will own `this` if `chain` returns true */
|
2013-07-29 22:16:14 +03:00
|
|
|
bool chain(StaticANIObject *ani);
|
2013-08-02 02:04:03 +03:00
|
|
|
void update();
|
|
|
|
void sendNextCommand();
|
|
|
|
void finish();
|
2013-08-03 00:26:34 +03:00
|
|
|
|
|
|
|
void messageQueueCallback1(int par);
|
2013-08-10 23:41:38 +03:00
|
|
|
|
|
|
|
bool checkGlobalExCommandList1();
|
|
|
|
bool checkGlobalExCommandList2();
|
2013-09-08 23:53:02 +03:00
|
|
|
|
|
|
|
int calcDuration(StaticANIObject *obj);
|
|
|
|
void changeParam28ForObjectId(int objId, int oldParam28, int newParam28);
|
2014-01-29 23:48:06 +02:00
|
|
|
|
|
|
|
int activateExCommandsByKind(int kind);
|
2013-07-20 16:08:05 +03:00
|
|
|
};
|
|
|
|
|
2013-09-06 15:36:02 +03:00
|
|
|
class GlobalMessageQueueList : public Common::Array<MessageQueue *> {
|
2017-11-17 10:37:26 -06:00
|
|
|
public:
|
2013-07-20 16:08:05 +03:00
|
|
|
MessageQueue *getMessageQueueById(int id);
|
|
|
|
void deleteQueueById(int id);
|
2013-08-10 23:41:38 +03:00
|
|
|
void removeQueueById(int id);
|
2013-07-20 16:08:05 +03:00
|
|
|
void disableQueueById(int id);
|
2017-11-14 20:50:13 -06:00
|
|
|
/** `msg` becomes owned by `this` */
|
2013-07-29 22:16:14 +03:00
|
|
|
void addMessageQueue(MessageQueue *msg);
|
2017-11-17 10:37:26 -06:00
|
|
|
void clear();
|
2013-07-29 22:16:14 +03:00
|
|
|
|
|
|
|
int compact();
|
2013-07-20 16:08:05 +03:00
|
|
|
};
|
|
|
|
|
2013-07-22 22:46:08 +03:00
|
|
|
struct MessageHandler {
|
|
|
|
int (*callback)(ExCommand *cmd);
|
|
|
|
int16 id;
|
|
|
|
int16 field_6;
|
|
|
|
int index;
|
|
|
|
MessageHandler *nextItem;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool removeMessageHandler(int16 id, int pos);
|
|
|
|
void updateMessageHandlerIndex(MessageHandler *msg, int offset);
|
2013-07-22 23:38:11 +03:00
|
|
|
void addMessageHandler(int (*callback)(ExCommand *), int16 id);
|
|
|
|
MessageHandler *getMessageHandlerById(int16 id);
|
|
|
|
bool allocMessageHandler(MessageHandler *where, int16 id, int (*callback)(ExCommand *), int index);
|
|
|
|
int getMessageHandlersCount();
|
|
|
|
bool addMessageHandlerByIndex(int (*callback)(ExCommand *), int index, int16 id);
|
|
|
|
bool insertMessageHandler(int (*callback)(ExCommand *), int index, int16 id);
|
|
|
|
void clearMessageHandlers();
|
2013-07-31 20:06:13 +03:00
|
|
|
void processMessages();
|
2013-08-10 02:32:00 +03:00
|
|
|
void updateGlobalMessageQueue(int id, int objid);
|
2014-01-12 11:12:45 +02:00
|
|
|
void clearMessages();
|
2014-04-26 12:08:37 +03:00
|
|
|
void clearGlobalMessageQueueList();
|
2013-09-12 22:47:45 +03:00
|
|
|
void clearGlobalMessageQueueList1();
|
2013-07-22 22:46:08 +03:00
|
|
|
|
2013-10-28 00:49:26 +02:00
|
|
|
bool chainQueue(int queueId, int flags);
|
2013-12-17 23:32:30 +02:00
|
|
|
bool chainObjQueue(StaticANIObject *obj, int queueId, int flags);
|
2013-12-12 15:15:39 +02:00
|
|
|
void postExCommand(int parentId, int keyCode, int x, int y, int f20, int f16);
|
2013-10-28 00:49:26 +02:00
|
|
|
|
2020-10-03 23:55:39 +02:00
|
|
|
} // End of namespace NGI
|
2013-07-20 16:08:05 +03:00
|
|
|
|
2020-10-04 00:02:37 +02:00
|
|
|
#endif /* NGI_MESSAGEQUEUE_H */
|