diff options
Diffstat (limited to 'engines/titanic/game_manager.cpp')
-rw-r--r-- | engines/titanic/game_manager.cpp | 75 |
1 files changed, 72 insertions, 3 deletions
diff --git a/engines/titanic/game_manager.cpp b/engines/titanic/game_manager.cpp index 4a45fa52f9..1c480e5d4d 100644 --- a/engines/titanic/game_manager.cpp +++ b/engines/titanic/game_manager.cpp @@ -26,6 +26,7 @@ #include "titanic/screen_manager.h" #include "titanic/core/project_item.h" #include "titanic/messages/messages.h" +#include "titanic/pet_control/pet_control.h" namespace Titanic { @@ -44,6 +45,10 @@ void CGameManagerList::postSave() { (*i)->postSave(); } +void CGameManagerList::update(uint ticks) { + warning("TODO: CGameManagerList::update"); +} + /*------------------------------------------------------------------------*/ void CGameManagerListItem::postLoad(uint ticks, CProjectItem *project) { @@ -64,7 +69,7 @@ CGameManager::CGameManager(CProjectItem *project, CGameView *gameView): _project(project), _gameView(gameView), _trueTalkManager(this), _inputHandler(this), _inputTranslator(&_inputHandler), _gameState(this), _sound(this), _musicRoom(this), - _field30(0), _field34(0), _field4C(0), + _field30(0), _soundMaker(nullptr), _field4C(0), _dragItem(nullptr), _field54(0), _lastDiskTicksCount(0), _tickCount2(0) { _videoSurface1 = nullptr; @@ -85,7 +90,7 @@ void CGameManager::load(SimpleFile *file) { void CGameManager::preLoad() { updateDiskTicksCount(); _list.destroyContents(); - _field34 = 0; + _soundMaker = nullptr; _trueTalkManager.preLoad(); _sound.preLoad(); @@ -144,7 +149,49 @@ void CGameManager::playClip(CMovieClip *clip, CRoomItem *oldRoom, CRoomItem *new } void CGameManager::update() { - warning("TODO: CGameManager::update"); + handleMovies(); + frameMessage(getRoom()); + _list.update(g_vm->_events->getTicksCount()); + _trueTalkManager.update1(); + _trueTalkManager.update2(); + CScreenManager::_screenManagerPtr->_mouseCursor->update(); + + CViewItem *view = getView(); + if (view) { + // Expand the game manager's bounds to encompass all the view's items + for (CTreeItem *item = view; item; item = item->scan(view)) { + Common::Rect r = item->getBounds(); + if (!r.isEmpty()) + _bounds.extend(r); + } + + // Also include the PET control in the bounds + if (_project) { + CPetControl *pet = _project->getPetControl(); + if (pet) + _bounds.extend(pet->getBounds()); + } + + // And the text cursor + CScreenManager *screenManager = CScreenManager::_screenManagerPtr; + CTextCursor *textCursor = screenManager->_textCursor; + if (textCursor->_active) + _bounds.extend(textCursor->getBounds()); + + // Set the surface bounds + screenManager->setSurfaceBounds(0, _bounds); + + if (!_bounds.isEmpty()) { + _gameView->proc4(_bounds); + _bounds = Common::Rect(); + } + + _gameState.checkForViewChange(); + } +} + +void CGameManager::handleMovies() { + warning("TODO: CGameManager::handleMovies"); } void CGameManager::updateDiskTicksCount() { @@ -165,4 +212,26 @@ void CGameManager::viewChange() { initBounds(); } +CRoomItem *CGameManager::getRoom() { + return _gameState._gameLocation.getRoom(); +} + +void CGameManager::frameMessage(CRoomItem *room) { + if (room) { + // Signal the next frame + CFrameMsg frameMsg(g_vm->_events->getTicksCount()); + frameMsg.execute(room, nullptr, MSGFLAG_SCAN); + + if (!_soundMaker) { + // Check for a sound maker in the room + _soundMaker = dynamic_cast<CBackgroundSoundMaker *>( + _project->findByName("zBackgroundSoundMaker")); + } + + // If there's a sound maker, dispatch the event to it as well + if (_soundMaker) + frameMsg.execute(_soundMaker); + } +} + } // End of namespace Titanic |