diff options
author | Paul Gilbert | 2016-03-22 22:36:49 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-03-22 22:36:49 -0400 |
commit | bfcf006bbbec047c973f2008711e005ffb40acff (patch) | |
tree | f292a3555d113600e60b37cb7414cc6e056a5c60 | |
parent | 06bd62fed403684afe00c018647cb4febeeddcce (diff) | |
download | scummvm-rg350-bfcf006bbbec047c973f2008711e005ffb40acff.tar.gz scummvm-rg350-bfcf006bbbec047c973f2008711e005ffb40acff.tar.bz2 scummvm-rg350-bfcf006bbbec047c973f2008711e005ffb40acff.zip |
TITANIC: Fixes for correct positioning of view background
-rw-r--r-- | engines/titanic/game_manager.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/game_view.cpp | 9 | ||||
-rw-r--r-- | engines/titanic/rect.cpp | 6 | ||||
-rw-r--r-- | engines/titanic/rect.h | 6 | ||||
-rw-r--r-- | engines/titanic/screen_manager.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/video_surface.cpp | 15 | ||||
-rw-r--r-- | engines/titanic/video_surface.h | 4 |
7 files changed, 24 insertions, 20 deletions
diff --git a/engines/titanic/game_manager.cpp b/engines/titanic/game_manager.cpp index d0c1ad5f8a..23cb26e146 100644 --- a/engines/titanic/game_manager.cpp +++ b/engines/titanic/game_manager.cpp @@ -239,7 +239,7 @@ void CGameManager::extendBounds(const Rect &r) { if (_bounds.isEmpty()) _bounds = r; else - _bounds.combine1(r); + _bounds.combine(r); } } // End of namespace Titanic diff --git a/engines/titanic/game_view.cpp b/engines/titanic/game_view.cpp index e93e8f0768..22da0c46bf 100644 --- a/engines/titanic/game_view.cpp +++ b/engines/titanic/game_view.cpp @@ -27,6 +27,9 @@ namespace Titanic { +#define VIEW_OFFSET_X 20 +#define VIEW_OFFSET_Y 10 + CGameView::CGameView() : _gameManager(nullptr), _surface(nullptr) { } @@ -62,10 +65,10 @@ void CGameView::drawView() { Rect srcRect = _gameManager->_bounds; Rect rect2(0, 0, 600, 340); - rect2.translate(20, 10); - srcRect.combine2(rect2); - srcRect.translate(-20, -10); + rect2.translate(VIEW_OFFSET_X, VIEW_OFFSET_Y); + srcRect.constrain(rect2); Common::Point destPos(srcRect.left, srcRect.top); + srcRect.translate(-VIEW_OFFSET_X, -VIEW_OFFSET_Y); CScreenManager::_currentScreenManagerPtr->blitFrom(SURFACE_BACKBUFFER, _surface, &destPos, &srcRect); diff --git a/engines/titanic/rect.cpp b/engines/titanic/rect.cpp index 4642b3422c..228a2ae4d4 100644 --- a/engines/titanic/rect.cpp +++ b/engines/titanic/rect.cpp @@ -24,19 +24,19 @@ namespace Titanic { -void Rect::combine1(const Rect &r) { +void Rect::combine(const Rect &r) { if (isEmpty() || r.isEmpty()) return; Common::Rect::extend(r); } -void Rect::combine2(const Rect &r) { +void Rect::constrain(const Rect &r) { if (!isEmpty()) { if (r.isEmpty()) { clear(); } else { - Common::Rect::extend(r); + Common::Rect::clip(r); } } } diff --git a/engines/titanic/rect.h b/engines/titanic/rect.h index b70550a607..1661711870 100644 --- a/engines/titanic/rect.h +++ b/engines/titanic/rect.h @@ -48,12 +48,12 @@ public: /** * Combine another rect into this one */ - void combine1(const Rect &r); + void combine(const Rect &r); /** - * Combine another rect into this one + * Constrains/clips to the intersection area of the given rect */ - void combine2(const Rect &r); + void constrain(const Rect &r); }; } // End of namespace Titanic diff --git a/engines/titanic/screen_manager.cpp b/engines/titanic/screen_manager.cpp index f13ecdd8fc..11063be2b6 100644 --- a/engines/titanic/screen_manager.cpp +++ b/engines/titanic/screen_manager.cpp @@ -149,7 +149,7 @@ void OSScreenManager::blitFrom(SurfaceNum surfaceNum, CVideoSurface *src, rect2 = srcBounds; rect2.translate(-srcBounds.left, -srcBounds.top); rect2.translate(destPoint.x, destPoint.y); - rect2.combine2(_backSurfaces[surfaceNum]._bounds); + rect2.constrain(_backSurfaces[surfaceNum]._bounds); rect2.translate(-destPoint.x, -destPoint.y); rect2.translate(srcBounds.left, srcBounds.top); diff --git a/engines/titanic/video_surface.cpp b/engines/titanic/video_surface.cpp index e833e1c1c7..0b935292b1 100644 --- a/engines/titanic/video_surface.cpp +++ b/engines/titanic/video_surface.cpp @@ -59,12 +59,14 @@ void CVideoSurface::blitFrom(const Point &destPos, CVideoSurface *src, const Rec } void CVideoSurface::clipBounds(Rect &srcRect, Rect &destRect, - CVideoSurface *srcSurface, const Rect *subRect, const Point *pt) { - if (pt) { - srcRect.left = pt->x; - srcRect.top = pt->y; + CVideoSurface *srcSurface, const Rect *subRect, const Point *destPos) { + // Figure out initial source rect and dest rect, based on whether + // specific subRect and/or destPos have been passed + if (destPos) { + destRect.left = destPos->x; + destRect.top = destPos->y; } else { - srcRect.left = srcRect.top = 0; + destRect.left = destRect.top = 0; } if (subRect) { @@ -124,8 +126,7 @@ void CVideoSurface::blitRect1(const Rect &srcRect, const Rect &destRect, CVideoS lock(); // TODO: Do it like the original does it -// this->_rawSurface->blitFrom(*src->_rawSurface, srcRect, Point(destRect.left, destRect.top)); - this->_rawSurface->blitFrom(*src->_rawSurface); + _rawSurface->blitFrom(*src->_rawSurface, srcRect, Point(destRect.left, destRect.top)); src->unlock(); unlock(); diff --git a/engines/titanic/video_surface.h b/engines/titanic/video_surface.h index 39431f1fae..d89d3201c2 100644 --- a/engines/titanic/video_surface.h +++ b/engines/titanic/video_surface.h @@ -44,8 +44,8 @@ private: /** * Calculates blitting bounds */ - void clipBounds(Rect &srcRect, Rect &destRect, - CVideoSurface *srcSurface, const Rect *subRect, const Point *pt); + void clipBounds(Rect &srcRect, Rect &destRect, CVideoSurface *srcSurface, + const Rect *subRect = nullptr, const Point *destPos = nullptr); void blitRect1(const Rect &srcRect, const Rect &destRect, CVideoSurface *src); void blitRect2(const Rect &srcRect, const Rect &destRect, CVideoSurface *src); |