diff options
Diffstat (limited to 'engines/titanic/core')
-rw-r--r-- | engines/titanic/core/game_object.cpp | 101 | ||||
-rw-r--r-- | engines/titanic/core/game_object.h | 58 |
2 files changed, 145 insertions, 14 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp index 9c5f9db3b4..66417ac630 100644 --- a/engines/titanic/core/game_object.cpp +++ b/engines/titanic/core/game_object.cpp @@ -69,14 +69,18 @@ CGameObject::CGameObject(): CNamedItem() { _cursorId = CURSOR_ARROW; _initialFrame = 0; _frameNumber = -1; - _field90 = 0; - _field94 = 0; - _field98 = 0; + _text = nullptr; + _textBorder = _textBorderRight = 0; _field9C = 0; _surface = nullptr; _fieldB8 = 0; } +CGameObject::~CGameObject() { + delete _surface; + delete _text; +} + void CGameObject::save(SimpleFile *file, int indent) const { file->writeNumberLine(7, indent); error("TODO: CGameObject::save"); @@ -151,12 +155,12 @@ void CGameObject::draw(CScreenManager *screenManager) { } if (_field40) { - if (_field90) { - if (_bounds.intersects(getGameManager()->_bounds)) - warning("TODO: _field90(screenManager);"); - } - } - else { + // If a text object is defined, handle drawing it + if (_text && _bounds.intersects(getGameManager()->_bounds)) + _text->draw(screenManager); + + return; + } else { if (!_surface) { if (!_resource.empty()) { loadResource(_resource); @@ -185,8 +189,8 @@ void CGameObject::draw(CScreenManager *screenManager) { screenManager->blitFrom(SURFACE_BACKBUFFER, _surface, &destPos); } - if (_field90) - warning("TODO: sub_415f80(screenManager);"); + if (_text) + _text->draw(screenManager); } } } @@ -358,6 +362,21 @@ void CGameObject::loadFrame(int frameNumber) { makeDirty(); } +void CGameObject::playMovie(int v1, int v2) { + if (_surface && !_resource.empty()) { + loadResource(_resource); + _resource.clear(); + } + + if (_surface && _surface->loadIfReady()) { + if (_surface->_movie) { + disableMouse(); + _surface->_movie->play(_bounds, v1, v2); + enableMouse(); + } + } +} + void CGameObject::processClipList2() { for (CMovieClipList::iterator i = _clipList2.begin(); i != _clipList2.end(); ++i) (*i)->process(this); @@ -869,6 +888,66 @@ void CGameObject::surface39(int v1, int v2) { _surface->proc39(v1, v2); } +void CGameObject::setTextBorder(const CString &str, int border, int borderRight) { + if (!_text) + _text = new CPetText(); + _textBorder = border; + _textBorderRight = borderRight; + + _text->setText(str); + CScreenManager *screenManager = getGameManager()->setScreenManager(); + _text->scrollToTop(screenManager); +} + +void CGameObject::setTextHasBorders(bool hasBorders) { + if (!_text) + _text = new CPetText(); + + _text->setHasBorder(hasBorders); +} + +void CGameObject::setTextBounds() { + Rect rect = _bounds; + rect.grow(_textBorder); + rect.right -= _textBorderRight; + + _text->setBounds(rect); + makeDirty(); +} + +void CGameObject::setTextColor(byte r, byte g, byte b) { + if (!_text) + _text = new CPetText(); + + _text->setColor(r, g, b); +} + +void CGameObject::setTextFontNumber(int fontNumber) { + if (!_text) + _text = new CPetText(); + + _text->setFontNumber(fontNumber); +} + +int CGameObject::getTextWidth() const { + assert(_text); + return _text->getTextWidth(CScreenManager::_screenManagerPtr); +} + +CTextCursor *CGameObject::getTextCursor() const { + return CScreenManager::_screenManagerPtr->_textCursor; +} + +void CGameObject::scrollTextUp() { + if (_text) + _text->scrollUp(CScreenManager::_screenManagerPtr); +} + +void CGameObject::scrollTextDown() { + if (_text) + _text->scrollDown(CScreenManager::_screenManagerPtr); +} + void CGameObject::lockMouse() { CGameManager *gameMan = getGameManager(); gameMan->lockInputHandler(); diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h index 02168c9f00..145b81ee65 100644 --- a/engines/titanic/core/game_object.h +++ b/engines/titanic/core/game_object.h @@ -30,6 +30,7 @@ #include "titanic/core/movie_clip.h" #include "titanic/core/named_item.h" #include "titanic/pet_control/pet_section.h" +#include "titanic/pet_control/pet_text.h" namespace Titanic { @@ -87,9 +88,9 @@ protected: int _initialFrame; CMovieClipList _clipList2; int _frameNumber; - int _field90; - int _field94; - int _field98; + CPetText *_text; + uint _textBorder; + uint _textBorderRight; int _field9C; Common::Point _savedPos; CVideoSurface *_surface; @@ -289,6 +290,11 @@ protected: void sound8(bool flag) const; /** + * Plays a movie + */ + void playMovie(int v1, int v2); + + /** * Play an arbitrary clip */ void playClip(const CString &name, uint flags); @@ -441,6 +447,51 @@ protected: int stateGet24(); void surface39(int v1, int v2); + + /** + * Set up the text borders for the object + */ + void setTextBorder(const CString &str, int border = 0, int borderRight = 0); + + /** + * Sets whether the text will use borders + */ + void setTextHasBorders(bool hasBorders); + + /** + * Sets the bounds for a previously defined text area + */ + void setTextBounds(); + + /** + * Sets the color for the object's text + */ + void setTextColor(byte r, byte g, byte b); + + /** + * Sets the font number to use for text + */ + void setTextFontNumber(int fontNumber); + + /** + * Gets the width of the text contents + */ + int getTextWidth() const; + + /** + * Returns the text cursor + */ + CTextCursor *getTextCursor() const; + + /** + * Scroll text up + */ + void scrollTextUp(); + + /** + * Scroll text down + */ + void scrollTextDown(); public: bool _isMail; int _id; @@ -461,6 +512,7 @@ public: public: CLASSDEF CGameObject(); + ~CGameObject(); /** * Save the data for the class to file |