TITANIC: Fixes for correct positioning of view background

This commit is contained in:
Paul Gilbert
2016-03-22 22:36:49 -04:00
parent 06bd62fed4
commit bfcf006bbb
7 changed files with 24 additions and 20 deletions
+1 -1
View File
@@ -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
+6 -3
View File
@@ -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);
+3 -3
View File
@@ -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);
}
}
}
+3 -3
View File
@@ -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
+1 -1
View File
@@ -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);
+8 -7
View File
@@ -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();
+2 -2
View File
@@ -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);