From c9bfc5c4814c26b0a6a1e2cdd22e3e1ce114eddd Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 29 May 2015 22:56:34 -0400 Subject: [PATCH] SHERLOCK: More RT doBgAnim code, interface draw --- engines/sherlock/objects.cpp | 4 ++ engines/sherlock/objects.h | 2 + engines/sherlock/scene.h | 10 +-- engines/sherlock/surface.cpp | 6 ++ engines/sherlock/tattoo/tattoo.cpp | 4 ++ engines/sherlock/tattoo/tattoo.h | 5 ++ engines/sherlock/tattoo/tattoo_scene.cpp | 69 ++++++++++++++++++- engines/sherlock/tattoo/tattoo_scene.h | 5 ++ .../sherlock/tattoo/tattoo_user_interface.cpp | 46 ++++++++++++- .../sherlock/tattoo/tattoo_user_interface.h | 15 ++++ 10 files changed, 159 insertions(+), 7 deletions(-) diff --git a/engines/sherlock/objects.cpp b/engines/sherlock/objects.cpp index 3e8838cb7901..8818f805a57b 100644 --- a/engines/sherlock/objects.cpp +++ b/engines/sherlock/objects.cpp @@ -1151,6 +1151,10 @@ CAnimStream::CAnimStream() { _zPlacement = 0; } +void CAnimStream::getNextFrame() { + // TODO +} + /*----------------------------------------------------------------*/ SceneImage::SceneImage() { diff --git a/engines/sherlock/objects.h b/engines/sherlock/objects.h index ec5c2e789709..d671066a23bf 100644 --- a/engines/sherlock/objects.h +++ b/engines/sherlock/objects.h @@ -429,6 +429,8 @@ struct CAnimStream { int _zPlacement; // Used by doBgAnim for determining Z order CAnimStream(); + + void getNextFrame(); }; struct SceneImage { diff --git a/engines/sherlock/scene.h b/engines/sherlock/scene.h index 624e4d3c9933..37a1b3274044 100644 --- a/engines/sherlock/scene.h +++ b/engines/sherlock/scene.h @@ -183,11 +183,6 @@ class Scene { * will remain the same on future visits to the scene */ void saveSceneStatus(); - - /** - * Draw all the shapes, people and NPCs in the correct order - */ - void drawAllShapes(); protected: SherlockEngine *_vm; @@ -198,6 +193,11 @@ class Scene { */ virtual void checkBgShapes(); + /** + * Draw all the shapes, people and NPCs in the correct order + */ + void drawAllShapes(); + Scene(SherlockEngine *vm); public: int _currentScene; diff --git a/engines/sherlock/surface.cpp b/engines/sherlock/surface.cpp index 6cf479c9624e..5a9e59e01bf9 100644 --- a/engines/sherlock/surface.cpp +++ b/engines/sherlock/surface.cpp @@ -96,6 +96,12 @@ void Surface::transBlitFrom(const ImageFrame &src, const Common::Point &pt, transBlitFrom(src._frame, pt + src._offset, flipped, overrideColor); } +void Surface::transBlitFrom(const Surface &src, const Common::Point &pt, + bool flipped, int overrideColor) { + const Graphics::Surface &s = src._surface; + transBlitFrom(s, pt, flipped, overrideColor); +} + void Surface::transBlitFrom(const Graphics::Surface &src, const Common::Point &pt, bool flipped, int overrideColor) { Common::Rect drawRect(0, 0, src.w, src.h); diff --git a/engines/sherlock/tattoo/tattoo.cpp b/engines/sherlock/tattoo/tattoo.cpp index 6d90416c34f5..368b24bfcd66 100644 --- a/engines/sherlock/tattoo/tattoo.cpp +++ b/engines/sherlock/tattoo/tattoo.cpp @@ -68,6 +68,10 @@ void TattooEngine::loadInitialPalette() { delete stream; } +void TattooEngine::drawCredits() { + // TODO +} + void TattooEngine::eraseCredits() { // TODO } diff --git a/engines/sherlock/tattoo/tattoo.h b/engines/sherlock/tattoo/tattoo.h index b6a85108e435..bb6310dbe3d3 100644 --- a/engines/sherlock/tattoo/tattoo.h +++ b/engines/sherlock/tattoo/tattoo.h @@ -53,6 +53,11 @@ class TattooEngine : public SherlockEngine { TattooEngine(OSystem *syst, const SherlockGameDescription *gameDesc); virtual ~TattooEngine() {} + /** + * Draw credits on the screen + */ + void drawCredits(); + /** * Erase any area of the screen covered by credits */ diff --git a/engines/sherlock/tattoo/tattoo_scene.cpp b/engines/sherlock/tattoo/tattoo_scene.cpp index 1effd6068273..dd96f3358e72 100644 --- a/engines/sherlock/tattoo/tattoo_scene.cpp +++ b/engines/sherlock/tattoo/tattoo_scene.cpp @@ -196,6 +196,8 @@ void TattooScene::doBgAnimEraseBackground() { } void TattooScene::doBgAnim() { + TattooUserInterface &ui = *((TattooUserInterface *)_vm->_ui); + doBgAnimCheckCursor(); // Events &events = *_vm->_events; @@ -208,7 +210,7 @@ void TattooScene::doBgAnim() { talk._talkToAbort = false; // Check the characters and sprites for updates - for (int idx = 0; idx < MAX_CHARACTERS; ++idx) { + for (uint idx = 0; idx < MAX_CHARACTERS; ++idx) { if (people[idx]._type == CHARACTER) people[idx].checkSprite(); } @@ -220,8 +222,73 @@ void TattooScene::doBgAnim() { // Erase any affected background areas doBgAnimEraseBackground(); + + doBgAnimUpdateBgObjectsAndAnim(); + + ui.drawInterface(); +} + +void TattooScene::doBgAnimUpdateBgObjectsAndAnim() { + TattooEngine &vm = *((TattooEngine *)_vm); + People &people = *_vm->_people; + Screen &screen = *_vm->_screen; + + for (uint idx = 0; idx < _bgShapes.size(); ++idx) { + Object &obj = _bgShapes[idx]; + if (obj._type == ACTIVE_BG_SHAPE || obj._type == NO_SHAPE) + obj.adjustObject(); + } + + for (uint idx = 0; idx < MAX_CHARACTERS; ++idx) { + if (people[idx]._type == CHARACTER) + people[idx].adjustSprite(); + } + + if (_activeCAnim._images != nullptr != _activeCAnim._zPlacement != REMOVE) { + _activeCAnim.getNextFrame(); + } + + // Flag the bg shapes which need to be redrawn + checkBgShapes(); + drawAllShapes(); + + + if (_mask != nullptr) { + switch (_currentScene) { + case 7: + screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x - SHERLOCK_SCREEN_WIDTH, 110), screen._currentScroll); + screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 110), screen._currentScroll); + screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x + SHERLOCK_SCREEN_WIDTH, 110), screen._currentScroll); + break; + + case 8: + screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x - SHERLOCK_SCREEN_WIDTH, 180), screen._currentScroll); + screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 180), screen._currentScroll); + screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x + SHERLOCK_SCREEN_WIDTH, 180), screen._currentScroll); + if (!_vm->readFlags(880)) + screen._backBuffer1.maskArea((*_mask1)[0], Common::Point(940, 300), screen._currentScroll); + break; + + case 18: + screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 203), screen._currentScroll); + if (!_vm->readFlags(189)) + screen._backBuffer1.maskArea((*_mask1)[0], Common::Point(124 + _maskOffset.x, 239), screen._currentScroll); + break; + + case 53: + screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 110), screen._currentScroll); + screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x - SHERLOCK_SCREEN_WIDTH, 110), screen._currentScroll); + break; + + case 68: + screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 203), screen._currentScroll); + screen._backBuffer1.maskArea((*_mask1)[0], Common::Point(124 + _maskOffset.x, 239), screen._currentScroll); + break; + } + } } + void TattooScene::updateBackground() { People &people = *_vm->_people; Screen &screen = *_vm->_screen; diff --git a/engines/sherlock/tattoo/tattoo_scene.h b/engines/sherlock/tattoo/tattoo_scene.h index 5e26eaa455e6..de28306c1b01 100644 --- a/engines/sherlock/tattoo/tattoo_scene.h +++ b/engines/sherlock/tattoo/tattoo_scene.h @@ -39,6 +39,11 @@ class TattooScene : public Scene { void doBgAnimCheckCursor(); void doBgAnimEraseBackground(); + + /** + * Update the background objects and canimations as part of doBgAnim + */ + void doBgAnimUpdateBgObjectsAndAnim(); protected: /** * Checks all the background shapes. If a background shape is animating, diff --git a/engines/sherlock/tattoo/tattoo_user_interface.cpp b/engines/sherlock/tattoo/tattoo_user_interface.cpp index 98ec34d62cf9..e76322833f55 100644 --- a/engines/sherlock/tattoo/tattoo_user_interface.cpp +++ b/engines/sherlock/tattoo/tattoo_user_interface.cpp @@ -22,7 +22,7 @@ #include "sherlock/tattoo/tattoo_user_interface.h" #include "sherlock/tattoo/tattoo_scene.h" -#include "sherlock/sherlock.h" +#include "sherlock/tattoo/tattoo.h" namespace Sherlock { @@ -31,6 +31,8 @@ namespace Tattoo { TattooUserInterface::TattooUserInterface(SherlockEngine *vm): UserInterface(vm) { _menuBuffer = nullptr; _invMenuBuffer = nullptr; + _tagBuffer = nullptr; + _invGraphic = nullptr; } void TattooUserInterface::handleInput() { @@ -38,6 +40,44 @@ void TattooUserInterface::handleInput() { _vm->_events->pollEventsAndWait(); } +void TattooUserInterface::drawInterface(int bufferNum) { + Screen &screen = *_vm->_screen; + TattooEngine &vm = *((TattooEngine *)_vm); + + if (_invMenuBuffer != nullptr) { + Common::Rect r = _invMenuBounds; + r.grow(-3); + r.translate(-screen._currentScroll, 0); + _grayAreas.clear(); + _grayAreas.push_back(r); + + drawGrayAreas(); + screen._backBuffer1.transBlitFrom(*_invMenuBuffer, Common::Point(_invMenuBounds.left, _invMenuBounds.top)); + } + + if (_menuBuffer != nullptr) { + Common::Rect r = _menuBounds; + r.grow(-3); + r.translate(-screen._currentScroll, 0); + _grayAreas.clear(); + _grayAreas.push_back(r); + + drawGrayAreas(); + screen._backBuffer1.transBlitFrom(*_menuBuffer, Common::Point(_invMenuBounds.left, _invMenuBounds.top)); + } + + // See if we need to draw a Text Tag floating with the cursor + if (_tagBuffer != nullptr) + screen._backBuffer1.transBlitFrom(*_tagBuffer, Common::Point(_tagBounds.left, _tagBounds.top)); + + // See if we need to draw an Inventory Item Graphic floating with the cursor + if (_invGraphic != nullptr) + screen._backBuffer1.transBlitFrom(*_invGraphic, Common::Point(_invGraphicBounds.left, _invGraphicBounds.top)); + + if (vm._creditsActive) + vm.drawCredits(); +} + void TattooUserInterface::doBgAnimRestoreUI() { TattooScene &scene = *((TattooScene *)_vm->_scene); Screen &screen = *_vm->_screen; @@ -101,6 +141,10 @@ void TattooUserInterface::doScroll() { _invMenuBounds.translate(screen._currentScroll - oldScroll, 0); } +void TattooUserInterface::drawGrayAreas() { + // TODO +} + } // End of namespace Tattoo } // End of namespace Sherlock diff --git a/engines/sherlock/tattoo/tattoo_user_interface.h b/engines/sherlock/tattoo/tattoo_user_interface.h index c7a4c4cf773a..2125f1ba0755 100644 --- a/engines/sherlock/tattoo/tattoo_user_interface.h +++ b/engines/sherlock/tattoo/tattoo_user_interface.h @@ -36,10 +36,20 @@ class TattooUserInterface : public UserInterface { Common::Rect _oldMenuBounds; Common::Rect _invMenuBounds; Common::Rect _oldInvMenuBounds; + Common::Rect _tagBounds; Common::Rect _oldTagBounds; + Common::Rect _invGraphicBounds; Common::Rect _oldInvGraphicBounds; Surface *_menuBuffer; Surface *_invMenuBuffer; + Surface *_tagBuffer; + Surface *_invGraphic; + Common::Array _grayAreas; +private: + /** + * Draws designated areas of the screen that are meant to be grayed out using grayscale colors + */ + void drawGrayAreas(); public: TattooUserInterface(SherlockEngine *vm); @@ -59,6 +69,11 @@ class TattooUserInterface : public UserInterface { * Main input handler for the user interface */ virtual void handleInput(); + + /** + * Draw the user interface onto the screen's back buffers + */ + virtual void drawInterface(int bufferNum = 3); }; } // End of namespace Tattoo