diff options
author | Paul Gilbert | 2016-06-19 20:58:37 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-15 19:23:44 -0400 |
commit | f0889c17a46019b8b294a74d054d0c60e445190b (patch) | |
tree | d9ddfcb512eefb3bcca3307228464d27ce0c4027 /engines/titanic/core | |
parent | 2267c5eb4c5addecbf0012495f84ece6d6df835d (diff) | |
download | scummvm-rg350-f0889c17a46019b8b294a74d054d0c60e445190b.tar.gz scummvm-rg350-f0889c17a46019b8b294a74d054d0c60e445190b.tar.bz2 scummvm-rg350-f0889c17a46019b8b294a74d054d0c60e445190b.zip |
TITANIC: Implementing lots of cGameObject methods
Diffstat (limited to 'engines/titanic/core')
-rw-r--r-- | engines/titanic/core/game_object.cpp | 91 | ||||
-rw-r--r-- | engines/titanic/core/game_object.h | 41 | ||||
-rw-r--r-- | engines/titanic/core/mail_man.cpp | 17 | ||||
-rw-r--r-- | engines/titanic/core/mail_man.h | 9 |
4 files changed, 156 insertions, 2 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp index 2da7d79949..4a5dd9b065 100644 --- a/engines/titanic/core/game_object.cpp +++ b/engines/titanic/core/game_object.cpp @@ -343,7 +343,10 @@ void CGameObject::loadFrame(int frameNumber) { } void CGameObject::processClipList2() { - warning("CGameObject::processClipList2"); + for (CMovieClipList::iterator i = _clipList2.begin(); i != _clipList2.end(); ++i) + (*i)->process(this); + + _clipList2.destroyContents(); } void CGameObject::makeDirty(const Rect &r) { @@ -429,6 +432,17 @@ void CGameObject::playClip(uint startFrame, uint endFrame) { gameManager->playClip(clip, room, room); } +void CGameObject::playRandomClip(const char **names, uint flags) { + // Count size of array + int count = 0; + for (const char **p = names; *p; ++p) + ++count; + + // Play clip + const char *name = names[g_vm->getRandomNumber(count - 1)]; + playClip(name, flags); +} + void CGameObject::playMovie(uint flags) { _frameNumber = -1; if (!_surface && !_resource.empty()) { @@ -844,6 +858,11 @@ void CGameObject::dragMove(const Point &pt) { setPosition(Point(pt.x - _bounds.width() / 2, pt.y - _bounds.height() / 2)); } +Point CGameObject::getControid() const { + return Point(_bounds.left + _bounds.width() / 2, + _bounds.top + _bounds.height() / 2); +} + bool CGameObject::clipExistsByStart(const CString &name, int startFrame) const { return _clipList1.existsByStart(name, startFrame); } @@ -943,7 +962,75 @@ void CGameObject::createCredits() { _credits = new CCreditText(); CScreenManager *screenManager = getGameManager()->setScreenManager(); _credits->load(this, screenManager, _bounds); - +} + +void CGameObject::fn10(int v1, int v2, int v3) { + makeDirty(); + _field44 = v1; + _field48 = v2; + _field4C = v3; +} + +void CGameObject::setMovie14(int v) { + if (!_surface && !_resource.empty()) { + loadResource(_resource); + _resource.clear(); + } + + if (_surface && _surface->_movie) + _surface->_movie->_field14 = v; +} + +void CGameObject::movie38(int v1, int v2) { + if (_surface) + _surface->proc38(v1, v2); +} + +void CGameObject::movie38(int v1) { + if (_surface) + _surface->proc38(-1, v1); +} + +int CGameObject::getClipDuration(const CString &name, int frameRate) const { + CMovieClip *clip = _clipList1.findByName(name); + return clip ? (clip->_endFrame - clip->_startFrame) * 1000 / frameRate : 0; +} + +void CGameObject::petIncC0() { + getPetControl()->incC0(); +} + +void CGameObject::petDecC0() { + getPetControl()->decC0(); +} + +void CGameObject::setState1C(bool flag) { + getGameManager()->_gameState._field1C = flag; +} + +void CGameObject::mailFn10(int v) { + CMailMan *mailMan = getMailMan(); + if (mailMan) { + makeDirty(); + mailMan->fn10(this, v); + } +} + +void CGameObject::mailFn11(int v) { + CMailMan *mailMan = getMailMan(); + if (mailMan) { + makeDirty(); + mailMan->fn11(this, v); + } +} + +bool CGameObject::mailExists(int id) const { + return findMail(id) != nullptr; +} + +CGameObject *CGameObject::findMail(int id) const { + CMailMan *mailMan = getMailMan(); + return mailMan ? mailMan->findMail(id) : nullptr; } } // End of namespace Titanic diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h index 44e12319e4..01f15ceb85 100644 --- a/engines/titanic/core/game_object.h +++ b/engines/titanic/core/game_object.h @@ -276,6 +276,11 @@ protected: void dragMove(const Point &pt); /** + * Get the centre of the game object's bounds + */ + Point getControid() const; + + /** * Set the position of the object */ void setPosition(const Point &newPos); @@ -293,6 +298,11 @@ protected: void playClip(uint startFrame, uint endFrame); /** + * Play a clip randomly from a passed list of names + */ + void playRandomClip(const char **names, uint flags); + + /** * Return the current view/node/room as a single string */ CString getViewFullName() const; @@ -353,6 +363,37 @@ protected: * Set's the player's passenger class */ void setPassengerClass(int newClass); + + void setMovie14(int v); + + void movie38(int v1, int v2); + + void movie38(int v1); + + void fn10(int v1, int v2, int v3); + + /** + * Gets the duration of a specified clip in milliseconds + */ + int getClipDuration(const CString &name, int frameRate = 14) const; + + void petIncC0(); + void petDecC0(); + + void setState1C(bool flag); + + void mailFn10(int v); + void mailFn11(int v); + + /** + * Returns true if a mail with a specified Id exists + */ + bool mailExists(int id) const; + + /** + * Returns a specified mail, if one exists + */ + CGameObject *findMail(int id) const; public: int _field60; CursorId _cursorId; diff --git a/engines/titanic/core/mail_man.cpp b/engines/titanic/core/mail_man.cpp index cb959245b5..e96b697dff 100644 --- a/engines/titanic/core/mail_man.cpp +++ b/engines/titanic/core/mail_man.cpp @@ -47,4 +47,21 @@ CGameObject *CMailMan::getNextObject(CGameObject *prior) const { return static_cast<CGameObject *>(prior->getNextSibling()); } +void CMailMan::fn10(CGameObject *obj, int v) { + warning("TODO: CMailMan::fn10"); +} + +void CMailMan::fn11(CGameObject *obj, int v) { + warning("TODO: CMailMan::fn11"); +} + +CGameObject *CMailMan::findMail(int id) const { + for (CGameObject *obj = getFirstObject(); obj; obj = getNextObject(obj)) { + if (_field50 && _field54 == id) + return obj; + } + + return nullptr; +} + } // End of namespace Titanic diff --git a/engines/titanic/core/mail_man.h b/engines/titanic/core/mail_man.h index d1c84e2264..1a95729ff1 100644 --- a/engines/titanic/core/mail_man.h +++ b/engines/titanic/core/mail_man.h @@ -54,8 +54,17 @@ public: * the passed game object */ CGameObject *getNextObject(CGameObject *prior) const; + + void fn10(CGameObject *obj, int v); + void fn11(CGameObject *obj, int v); + + /** + * Scan the mail list for a specified item + */ + CGameObject *findMail(int id) const; }; + } // End of namespace Titanic #endif /* TITANIC_MAIL_MAN_H */ |