diff options
author | Paul Gilbert | 2017-08-06 11:58:06 -0400 |
---|---|---|
committer | Paul Gilbert | 2017-08-06 11:58:06 -0400 |
commit | 07e70d9896c0d2eb9c2b1c56becfa1483822a382 (patch) | |
tree | c280946cbce939f10f47705dfce71da153cd4b6e /engines/titanic/messages | |
parent | f5b335af100c84d2ad761548825548d6fe3be125 (diff) | |
download | scummvm-rg350-07e70d9896c0d2eb9c2b1c56becfa1483822a382.tar.gz scummvm-rg350-07e70d9896c0d2eb9c2b1c56becfa1483822a382.tar.bz2 scummvm-rg350-07e70d9896c0d2eb9c2b1c56becfa1483822a382.zip |
TITANIC: Create new CMovementMsg for new movement functionality
This also moves logic for detecting which movement is associated
with given keycodes and cursors to CMovementMsg and CLinkItem,
which are better suited to contain the logic
Diffstat (limited to 'engines/titanic/messages')
-rw-r--r-- | engines/titanic/messages/messages.cpp | 21 | ||||
-rw-r--r-- | engines/titanic/messages/messages.h | 26 |
2 files changed, 47 insertions, 0 deletions
diff --git a/engines/titanic/messages/messages.cpp b/engines/titanic/messages/messages.cpp index 331d580dee..83c09688c4 100644 --- a/engines/titanic/messages/messages.cpp +++ b/engines/titanic/messages/messages.cpp @@ -177,4 +177,25 @@ CShowTextMsg::CShowTextMsg(StringId stringId) : CMessage() { _message = g_vm->_strings[stringId]; } +/*------------------------------------------------------------------------*/ + +Movement CMovementMsg::getMovement(Common::KeyCode keycode) { + switch (keycode) { + case Common::KEYCODE_LEFT: + case Common::KEYCODE_KP4: + return TURN_LEFT; + case Common::KEYCODE_RIGHT: + case Common::KEYCODE_KP6: + return TURN_RIGHT; + case Common::KEYCODE_UP: + case Common::KEYCODE_KP8: + return MOVE_FORWARDS; + case Common::KEYCODE_DOWN: + case Common::KEYCODE_KP2: + return MOVE_BACKWARDS; + default: + return MOVE_NONE; + } +} + } // End of namespace Titanic diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h index 8f8c785e43..b5c8dd4e21 100644 --- a/engines/titanic/messages/messages.h +++ b/engines/titanic/messages/messages.h @@ -222,6 +222,32 @@ enum MissiveOMatAction { MESSAGE_STARTUP = 9 }; +enum Movement { + MOVE_NONE = 0, MOVE_FORWARDS, MOVE_BACKWARDS, TURN_LEFT, TURN_RIGHT +}; + + +class CMovementMsg : public CMessage { +public: + Movement _movement; +public: + CLASSDEF; + CMovementMsg() : _movement(MOVE_NONE) {} + CMovementMsg(Movement move) : _movement(move) {} + CMovementMsg(Common::KeyCode key) : + _movement(getMovement(key)) {} + + static bool isSupportedBy(const CTreeItem *item) { + return supports(item, _type); + } + + /** + * Returns the movement associated with a given key, if any + */ + static Movement getMovement(Common::KeyCode keycode); +}; + + MESSAGE1(CActMsg, CString, action, ""); MESSAGE1(CActivationmsg, CString, value, ""); MESSAGE1(CAddHeadPieceMsg, CString, value, "NULL"); |