1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407
|
/* 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 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ULTIMA_SHARED_ENGINE_MESSAGES_H
#define ULTIMA_SHARED_ENGINE_MESSAGES_H
#include "common/keyboard.h"
#include "common/events.h"
#include "ultima/shared/core/rect.h"
#include "ultima/shared/core/base_object.h"
#include "ultima/shared/core/tree_item.h"
namespace Ultima {
namespace Shared {
enum MessageFlag {
MSGFLAG_SCAN = 1,
MSGFLAG_BREAK_IF_HANDLED = 2,
MSGFLAG_CLASS_DEF = 4
};
class CMessage;
namespace Gfx {
class VisualItem;
class TextInput;
class Popup;
}
#define MESSAGEDEF(theClass) \
static ClassDef type() { return ClassDef(#theClass, &CMessage::type); } \
virtual ClassDef getType() const { return type(); }
#define MESSAGEDEFP(theClass, baseClass) \
static ClassDef type() { return ClassDef(#theClass, &baseClass::type); } \
virtual ClassDef getType() const { return type(); }
#define MESSAGE0(NAME) \
class NAME: public CMessage { \
public: NAME() : CMessage() {} \
MESSAGEDEF(NAME); \
}
#define MESSAGE1(NAME, F1, N1, V1) \
class NAME: public CMessage { \
public: F1 _##N1; \
NAME(F1 N1 = V1) : CMessage(), _##N1(N1) {} \
MESSAGEDEF(NAME); \
}
#define MESSAGE2(NAME, F1, N1, V1, F2, N2, V2) \
class NAME: public CMessage { \
public: F1 _##N1; F2 _##N2; \
NAME(F1 N1 = V1, F2 N2 = V2) : CMessage(), _##N1(N1), _##N2(N2) {} \
MESSAGEDEF(NAME); \
}
#define MESSAGE3(NAME, F1, N1, V1, F2, N2, V2, F3, N3, V3) \
class NAME: public CMessage { \
public: F1 _##N1; F2 _##N2; F3 _##N3; \
NAME(F1 N1 = V1, F2 N2 = V2, F3 N3 = V3) : CMessage(), _##N1(N1), _##N2(N2), _##N3(N3) {} \
MESSAGEDEF(NAME); \
}
#define MESSAGE4(NAME, F1, N1, V1, F2, N2, V2, F3, N3, V3, F4, N4, V4) \
class NAME: public CMessage { \
public: F1 _##N1; F2 _##N2; F3 _##N3; F4 _##N4; \
NAME(F1 N1 = V1, F2 N2 = V2, F3 N3 = V3, F4 N4 = V4) : CMessage(), _##N1(N1), _##N2(N2), _##N3(N3), _##N4(N4) {} \
MESSAGEDEF(NAME); \
}
/**
* Base class for all messages
*/
class CMessage : public BaseObject {
private:
/**
* Find a map entry that supports the given class
*/
static const MSGMAP_ENTRY *findMapEntry(const TreeItem *treeItem, const ClassDef &classDef);
public:
MESSAGEDEFP(CMessage, BaseObject);
CMessage();
/**
* Executes the message, passing it on to the designated target,
* and optionally it's children
*/
bool execute(TreeItem *target, const ClassDef *classDef = nullptr,
int flags = MSGFLAG_SCAN | MSGFLAG_BREAK_IF_HANDLED);
/**
* Executes the message, passing it on to the designated target,
* and optionally it's children
*/
bool execute(const Common::String &target, const ClassDef *classDef = nullptr,
int flags = MSGFLAG_SCAN | MSGFLAG_BREAK_IF_HANDLED);
/**
* Makes the passed item execute the message
*/
virtual bool perform(TreeItem *treeItem);
/**
* Returns true if the passed item supports the specified message class
*/
static bool supports(const TreeItem *treeItem, const ClassDef &classDef);
virtual bool isMouseMsg() const;
virtual bool isButtonDownMsg() const;
virtual bool isButtonUpMsg() const;
virtual bool isMouseMoveMsg() const;
virtual bool isDoubleClickMsg() const;
};
enum CMouseButton {
MB_LEFT = 1, MB_MIDDLE = 2, MB_RIGHT = 4
};
/**
* Base class for the different mouse notifications
*/
class CMouseMsg : public CMessage {
public:
int _buttons;
Point _mousePos;
public:
MESSAGEDEF(CMouseMsg);
CMouseMsg() : _buttons(0) {}
CMouseMsg(const Point &pt, int buttons) :
_mousePos(pt), _buttons(buttons) {}
};
/**
* Notifies a mouse movement
*
*/
class CMouseMoveMsg : public CMouseMsg {
public:
MESSAGEDEFP(CMouseMoveMsg, CMouseMsg);
CMouseMoveMsg() : CMouseMsg() {}
CMouseMoveMsg(const Point &pt, int buttons) : CMouseMsg(pt, buttons) {}
};
/**
* Notifies of a mouse drag operation
*/
class CMouseDragMsg : public CMouseMoveMsg {
public:
MESSAGEDEFP(CMouseDragMsg, CMouseMoveMsg);
CMouseDragMsg() : CMouseMoveMsg() {}
CMouseDragMsg(const Point &pt, int buttons) : CMouseMoveMsg(pt, buttons) {}
};
/**
* Base class for mouse button notifications
*/
class CMouseButtonMsg : public CMouseMsg {
public:
MESSAGEDEFP(CMouseButtonMsg, CMouseMsg);
CMouseButtonMsg() : CMouseMsg() {}
CMouseButtonMsg(const Point &pt, int buttons) : CMouseMsg(pt, buttons) {}
};
/**
* Notifies a mouse button down
*/
class CMouseButtonDownMsg : public CMouseButtonMsg {
public:
MESSAGEDEFP(CMouseButtonDownMsg, CMouseButtonMsg);
CMouseButtonDownMsg() : CMouseButtonMsg() {}
CMouseButtonDownMsg(const Point &pt, int buttons) : CMouseButtonMsg(pt, buttons) {}
};
/**
* Notifies a mouse button release
*/
class CMouseButtonUpMsg : public CMouseButtonMsg {
public:
MESSAGEDEFP(CMouseButtonUpMsg, CMouseButtonMsg);
CMouseButtonUpMsg() : CMouseButtonMsg() {}
CMouseButtonUpMsg(const Point &pt, int buttons) : CMouseButtonMsg(pt, buttons) {}
};
/**
* Notifies a mouse wheel action
*/
class CMouseWheelMsg : public CMouseMsg {
public:
bool _wheelUp;
public:
MESSAGEDEFP(CMouseWheelMsg, CMouseMsg);
CMouseWheelMsg() : CMouseMsg(), _wheelUp(false) {}
CMouseWheelMsg(const Point &pt, bool wheelUp) :
CMouseMsg(pt, 0), _wheelUp(wheelUp) {}
};
/**
* Notifies a mouse double-click
*/
class CMouseDoubleClickMsg : public CMouseButtonMsg {
public:
MESSAGEDEFP(CMouseDuobleClickMsg, CMouseButtonMsg);
CMouseDoubleClickMsg() : CMouseButtonMsg() {}
CMouseDoubleClickMsg(const Point &pt, int buttons) : CMouseButtonMsg(pt, buttons) {}
};
/**
* Used to notify that a rendering frame has finished, occurring at GAME_FRAME_RATE times every second
*/
MESSAGE1(CFrameMsg, uint, ticks, 0);
/**
* Notifies a game view is being hidden
*/
MESSAGE2(CHideMsg, Gfx::VisualItem *, view, (Gfx::VisualItem *)nullptr, bool, fadeOut, false);
/**
* Show a prompt in the info area, and get a keypress for a command
*/
MESSAGE1(CInfoGetCommandKeypress, TreeItem *, responder, (TreeItem *)nullptr);
/**
* Get a keypress in the info area
*/
MESSAGE1(CInfoGetKeypress, TreeItem *, responder, (TreeItem *)nullptr);
/**
* Get a text input in the input area
*/
MESSAGE3(CInfoGetInput, TreeItem *, responder, (TreeItem *)nullptr, bool, isNumeric, false, size_t, maxCharacters, 10);
/**
* Adds text strings to the info area
*/
MESSAGE3(CInfoMsg, Common::String, text, "", bool, newLine, true, bool, replaceLine, false);
/**
* Signals an unknown/unhandled keypress
*/
MESSAGE0(CHuhMsg);
/**
* Signals a single standard ASCII keypress
*/
MESSAGE1(CKeyCharMsg, int, key, 32);
/**
* Signals a keypress
*/
MESSAGE1(CKeypressMsg, Common::KeyState, keyState, Common::KeyState());
/**
* Called when a popup is finally shown
*/
MESSAGE1(CPopupShownMsg, Gfx::Popup *, view, (Gfx::Popup *)nullptr);
/**
* Called when a popup is hidden
*/
MESSAGE1(CPopupHiddenMsg, Gfx::Popup *, view, (Gfx::Popup *)nullptr);
/**
* Called when a game view is shown
*/
MESSAGE2(CShowMsg, Gfx::VisualItem *, view, (Gfx::VisualItem *)nullptr, bool, fadeIn, false);
/**
* Used when text input is finished, to pass the text back to the owning view
*/
MESSAGE2(CTextInputMsg, Common::String, text, "", bool, escaped, false);
/**
* Used when character input is finished, to pass the text back to the owning view
*/
MESSAGE1(CCharacterInputMsg, Common::KeyState, keyState, Common::KeyState());
/*-------------------------------------------------------------------*/
/**
* Used to trigger a party movement
*/
MESSAGE1(CMoveMsg, int, direction, 0);
/**
* Used to trigger an attack
*/
MESSAGE1(CAttackMsg, int, direction, 0);
/**
* Used to trigger a board action
*/
MESSAGE0(CBoardMsg);
/**
* Used to trigger a cast action
*/
MESSAGE0(CCastMsg);
/**
* Climb up or down
*/
MESSAGE0(CClimbMsg);
/**
* Used to trigger a drop action
*/
MESSAGE0(CDropMsg);
/**
* Used to trigger an Enter action
*/
MESSAGE0(CEnterMsg);
/**
* Used to trigger an exit action
*/
MESSAGE0(CExitTransportMsg);
/**
* Used to trigger a fire action
*/
MESSAGE0(CFireMsg);
/**
* Used to trigger a Get action
*/
MESSAGE0(CGetMsg);
/**
* Used to trigger a HyperJump action
*/
MESSAGE0(CHyperJumpMsg);
/**
* Used to trigger an inform action
*/
MESSAGE0(CInformMsg);
/**
* Used to trigger an open action
*/
MESSAGE0(COpenMsg);
/**
* Pass a turn
*/
MESSAGE0(CPassMsg);
/**
* Used to trigger a quit (save) action
*/
MESSAGE0(CQuitMsg);
/**
* Used to trigger a ready item/weapon/spell action
*/
MESSAGE0(CReadyMsg);
/**
* Used to trigger a stats action
*/
MESSAGE0(CStatsMsg);
/**
* Used to trigger a steal action
*/
MESSAGE0(CStealMsg);
/**
* Used to trigger a Transact action
*/
MESSAGE0(CTransactMsg);
/**
* Used to trigger an Unlock action
*/
MESSAGE0(CUnlockMsg);
/**
* Used to trigger a view change action
*/
MESSAGE0(CViewChangeMsg);
/**
* Used to signal an end of turn
*/
MESSAGE0(CEndOfTurnMsg);
} // End of namespace Shared
} // End of namespace Ultima
#endif
|