diff options
author | Paul Gilbert | 2014-01-18 10:16:27 -0500 |
---|---|---|
committer | Paul Gilbert | 2014-01-18 10:16:27 -0500 |
commit | e387b016c02fcec0e5f4446f1a1064e6b0171e08 (patch) | |
tree | e252ec7f8b4c9eed2d56a53ccd559837c45c8552 | |
parent | cbbdf4db47cc6efeef5d9fa2630445e64aa3e444 (diff) | |
download | scummvm-rg350-e387b016c02fcec0e5f4446f1a1064e6b0171e08.tar.gz scummvm-rg350-e387b016c02fcec0e5f4446f1a1064e6b0171e08.tar.bz2 scummvm-rg350-e387b016c02fcec0e5f4446f1a1064e6b0171e08.zip |
VOYEUR: Implemented addSaveRect and clipRect
-rw-r--r-- | engines/voyeur/files.cpp | 47 | ||||
-rw-r--r-- | engines/voyeur/files.h | 5 | ||||
-rw-r--r-- | engines/voyeur/voyeur_game.cpp | 3 |
3 files changed, 52 insertions, 3 deletions
diff --git a/engines/voyeur/files.cpp b/engines/voyeur/files.cpp index 67488e4643..b776483b36 100644 --- a/engines/voyeur/files.cpp +++ b/engines/voyeur/files.cpp @@ -748,6 +748,43 @@ void DisplayResource::sFillBox(int width, int height) { _vm->_graphicsManager._saveBack = saveBack; } +bool DisplayResource::clipRect(Common::Rect &rect) { + Common::Rect clipRect; + if (_vm->_graphicsManager._clipPtr) { + clipRect = *_vm->_graphicsManager._clipPtr; + } else if (_flags & DISPFLAG_VIEWPORT) { + clipRect = ((ViewPortResource *)this)->_clipRect; + } else { + clipRect = ((PictureResource *)this)->_bounds; + } + + Common::Rect r = rect; + if (r.left < clipRect.left) { + if (r.right <= clipRect.left) + return false; + r.setWidth(r.right - clipRect.left); + } + if (r.right >= clipRect.right) { + if (r.left >= clipRect.left) + return false; + r.setWidth(clipRect.right - r.left); + } + + if (r.top < clipRect.top) { + if (r.bottom <= clipRect.top) + return false; + r.setHeight(r.bottom - clipRect.top); + } + if (r.bottom >= clipRect.bottom) { + if (r.top >= clipRect.top) + return false; + r.setWidth(clipRect.bottom - r.top); + } + + rect = r; + return true; +} + /*------------------------------------------------------------------------*/ PictureResource::PictureResource(BoltFilesState &state, const byte *src): @@ -1299,7 +1336,15 @@ int ViewPortResource::textWidth(const Common::String &msg) { void ViewPortResource::addSaveRect(int pageIndex, const Common::Rect &r) { // TODO - error("TODO: addSaveRect"); + Common::Rect rect = r; + + if (clipRect(rect)) { + if (_addFn) { + (_state._vm->_graphicsManager.*_addFn)(this, pageIndex, rect); + } else if (_rectListCount[pageIndex] != -1) { + _rectListPtr[pageIndex]->push_back(rect); + } + } } void ViewPortResource::fillPic(byte onOff) { diff --git a/engines/voyeur/files.h b/engines/voyeur/files.h index cbbf35eff8..b22aae4980 100644 --- a/engines/voyeur/files.h +++ b/engines/voyeur/files.h @@ -256,7 +256,12 @@ public: DisplayResource(); DisplayResource(VoyeurEngine *vm); + /** + * Fill a box of the given size at the current _drawPtr location + */ void sFillBox(int width, int height); + + bool clipRect(Common::Rect &rect); }; /* bvoy.blt resource types */ diff --git a/engines/voyeur/voyeur_game.cpp b/engines/voyeur/voyeur_game.cpp index d55a972c64..3178ccd087 100644 --- a/engines/voyeur/voyeur_game.cpp +++ b/engines/voyeur/voyeur_game.cpp @@ -546,8 +546,7 @@ void VoyeurEngine::reviewTape() { flipPageAndWait(); _graphicsManager._drawPtr->_penColor = 0; - _graphicsManager._drawPtr->_pos = Common::Point(tempRect.left, tempRect.top); - + _graphicsManager._drawPtr->_pos = Common::Point(tempRect.left, tempRect.top); _graphicsManager._backgroundPage->sFillBox(tempRect.width(), tempRect.height()); evtIndex = si; |