diff options
Diffstat (limited to 'engines/titanic')
-rw-r--r-- | engines/titanic/core/saveable_object.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/game_location.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/game_manager.cpp | 75 | ||||
-rw-r--r-- | engines/titanic/game_manager.h | 27 | ||||
-rw-r--r-- | engines/titanic/game_state.cpp | 24 | ||||
-rw-r--r-- | engines/titanic/game_state.h | 7 | ||||
-rw-r--r-- | engines/titanic/game_view.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/game_view.h | 4 | ||||
-rw-r--r-- | engines/titanic/messages/messages.h | 1 | ||||
-rw-r--r-- | engines/titanic/module.mk | 1 | ||||
-rw-r--r-- | engines/titanic/mouse_cursor.cpp | 4 | ||||
-rw-r--r-- | engines/titanic/mouse_cursor.h | 5 | ||||
-rw-r--r-- | engines/titanic/screen_manager.cpp | 18 | ||||
-rw-r--r-- | engines/titanic/screen_manager.h | 25 | ||||
-rw-r--r-- | engines/titanic/sound/sound.cpp | 4 | ||||
-rw-r--r-- | engines/titanic/sound/sound.h | 2 | ||||
-rw-r--r-- | engines/titanic/text_cursor.cpp | 37 | ||||
-rw-r--r-- | engines/titanic/text_cursor.h | 41 | ||||
-rw-r--r-- | engines/titanic/true_talk/true_talk_manager.cpp | 8 | ||||
-rw-r--r-- | engines/titanic/true_talk/true_talk_manager.h | 4 |
20 files changed, 254 insertions, 39 deletions
diff --git a/engines/titanic/core/saveable_object.cpp b/engines/titanic/core/saveable_object.cpp index 5fbe88878f..2c4eea5f3c 100644 --- a/engines/titanic/core/saveable_object.cpp +++ b/engines/titanic/core/saveable_object.cpp @@ -785,6 +785,7 @@ DEFFN(CEnterRoomMsg); DEFFN(CEnterViewMsg); DEFFN(CEjectCylinderMsg) DEFFN(CErasePhonographCylinderMsg) +DEFFN(CFrameMsg) DEFFN(CFreshenCookieMsg) DEFFN(CGetChevClassBits) DEFFN(CGetChevClassNum) @@ -1361,6 +1362,7 @@ void CSaveableObject::initClassList() { ADDFN(CEnterViewMsg, CMessage); ADDFN(CEjectCylinderMsg, CMessage); ADDFN(CErasePhonographCylinderMsg, CMessage); + ADDFN(CFrameMsg, CMessage); ADDFN(CFreshenCookieMsg, CMessage); ADDFN(CGetChevClassBits, CMessage); ADDFN(CGetChevClassNum, CMessage); diff --git a/engines/titanic/game_location.cpp b/engines/titanic/game_location.cpp index 2a01bbf248..23c2ae2598 100644 --- a/engines/titanic/game_location.cpp +++ b/engines/titanic/game_location.cpp @@ -112,4 +112,4 @@ CRoomItem *CGameLocation::getRoom() { return !view ? nullptr : view->findRoom(); } -} // End of namespace Titanic z +} // End of namespace Titanic 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 diff --git a/engines/titanic/game_manager.h b/engines/titanic/game_manager.h index 38edc6e1a4..f63b571ded 100644 --- a/engines/titanic/game_manager.h +++ b/engines/titanic/game_manager.h @@ -30,6 +30,7 @@ #include "titanic/simple_file.h" #include "titanic/video_surface.h" #include "titanic/true_talk/true_talk_manager.h" +#include "titanic/sound/background_sound_maker.h" #include "titanic/sound/music_room.h" #include "titanic/sound/sound.h" @@ -74,6 +75,11 @@ public: * Called when a game has finished being saved */ void postSave(); + + /** + * Handles an update + */ + void update(uint ticks); }; class CGameManager { @@ -81,13 +87,28 @@ private: CTrueTalkManager _trueTalkManager; CGameManagerList _list; int _field30; - int _field34; + CBackgroundSoundMaker *_soundMaker; CVideoSurface *_videoSurface1; int _field4C; int _field54; CVideoSurface *_videoSurface2; uint _lastDiskTicksCount; uint _tickCount2; +private: + /** + * Return the current room + */ + CRoomItem *getRoom(); + + /** + * Generates a message for the next game frame + */ + void frameMessage(CRoomItem *room); + + /** + * Handles any ongoing movie playback + */ + void handleMovies(); public: CProjectItem *_project; CGameView *_gameView; @@ -167,6 +188,10 @@ public: void viewChange(); bool test54() const { return !_field54; } + + void inc54() { ++_field54; } + + void dec54() { --_field54; } }; } // End of namespace Titanic diff --git a/engines/titanic/game_state.cpp b/engines/titanic/game_state.cpp index f10f945f93..f906ff66d3 100644 --- a/engines/titanic/game_state.cpp +++ b/engines/titanic/game_state.cpp @@ -27,6 +27,13 @@ namespace Titanic { +bool CGameStateList::isViewChanging() const { + warning("TODO: CGameStateList::isViewChanging"); + return false; +} + +/*------------------------------------------------------------------------*/ + CGameState::CGameState(CGameManager *gameManager) : _gameManager(gameManager), _gameLocation(this), _field8(0), _fieldC(0), _mode(GSMODE_0), _field14(0), _field18(0), @@ -98,6 +105,13 @@ void CGameState::enterView() { CRoomItem *oldRoom = oldView->findNode()->findRoom(); CRoomItem *newRoom = newView->findNode()->findRoom(); _gameManager->playClip(_list._movieClip, oldRoom, newRoom); + + _gameManager->_sound.preEnterView(newView, newRoom != oldRoom); + _gameManager->dec54(); + oldView->enterView(newView); + + _list._view = nullptr; + _list._movieClip = nullptr; } void CGameState::triggerLink(CLinkItem *link) { @@ -127,9 +141,17 @@ void CGameState::changeView(CViewItem *newView, CMovieClip *clip) { _gameManager->playClip(clip, oldRoom, newRoom); // Final view change handling - _gameManager->_sound.viewChanged(newView, newRoom != oldRoom); + _gameManager->_sound.preEnterView(newView, newRoom != oldRoom); oldView->enterView(newView); } } +void CGameState::checkForViewChange() { + if (_mode == GSMODE_2 && _list.isViewChanging()) { + setMode(GSMODE_1); + if (_list._view) + enterView(); + } +} + } // End of namespace Titanic diff --git a/engines/titanic/game_state.h b/engines/titanic/game_state.h index b9d25e9662..37bb603317 100644 --- a/engines/titanic/game_state.h +++ b/engines/titanic/game_state.h @@ -40,6 +40,8 @@ public: CMovieClip *_movieClip; public: CGameStateList() : List<ListItem>(), _view(nullptr), _movieClip(nullptr) {} + + bool isViewChanging() const; }; class CGameState { @@ -101,6 +103,11 @@ public: * Changes the current view */ void changeView(CViewItem *newView, CMovieClip *clip); + + /** + * Check for whether it's time to change the active view + */ + void checkForViewChange(); }; } // End of namespace Titanic diff --git a/engines/titanic/game_view.cpp b/engines/titanic/game_view.cpp index bf901bb704..86ad072f61 100644 --- a/engines/titanic/game_view.cpp +++ b/engines/titanic/game_view.cpp @@ -67,7 +67,7 @@ void CSTGameView::setView(CViewItem *view) { _gameWindow->setActiveView(view); } -void CSTGameView::proc4() { +void CSTGameView::proc4(const Common::Rect &bounds) { _gameWindow->fn2(); } diff --git a/engines/titanic/game_view.h b/engines/titanic/game_view.h index 9ede9d6c36..be4d934a33 100644 --- a/engines/titanic/game_view.h +++ b/engines/titanic/game_view.h @@ -57,7 +57,7 @@ public: */ virtual void setView(CViewItem *item) = 0; - virtual void proc4() = 0; + virtual void proc4(const Common::Rect &bounds) = 0; /** * Creates a surface from a specified resource @@ -76,7 +76,7 @@ public: */ virtual void setView(CViewItem *item); - virtual void proc4(); + virtual void proc4(const Common::Rect &bounds); }; } // End of namespace Titanic diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h index 317cde52c6..ccea453a26 100644 --- a/engines/titanic/messages/messages.h +++ b/engines/titanic/messages/messages.h @@ -298,6 +298,7 @@ MESSAGE2(CEnterNodeMsg, CNodeItem *, oldNode, nullptr, CNodeItem *, newNode, nul MESSAGE2(CEnterRoomMsg, CRoomItem *, oldRoom, nullptr, CRoomItem *, newRoom, nullptr); MESSAGE2(CEnterViewMsg, CViewItem *, oldView, nullptr, CViewItem *, newView, nullptr); MESSAGE0(CErasePhonographCylinderMsg); +MESSAGE1(CFrameMsg, uint, ticks, 0); MESSAGE2(CFreshenCookieMsg, int, value1, 0, int, value2, 0); MESSAGE1(CGetChevClassBits, int, value, 0); MESSAGE1(CGetChevClassNum, int, value, 0); diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk index af5c89c072..f62ef96d0b 100644 --- a/engines/titanic/module.mk +++ b/engines/titanic/module.mk @@ -20,6 +20,7 @@ MODULE_OBJS := \ screen_manager.o \ simple_file.o \ string.o \ + text_cursor.o \ titanic.o \ video_surface.o \ carry/auditory_centre.o \ diff --git a/engines/titanic/mouse_cursor.cpp b/engines/titanic/mouse_cursor.cpp index ee252ccf63..578bf9981f 100644 --- a/engines/titanic/mouse_cursor.cpp +++ b/engines/titanic/mouse_cursor.cpp @@ -37,4 +37,8 @@ void CMouseCursor::setCursorId(int id) { warning("CMouseCursor::setCursorId"); } +void CMouseCursor::update() { + warning("CMouseCursor::update"); +} + } // End of namespace Titanic diff --git a/engines/titanic/mouse_cursor.h b/engines/titanic/mouse_cursor.h index ecbee8569c..c6df65d096 100644 --- a/engines/titanic/mouse_cursor.h +++ b/engines/titanic/mouse_cursor.h @@ -32,6 +32,11 @@ public: void show(); void hide(); void setCursorId(int id); + + /** + * Updates the mouse cursor + */ + void update(); }; diff --git a/engines/titanic/screen_manager.cpp b/engines/titanic/screen_manager.cpp index 0c3ab6f556..59a322e919 100644 --- a/engines/titanic/screen_manager.cpp +++ b/engines/titanic/screen_manager.cpp @@ -25,15 +25,6 @@ namespace Titanic { -CScreenManagerRec::CScreenManagerRec() { - _field0 = 0; - _field4 = 0; - _field8 = 0; - _fieldC = 0; -} - -/*------------------------------------------------------------------------*/ - CScreenManager *CScreenManager::_screenManagerPtr; CScreenManager *CScreenManager::_currentScreenManagerPtr; @@ -71,6 +62,11 @@ CScreenManager *CScreenManager::setCurrent() { return _currentScreenManagerPtr; } +void CScreenManager::setSurfaceBounds(int surfaceNum, const Common::Rect &r) { + if (surfaceNum >= 0 && surfaceNum < (int)_backSurfaces.size()) + _backSurfaces[surfaceNum]._bounds = r; +} + /*------------------------------------------------------------------------*/ OSScreenManager::OSScreenManager(TitanicEngine *vm): CScreenManager(vm), @@ -115,7 +111,7 @@ CVideoSurface *OSScreenManager::getSurface(int surfaceNum) const { if (surfaceNum == -1) return _frontRenderSurface; else if (surfaceNum >= 0 && surfaceNum < (int)_backSurfaces.size()) - return _backSurfaces[surfaceNum]; + return _backSurfaces[surfaceNum]._surface; else return nullptr; } @@ -164,7 +160,7 @@ void OSScreenManager::destroyFrontAndBackBuffers() { _frontRenderSurface = nullptr; for (uint idx = 0; idx < _backSurfaces.size(); ++idx) - delete _backSurfaces[idx]; + delete _backSurfaces[idx]._surface; _backSurfaces.clear(); } diff --git a/engines/titanic/screen_manager.h b/engines/titanic/screen_manager.h index 1be2de9a8c..a8b7ee4bd6 100644 --- a/engines/titanic/screen_manager.h +++ b/engines/titanic/screen_manager.h @@ -29,6 +29,7 @@ #include "titanic/font.h" #include "titanic/input_handler.h" #include "titanic/mouse_cursor.h" +#include "titanic/text_cursor.h" #include "titanic/video_surface.h" #include "titanic/core/resource_key.h" @@ -36,20 +37,11 @@ namespace Titanic { class TitanicEngine; -class CSurface { -}; - -class CScreenManagerRec { -public: - int _field0; - int _field4; - int _field8; - int _fieldC; -public: - CScreenManagerRec(); -}; - class CScreenManager { + struct VideoSurfaceEntry { + CVideoSurface *_surface; + Common::Rect _bounds; + }; protected: TitanicEngine *_vm; public: @@ -61,11 +53,10 @@ public: */ static CScreenManager *setCurrent(); public: - Common::Array<CVideoSurface *> _backSurfaces; + Common::Array<VideoSurfaceEntry> _backSurfaces; CVideoSurface *_frontRenderSurface; - CScreenManagerRec _entries[2]; CMouseCursor *_mouseCursor; - void *_textCursor; + CTextCursor *_textCursor; CInputHandler *_inputHandler; int _fontNumber; public: @@ -118,6 +109,8 @@ public: virtual void proc25() = 0; virtual void showCursor() = 0; virtual void proc27() = 0; + + void setSurfaceBounds(int surfaceNum, const Common::Rect &r); }; class OSScreenManager: CScreenManager { diff --git a/engines/titanic/sound/sound.cpp b/engines/titanic/sound/sound.cpp index 54c14508cf..14dba2e152 100644 --- a/engines/titanic/sound/sound.cpp +++ b/engines/titanic/sound/sound.cpp @@ -43,8 +43,8 @@ void CSound::preLoad() { _gameManager->_musicRoom.preLoad(); } -void CSound::viewChanged(CViewItem *newView, bool isNewRoom) { - warning("CSound::viewChanged"); +void CSound::preEnterView(CViewItem *newView, bool isNewRoom) { + warning("CSound::preEnterView"); } } // End of namespace Titanic z diff --git a/engines/titanic/sound/sound.h b/engines/titanic/sound/sound.h index 0bfd3f29b1..4c0dab5dd5 100644 --- a/engines/titanic/sound/sound.h +++ b/engines/titanic/sound/sound.h @@ -71,7 +71,7 @@ public: /** * Called when the view has been changed */ - void viewChanged(CViewItem *newView, bool isNewRoom); + void preEnterView(CViewItem *newView, bool isNewRoom); }; } // End of namespace Titanic diff --git a/engines/titanic/text_cursor.cpp b/engines/titanic/text_cursor.cpp new file mode 100644 index 0000000000..e591dc38ed --- /dev/null +++ b/engines/titanic/text_cursor.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/rect.h" +#include "common/textconsole.h" +#include "titanic/text_cursor.h" + +namespace Titanic { + +CTextCursor::CTextCursor() : _active(false) { +} + +Common::Rect CTextCursor::getBounds() { + warning("CTextCursor::getBounds"); + return Common::Rect(); +} + +} // End of namespace Titanic diff --git a/engines/titanic/text_cursor.h b/engines/titanic/text_cursor.h new file mode 100644 index 0000000000..1b03abdd6a --- /dev/null +++ b/engines/titanic/text_cursor.h @@ -0,0 +1,41 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TEXT_CURSOR_H +#define TITANIC_TEXT_CURSOR_H + +#include "common/scummsys.h" + +namespace Titanic { + +class CTextCursor { +public: + bool _active; +public: + CTextCursor(); + + Common::Rect getBounds(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TEXT_CURSOR_H */ diff --git a/engines/titanic/true_talk/true_talk_manager.cpp b/engines/titanic/true_talk/true_talk_manager.cpp index 3d4a8ecc9d..d13356b42c 100644 --- a/engines/titanic/true_talk/true_talk_manager.cpp +++ b/engines/titanic/true_talk/true_talk_manager.cpp @@ -183,4 +183,12 @@ void CTrueTalkManager::viewChange() { warning("CTrueTalkManager::viewChange"); } +void CTrueTalkManager::update1() { + warning("CTrueTalkManager::update1"); +} + +void CTrueTalkManager::update2() { + warning("CTrueTalkManager::update2"); +} + } // End of namespace Titanic diff --git a/engines/titanic/true_talk/true_talk_manager.h b/engines/titanic/true_talk/true_talk_manager.h index 4c74ac2bc5..6724baaa34 100644 --- a/engines/titanic/true_talk/true_talk_manager.h +++ b/engines/titanic/true_talk/true_talk_manager.h @@ -106,6 +106,10 @@ public: * Returns the scripts for the manager */ TTScripts &getScripts() { return _scripts; } + + void update1(); + + void update2(); }; } // End of namespace Titanic |