diff options
author | Paul Gilbert | 2016-07-24 07:45:30 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-24 07:45:30 -0400 |
commit | fd316a60589f07ac75cfdf1b56188d9d464336bd (patch) | |
tree | 121938b97ee70db270755d721fadc6aa1c6a2db0 /engines | |
parent | f1344c2c277125e652092b94a0a5347f842c45d0 (diff) | |
download | scummvm-rg350-fd316a60589f07ac75cfdf1b56188d9d464336bd.tar.gz scummvm-rg350-fd316a60589f07ac75cfdf1b56188d9d464336bd.tar.bz2 scummvm-rg350-fd316a60589f07ac75cfdf1b56188d9d464336bd.zip |
TITANIC: Fleshed out various methods
Diffstat (limited to 'engines')
-rw-r--r-- | engines/titanic/game_state.cpp | 14 | ||||
-rw-r--r-- | engines/titanic/input_handler.cpp | 20 | ||||
-rw-r--r-- | engines/titanic/input_handler.h | 2 | ||||
-rw-r--r-- | engines/titanic/input_translator.cpp | 5 | ||||
-rw-r--r-- | engines/titanic/input_translator.h | 5 | ||||
-rw-r--r-- | engines/titanic/support/credit_text.cpp | 7 |
6 files changed, 40 insertions, 13 deletions
diff --git a/engines/titanic/game_state.cpp b/engines/titanic/game_state.cpp index 0f2ed1798e..5628161558 100644 --- a/engines/titanic/game_state.cpp +++ b/engines/titanic/game_state.cpp @@ -28,8 +28,18 @@ namespace Titanic { bool CGameStateMovieList::clear() { - // TODO - return false; + for (CGameStateMovieList::iterator i = begin(); i != end(); ) { + CMovieListItem *movieItem = *i; + + if (movieItem->_item->isActive()) { + ++i; + } else { + i = erase(i); + delete movieItem; + } + } + + return !empty(); } /*------------------------------------------------------------------------*/ diff --git a/engines/titanic/input_handler.cpp b/engines/titanic/input_handler.cpp index 395f55df6f..7c35a5d855 100644 --- a/engines/titanic/input_handler.cpp +++ b/engines/titanic/input_handler.cpp @@ -22,15 +22,17 @@ #include "titanic/input_handler.h" #include "titanic/game_manager.h" -#include "titanic/support/screen_manager.h" #include "titanic/titanic.h" +#include "titanic/messages/mouse_messages.h" #include "titanic/pet_control/pet_control.h" +#include "titanic/support/screen_manager.h" namespace Titanic { CInputHandler::CInputHandler(CGameManager *owner) : _gameManager(owner), _inputTranslator(nullptr), _dragging(false), - _buttonDown(false), _dragItem(nullptr), _lockCount(0), _field24(0) { + _buttonDown(false), _dragItem(nullptr), _lockCount(0), + _singleton(false) { CScreenManager::_screenManagerPtr->_inputHandler = this; } @@ -44,7 +46,13 @@ void CInputHandler::incLockCount() { void CInputHandler::decLockCount() { if (--_lockCount == 0 && _inputTranslator) { - warning("TODO"); + if (_dragging && !_inputTranslator->isMousePressed()) { + CMouseButtonUpMsg upMsg(_mousePos, MK_LBUTTON); + handleMessage(upMsg); + } + + _buttonDown = _inputTranslator->isMousePressed(); + _singleton = true; } } @@ -60,11 +68,11 @@ void CInputHandler::handleMessage(CMessage &msg, bool respectLock) { void CInputHandler::processMessage(CMessage *msg) { const CMouseMsg *mouseMsg = dynamic_cast<const CMouseMsg *>(msg); - _field24 = 0; + _singleton = false; dispatchMessage(msg); - if (_field24) { - _field24 = 0; + if (_singleton) { + _singleton = false; } else if (mouseMsg) { // Keep the game state mouse position up to date if (_mousePos != mouseMsg->_mousePos) { diff --git a/engines/titanic/input_handler.h b/engines/titanic/input_handler.h index 2d62127a11..7244ddc050 100644 --- a/engines/titanic/input_handler.h +++ b/engines/titanic/input_handler.h @@ -56,7 +56,7 @@ public: Point _dragStartPos; Point _mousePos; int _lockCount; - int _field24; + bool _singleton; public: CInputHandler(CGameManager *owner); diff --git a/engines/titanic/input_translator.cpp b/engines/titanic/input_translator.cpp index 571b6dfa14..ce272d152c 100644 --- a/engines/titanic/input_translator.cpp +++ b/engines/titanic/input_translator.cpp @@ -24,6 +24,7 @@ #include "titanic/input_translator.h" #include "titanic/events.h" #include "titanic/messages/mouse_messages.h" +#include "titanic/titanic.h" namespace Titanic { @@ -106,4 +107,8 @@ void CInputTranslator::keyDown(const Common::KeyState &keyState) { } } +bool CInputTranslator::isMousePressed() const { + return g_vm->_window->getSpecialButtons() & (MK_LBUTTON | MK_RBUTTON | MK_MBUTTON); +} + } // End of namespace Titanic diff --git a/engines/titanic/input_translator.h b/engines/titanic/input_translator.h index 7ca2a78699..d92157bccc 100644 --- a/engines/titanic/input_translator.h +++ b/engines/titanic/input_translator.h @@ -52,6 +52,11 @@ public: void rightButtonUp(int special, const Point &pt); void rightButtonDoubleClick(int special, const Point &pt); void keyDown(const Common::KeyState &keyState); + + /** + * Returns true if any mouse button is currently pressed + */ + bool isMousePressed() const; }; } // End of namespace Titanic diff --git a/engines/titanic/support/credit_text.cpp b/engines/titanic/support/credit_text.cpp index 1f12341e71..0e9715aaa6 100644 --- a/engines/titanic/support/credit_text.cpp +++ b/engines/titanic/support/credit_text.cpp @@ -78,7 +78,7 @@ void CCreditText::setup() { if (srcLine.empty()) break; - CCreditLine *line = new CCreditLine(srcLine, + line = new CCreditLine(srcLine, _screenManagerP->stringWidth(srcLine)); group->_lines.push_back(line); @@ -107,9 +107,8 @@ CString CCreditText::readLine(Common::SeekableReadStream *stream) { } if (c == '\r') { - c = stream->readByte(); - if (c != '\n') - stream->skip(-1); + // Read following '\n' + stream->readByte(); } return line; |