diff options
author | Paul Gilbert | 2016-03-24 21:02:25 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-03-24 21:02:25 -0400 |
commit | c948e8812ebb619f22adb7794da6dcfb6d5d6b9e (patch) | |
tree | 8b87bcb0ceb513dcdd810dde682bf9c550e71251 /engines/titanic | |
parent | fd78a874ccfdbc652241dc4402f6ca96ca188170 (diff) | |
download | scummvm-rg350-c948e8812ebb619f22adb7794da6dcfb6d5d6b9e.tar.gz scummvm-rg350-c948e8812ebb619f22adb7794da6dcfb6d5d6b9e.tar.bz2 scummvm-rg350-c948e8812ebb619f22adb7794da6dcfb6d5d6b9e.zip |
TITANIC: Support methods needed by CTelevision
Diffstat (limited to 'engines/titanic')
22 files changed, 299 insertions, 32 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp index 810e4396cb..a1fde3f74e 100644 --- a/engines/titanic/core/game_object.cpp +++ b/engines/titanic/core/game_object.cpp @@ -230,7 +230,13 @@ void CGameObject::loadImage(const CString &name, bool pendingFlag) { } void CGameObject::loadFrame(int frameNumber) { - warning("CGameObject::loadFrame"); + if (frameNumber != -1 && !_resource.empty()) + loadResource(_resource); + + if (_surface) + _surface->setMovieFrame(frameNumber); + + makeDirty(); } void CGameObject::processClipList2() { @@ -247,4 +253,33 @@ void CGameObject::makeDirty() { makeDirty(_bounds); } +bool CGameObject::soundFn1(int val) { + if (val != 0 && val != -1) { + CGameManager *gameManager = getGameManager(); + if (gameManager) + return gameManager->_sound.fn1(val); + } + + return false; +} + +void CGameObject::soundFn2(int val, int val2) { + if (val != 0 && val != -1) { + CGameManager *gameManager = getGameManager(); + if (gameManager) { + if (val2) + gameManager->_sound.fn3(val, 0, val2); + else + gameManager->_sound.fn2(val); + } + } +} + +void CGameObject::set5C(int val) { + if (val != _field5C) { + _field5C = val; + makeDirty(); + } +} + } // End of namespace Titanic diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h index 9d24f8eac1..88ea8414ed 100644 --- a/engines/titanic/core/game_object.h +++ b/engines/titanic/core/game_object.h @@ -93,6 +93,10 @@ protected: CVideoSurface *_surface; CString _resource; int _fieldB8; +protected: + bool soundFn1(int val); + void soundFn2(int val, int val2); + void set5C(int val); public: int _field60; CursorId _cursorId; diff --git a/engines/titanic/core/saveable_object.cpp b/engines/titanic/core/saveable_object.cpp index 1f7448f655..f7c715fd66 100644 --- a/engines/titanic/core/saveable_object.cpp +++ b/engines/titanic/core/saveable_object.cpp @@ -850,6 +850,11 @@ DEFFN(CPETSetStarDestinationMsg) DEFFN(CPETStarFieldLockMsg) DEFFN(CPETStereoFieldOnOffMsg) DEFFN(CPETTargetMsg) +DEFFN(CPETUpMsg) +DEFFN(CPETDownMsg) +DEFFN(CPETLeftMsg) +DEFFN(CPETRightMsg) +DEFFN(CPETActivateMsg) DEFFN(CPanningAwayFromParrotMsg) DEFFN(CParrotSpeakMsg) DEFFN(CParrotTriesChickenMsg) @@ -1427,6 +1432,11 @@ void CSaveableObject::initClassList() { ADDFN(CPETStarFieldLockMsg, CMessage); ADDFN(CPETStereoFieldOnOffMsg, CMessage); ADDFN(CPETTargetMsg, CMessage); + ADDFN(CPETUpMsg, CPETTargetMsg); + ADDFN(CPETDownMsg, CPETTargetMsg); + ADDFN(CPETLeftMsg, CPETTargetMsg); + ADDFN(CPETRightMsg, CPETTargetMsg); + ADDFN(CPETActivateMsg, CPETTargetMsg); ADDFN(CPanningAwayFromParrotMsg, CMessage); ADDFN(CParrotSpeakMsg, CMessage); ADDFN(CParrotTriesChickenMsg, CMessage); diff --git a/engines/titanic/core/tree_item.cpp b/engines/titanic/core/tree_item.cpp index a1dcce1abe..2c985bf34e 100644 --- a/engines/titanic/core/tree_item.cpp +++ b/engines/titanic/core/tree_item.cpp @@ -31,6 +31,8 @@ #include "titanic/core/project_item.h" #include "titanic/core/view_item.h" #include "titanic/core/room_item.h" +#include "titanic/pet_control/pet_control.h" +#include "titanic/game_manager.h" namespace Titanic { @@ -255,4 +257,31 @@ CNamedItem *CTreeItem::findByName(const CString &name, int maxLen) { return nullptr; } +int CTreeItem::compareRoomNameTo(const CString &name) { + CRoomItem *room = getGameManager()->getRoom(); + return room->getName().compareToIgnoreCase(name); +} + +void CTreeItem::clearPet() const { + CPetControl *petControl = getPetControl(); + if (petControl) + petControl->clear(); +} + +CPetControl *CTreeItem::getPetControl() const { + return dynamic_cast<CPetControl *>(getDontSaveChild(CPetControl::_type)); +} + +CTreeItem *CTreeItem::getDontSaveChild(ClassDef *classDef) const { + CProjectItem *root = getRoot(); + if (!root) + return nullptr; + + CDontSaveFileItem *dontSave = root->getDontSaveFileItem(); + if (!dontSave) + return nullptr; + + return dontSave->findChildInstanceOf(classDef); +} + } // End of namespace Titanic diff --git a/engines/titanic/core/tree_item.h b/engines/titanic/core/tree_item.h index e870ad1dc3..a6c09b8126 100644 --- a/engines/titanic/core/tree_item.h +++ b/engines/titanic/core/tree_item.h @@ -30,6 +30,7 @@ namespace Titanic { class CGameManager; class CDontSaveFileItem; class CNamedItem; +class CPetControl; class CProjectItem; class CScreenManager; @@ -220,6 +221,27 @@ public: * Finds a tree item by name */ CNamedItem *findByName(const CString &name, int maxLen = 0); + + /** + * Compare the name of the parent room to the item to a passed string + */ + int compareRoomNameTo(const CString &name); + + /** + * Clear the PET display + */ + void clearPet() const; + + /** + * Returns the PET control + */ + CPetControl *getPetControl() const; + + /** + * Returns a child of the Dont Save area of the project of the given class + */ + CTreeItem *getDontSaveChild(ClassDef *classDef) const; + }; } // End of namespace Titanic diff --git a/engines/titanic/game/television.cpp b/engines/titanic/game/television.cpp index 4c6b38ad32..102049abbf 100644 --- a/engines/titanic/game/television.cpp +++ b/engines/titanic/game/television.cpp @@ -69,4 +69,56 @@ void CTelevision::load(SimpleFile *file) { CBackground::load(file); } +bool CTelevision::handleMessage(CLeaveViewMsg &msg) { + return true; +} + +bool CTelevision::handleMessage(CChangeSeasonMsg &msg) { + return true; +} + +bool CTelevision::handleMessage(CEnterViewMsg &msg) { + return true; +} + +bool CTelevision::handleMessage(CPETUpMsg &msg) { + return true; +} + +bool CTelevision::handleMessage(CPETDownMsg &msg) { + return true; +} + +bool CTelevision::handleMessage(CStatusChangeMsg &msg) { + return true; +} + +bool CTelevision::handleMessage(CActMsg &msg) { + return true; +} + +bool CTelevision::handleMessage(CPETActivateMsg &msg) { + return true; +} + +bool CTelevision::handleMessage(CMovieEndMsg &msg) { + return true; +} + +bool CTelevision::handleMessage(CShipSettingMsg &msg) { + return true; +} + +bool CTelevision::handleMessage(CTurnOff &msg) { + return true; +} + +bool CTelevision::handleMessage(CTurnOn &msg) { + return true; +} + +bool CTelevision::handleMessage(CLightsMsg &msg) { + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/television.h b/engines/titanic/game/television.h index d64c253d90..04c201e681 100644 --- a/engines/titanic/game/television.h +++ b/engines/titanic/game/television.h @@ -24,10 +24,25 @@ #define TITANIC_TELEVISION_H #include "titanic/core/background.h" +#include "titanic/messages/messages.h" +#include "titanic/messages/pet_messages.h" namespace Titanic { -class CTelevision : public CBackground { +class CTelevision : public CBackground, + public CLeaveViewMsgTarget, + public CChangeSeasonMsgTarget, + public CEnterViewMsgTarget, + public CPETUpMsgTarget, + public CPETDownMsgTarget, + public CStatusChangeMsgTarget, + public CActMsgTarget, + public CPETActivateMsgTarget, + public CMovieEndMsgTarget, + public CShipSettingMsgTarget, + public CTurnOffTarget, + public CTurnOnTarget, + public CLightsMsgTarget { private: static int _v1; static int _v2; @@ -41,6 +56,20 @@ private: int _fieldE8; int _fieldEC; int _fieldF0; +protected: + virtual bool handleMessage(CLeaveViewMsg &msg); + virtual bool handleMessage(CChangeSeasonMsg &msg); + virtual bool handleMessage(CEnterViewMsg &msg); + virtual bool handleMessage(CPETUpMsg &msg); + virtual bool handleMessage(CPETDownMsg &msg); + virtual bool handleMessage(CStatusChangeMsg &msg); + virtual bool handleMessage(CActMsg &msg); + virtual bool handleMessage(CPETActivateMsg &msg); + virtual bool handleMessage(CMovieEndMsg &msg); + virtual bool handleMessage(CShipSettingMsg &msg); + virtual bool handleMessage(CTurnOff &msg); + virtual bool handleMessage(CTurnOn &msg); + virtual bool handleMessage(CLightsMsg &msg); public: CLASSDEF CTelevision(); diff --git a/engines/titanic/game_manager.cpp b/engines/titanic/game_manager.cpp index 23cb26e146..d5547a3ab7 100644 --- a/engines/titanic/game_manager.cpp +++ b/engines/titanic/game_manager.cpp @@ -213,10 +213,6 @@ void CGameManager::viewChange() { initBounds(); } -CRoomItem *CGameManager::getRoom() { - return _gameState._gameLocation.getRoom(); -} - void CGameManager::frameMessage(CRoomItem *room) { if (room) { // Signal the next frame diff --git a/engines/titanic/game_manager.h b/engines/titanic/game_manager.h index 610c438cfa..6ad0843e96 100644 --- a/engines/titanic/game_manager.h +++ b/engines/titanic/game_manager.h @@ -96,11 +96,6 @@ private: uint _tickCount2; private: /** - * Return the current room - */ - CRoomItem *getRoom(); - - /** * Generates a message for the next game frame */ void frameMessage(CRoomItem *room); @@ -153,9 +148,22 @@ public: */ void updateDiskTicksCount(); + /** + * Gets the current view + */ CViewItem *getView() { return _gameState._gameLocation.getView(); } /** + * Gets the current room node + */ + CNodeItem *getNode() { return _gameState._gameLocation.getNode(); } + + /** + * Gets the current room + */ + CRoomItem *getRoom() { return _gameState._gameLocation.getRoom(); } + + /** * Lock the input handler */ void lockInputHandler() { _inputHandler.incLockCount(); } diff --git a/engines/titanic/messages/messages.cpp b/engines/titanic/messages/messages.cpp index 28b8856578..1c3d406b1b 100644 --- a/engines/titanic/messages/messages.cpp +++ b/engines/titanic/messages/messages.cpp @@ -24,6 +24,7 @@ #include "titanic/messages/mouse_messages.h" #include "titanic/core/game_object.h" #include "titanic/core/tree_item.h" +#include "titanic/titanic.h" namespace Titanic { @@ -67,6 +68,17 @@ bool CMessage::execute(CTreeItem *target, const ClassDef *classDef, int flags) { return result; } +bool CMessage::execute(const CString &target, const ClassDef *classDef, int flags) { + // Scan for the target by name + CProjectItem *project = g_vm->_window->_project; + for (CTreeItem *treeItem = project; treeItem; treeItem = treeItem->scan(project)) { + if (treeItem->getName().compareToIgnoreCase(target)) + return execute(treeItem, classDef, flags); + } + + return false; +} + bool CMessage::isMouseMsg() const { return dynamic_cast<const CMouseMsg *>(this) != nullptr; } diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h index c945ad7736..b7a7cd6e7b 100644 --- a/engines/titanic/messages/messages.h +++ b/engines/titanic/messages/messages.h @@ -54,6 +54,13 @@ public: bool execute(CTreeItem *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 CString &target, const ClassDef *classDef = nullptr, + int flags = MSGFLAG_SCAN | MSGFLAG_BREAK_IF_HANDLED); + virtual bool perform(CTreeItem *treeItem) { return false; } /** diff --git a/engines/titanic/messages/pet_messages.h b/engines/titanic/messages/pet_messages.h index ac9c3ccc75..caca53dfee 100644 --- a/engines/titanic/messages/pet_messages.h +++ b/engines/titanic/messages/pet_messages.h @@ -42,6 +42,25 @@ MESSAGE1(CPETStarFieldLockMsg, int, value, 0); MESSAGE0(CPETStereoFieldOnOffMsg); MESSAGE2(CPETTargetMsg, CString, strValue, "", int, numValue, -1); +#define PET_MESSAGE(NAME) MSGTARGET(NAME); \ + class NAME: public CPETTargetMsg { \ + public: \ + NAME() : CPETTargetMsg() {} \ + NAME(const CString &name, int num) : CPETTargetMsg(name, num) {} \ + CLASSDEF \ + static bool isSupportedBy(const CTreeItem *item) { \ + return dynamic_cast<const NAME##Target *>(item) != nullptr; } \ + virtual bool perform(CTreeItem *treeItem) { \ + NAME##Target *dest = dynamic_cast<NAME##Target *>(treeItem); \ + return dest != nullptr && dest->handleMessage(*this); \ + } } + +PET_MESSAGE(CPETDownMsg); +PET_MESSAGE(CPETUpMsg); +PET_MESSAGE(CPETLeftMsg); +PET_MESSAGE(CPETRightMsg); +PET_MESSAGE(CPETActivateMsg); + } // End of namespace Titanic #endif /* TITANIC_PET_MESSAGES_H */ diff --git a/engines/titanic/movie.cpp b/engines/titanic/movie.cpp index 04d57239e1..58da09e61f 100644 --- a/engines/titanic/movie.cpp +++ b/engines/titanic/movie.cpp @@ -56,8 +56,14 @@ void OSMovie::proc14() { warning("TODO: OSMovie::proc14"); } -void OSMovie::proc15() { - warning("TODO: OSMovie::proc15"); +void OSMovie::setFrame(uint frameNumber) { + warning("TODO: OSMovie::setFrame"); + /* + _aviDecoder.seekToFrame(frameNumber); + const Graphics::Surface *s = _aviDecoder.decodeNextFrame(); + + _videoSurface->blitFrom(Common::Point(0, 0), s); + */ } void OSMovie::proc16() { @@ -85,13 +91,4 @@ void *OSMovie::proc21() { return nullptr; } -void OSMovie::setFrame(uint frameNumber) { - /* - _aviDecoder.seekToFrame(frameNumber); - const Graphics::Surface *s = _aviDecoder.decodeNextFrame(); - - _videoSurface->blitFrom(Common::Point(0, 0), s); - */ -} - } // End of namespace Titanic diff --git a/engines/titanic/movie.h b/engines/titanic/movie.h index 7752fd8cc3..4409712809 100644 --- a/engines/titanic/movie.h +++ b/engines/titanic/movie.h @@ -40,7 +40,7 @@ public: virtual void proc12() = 0; virtual void stop() = 0; virtual void proc14() = 0; - virtual void proc15() = 0; + virtual void setFrame(uint frameNumber) = 0; virtual void proc16() = 0; virtual void proc17() = 0; virtual void proc18() = 0; @@ -63,18 +63,18 @@ public: virtual void proc12(); virtual void stop(); virtual void proc14(); - virtual void proc15(); + + /** + * Set the current frame number + */ + virtual void setFrame(uint frameNumber); + virtual void proc16(); virtual void proc17(); virtual void proc18(); virtual void proc19(); virtual void proc20(); virtual void *proc21(); - - /** - * Set the current frame number - */ - void setFrame(uint frameNumber); }; } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_control.cpp b/engines/titanic/pet_control/pet_control.cpp index 5886ce4169..097c72d586 100644 --- a/engines/titanic/pet_control/pet_control.cpp +++ b/engines/titanic/pet_control/pet_control.cpp @@ -97,4 +97,9 @@ void CPetControl::enterRoom(CRoomItem *room) { _sub3.enterRoom(room); } +void CPetControl::clear() { + _field1394 = 0; + _string2.clear(); +} + } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_control.h b/engines/titanic/pet_control/pet_control.h index df529aed6a..e2b31bea4a 100644 --- a/engines/titanic/pet_control/pet_control.h +++ b/engines/titanic/pet_control/pet_control.h @@ -94,6 +94,11 @@ public: * Called when a new room is entered */ void enterRoom(CRoomItem *room); + + /** + * Called to clear the PET display + */ + void clear(); }; } // End of namespace Titanic diff --git a/engines/titanic/sound/sound.cpp b/engines/titanic/sound/sound.cpp index 14dba2e152..b3b783d4c6 100644 --- a/engines/titanic/sound/sound.cpp +++ b/engines/titanic/sound/sound.cpp @@ -47,4 +47,21 @@ void CSound::preEnterView(CViewItem *newView, bool isNewRoom) { warning("CSound::preEnterView"); } +bool CSound::fn1(int val) { + if (val == 0 || val == -1) { + if (!_soundManager.proc14()) + return true; + } + + return false; +} + +void CSound::fn2(int val) { + warning("TODO: CSound::fn3"); +} + +void CSound::fn3(int val, int val2, int val3) { + warning("TODO: CSound::fn3"); +} + } // End of namespace Titanic z diff --git a/engines/titanic/sound/sound.h b/engines/titanic/sound/sound.h index 4c0dab5dd5..fe115f7237 100644 --- a/engines/titanic/sound/sound.h +++ b/engines/titanic/sound/sound.h @@ -72,6 +72,10 @@ public: * Called when the view has been changed */ void preEnterView(CViewItem *newView, bool isNewRoom); + + bool fn1(int val); + void fn2(int val); + void fn3(int val, int val2, int val3); }; } // End of namespace Titanic diff --git a/engines/titanic/sound/sound_manager.cpp b/engines/titanic/sound/sound_manager.cpp index 143dd8385f..f575411c82 100644 --- a/engines/titanic/sound/sound_manager.cpp +++ b/engines/titanic/sound/sound_manager.cpp @@ -81,8 +81,9 @@ void QSoundManager::proc13() { warning("TODO"); } -void QSoundManager::proc14() { +bool QSoundManager::proc14() { warning("TODO"); + return false; } int QSoundManager::proc15() { diff --git a/engines/titanic/sound/sound_manager.h b/engines/titanic/sound/sound_manager.h index 99513aefe8..29fbb5ad11 100644 --- a/engines/titanic/sound/sound_manager.h +++ b/engines/titanic/sound/sound_manager.h @@ -48,7 +48,7 @@ public: virtual void proc11() = 0; virtual void proc12() {} virtual void proc13() {} - virtual void proc14() = 0; + virtual bool proc14() = 0; virtual int proc15() const { return 0; } virtual int proc16() const { return 0; } virtual void WaveMixPump() {} @@ -111,7 +111,7 @@ public: virtual void proc11(); virtual void proc12(); virtual void proc13(); - virtual void proc14(); + virtual bool proc14(); virtual int proc15(); virtual int proc16(); virtual void WaveMixPump(); diff --git a/engines/titanic/video_surface.cpp b/engines/titanic/video_surface.cpp index 864eb6ba29..7a4aba565f 100644 --- a/engines/titanic/video_surface.cpp +++ b/engines/titanic/video_surface.cpp @@ -304,6 +304,11 @@ void OSVideoSurface::stopMovie() { _movie->stop(); } +void OSVideoSurface::setMovieFrame(uint frameNumber) { + if (loadIfReady() && _movie) + _movie->setFrame(frameNumber); +} + bool OSVideoSurface::loadIfReady() { _videoSurfaceNum = _videoSurfaceCounter; diff --git a/engines/titanic/video_surface.h b/engines/titanic/video_surface.h index dd150abdad..f3459b456f 100644 --- a/engines/titanic/video_surface.h +++ b/engines/titanic/video_surface.h @@ -145,6 +145,11 @@ public: virtual void stopMovie() = 0; /** + * Sets the movie to the specified frame number + */ + virtual void setMovieFrame(uint frameNumber) = 0; + + /** * Loads the surface's resource if there's one pending */ virtual bool loadIfReady() = 0; @@ -249,6 +254,11 @@ public: virtual void stopMovie(); /** + * Sets the movie to the specified frame number + */ + virtual void setMovieFrame(uint frameNumber); + + /** * Loads the surface's resource if there's one pending */ virtual bool loadIfReady(); |