aboutsummaryrefslogtreecommitdiff
path: root/engines/zvision
diff options
context:
space:
mode:
authorrichiesams2013-08-05 19:06:23 -0500
committerrichiesams2013-08-05 19:06:23 -0500
commit6598bb20fda6aec37d5d7c96ceb6ecde47fda866 (patch)
tree71bf12ca08cc79f7603cdbc49d62b9db531e5c8a /engines/zvision
parent1cff0fb0d6e33f436a998b07037b7a2428de34a8 (diff)
downloadscummvm-rg350-6598bb20fda6aec37d5d7c96ceb6ecde47fda866.tar.gz
scummvm-rg350-6598bb20fda6aec37d5d7c96ceb6ecde47fda866.tar.bz2
scummvm-rg350-6598bb20fda6aec37d5d7c96ceb6ecde47fda866.zip
ZVISION: Create image auto screen centering during blitting
Diffstat (limited to 'engines/zvision')
-rw-r--r--engines/zvision/render_manager.cpp20
-rw-r--r--engines/zvision/render_manager.h6
2 files changed, 15 insertions, 11 deletions
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 70f67deab7..1473dcccac 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -56,7 +56,7 @@ void RenderManager::updateScreen(bool isConsoleActive) {
}
}
-void RenderManager::renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uint32 imageHeight, uint32 horizontalPitch, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle) {
+void RenderManager::renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uint32 imageHeight, uint32 horizontalPitch, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool autoCenter) {
// Panoramas are transposed
// The actual data is transposed in mutateImage
if (_renderTable.getRenderState() == RenderTable::PANORAMA || _renderTable.getRenderState() == RenderTable::TILT) {
@@ -83,6 +83,11 @@ void RenderManager::renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uin
if (!subRectangle.isValidRect() || subRectangle.isEmpty() || !destRect.isValidRect() || destRect.isEmpty())
return;
+ // Center the image on the screen if asked
+ if (autoCenter) {
+ destRect.moveTo((_width - subRectangle.width()) / 2, (_height - subRectangle.height()) / 2);
+ }
+
if (_renderTable.getRenderState() == RenderTable::FLAT) {
_system->copyRectToScreen(buffer + subRectangle.top * horizontalPitch + subRectangle.left, horizontalPitch, destRect.left, destRect.top, destRect.width(), destRect.height());
} else {
@@ -94,7 +99,7 @@ void RenderManager::renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uin
}
}
-void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle) {
+void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool autoCenter) {
Common::File file;
if (!file.open(fileName)) {
@@ -102,10 +107,10 @@ void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 d
return;
}
- renderImageToScreen(file, destinationX, destinationY, subRectangle);
+ renderImageToScreen(file, destinationX, destinationY, subRectangle, autoCenter);
}
-void RenderManager::renderImageToScreen(Common::SeekableReadStream &stream, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle) {
+void RenderManager::renderImageToScreen(Common::SeekableReadStream &stream, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool autoCenter) {
// Read the magic number
// Some files are true TGA, while others are TGZ
uint32 fileType;
@@ -124,7 +129,7 @@ void RenderManager::renderImageToScreen(Common::SeekableReadStream &stream, uint
uint32 horizontalPitch = imageWidth * sizeof(uint16);
- renderSubRectToScreen((uint16 *)buffer, imageWidth, imageHeight, horizontalPitch, destinationX, destinationY, subRectangle);
+ renderSubRectToScreen((uint16 *)buffer, imageWidth, imageHeight, horizontalPitch, destinationX, destinationY, subRectangle, autoCenter);
delete[] buffer;
} else {
// Reset the cursor
@@ -138,7 +143,7 @@ void RenderManager::renderImageToScreen(Common::SeekableReadStream &stream, uint
}
const Graphics::Surface *tgaSurface = tga.getSurface();
- renderSubRectToScreen((uint16 *)tgaSurface->pixels, tgaSurface->w, tgaSurface->h, tgaSurface->pitch, destinationX, destinationY, subRectangle);
+ renderSubRectToScreen((uint16 *)tgaSurface->pixels, tgaSurface->w, tgaSurface->h, tgaSurface->pitch, destinationX, destinationY, subRectangle, autoCenter);
tga.destroy();
}
@@ -160,8 +165,7 @@ void RenderManager::setBackgroundImage(const Common::String &fileName) {
_currentBackground = file;
- // TODO: Check if all the panoramas are the same height. AKA: can we hardcode the vertical centering to 80px?
- renderImageToScreen(*_currentBackground, 0, 80);
+ renderImageToScreen(*_currentBackground, 0, 0, Common::Rect(), true);
}
} // End of namespace ZVision
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index c4318f7dd3..3352f415a9 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -72,7 +72,7 @@ public:
* @param destinationY Y position where the image should be put
* @param subRectangle The subrectangle of the image that should be rendered. If this is an empty rectangle, it will blit the entire image.
*/
- void renderImageToScreen(const Common::String &fileName, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle = Common::Rect(0, 0, 0, 0));
+ void renderImageToScreen(const Common::String &fileName, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle = Common::Rect(0, 0, 0, 0), bool autoCenter = false);
/**
* Blits the image or a portion of the image to the screen. Actual screen updates won't happen until the end of the frame.
@@ -83,7 +83,7 @@ public:
* @param destinationY Y position where the image should be put
* @param subRectangle The subrectangle of the image that should be rendered. If this is an empty rectangle, it will blit the entire image.
*/
- void renderImageToScreen(Common::SeekableReadStream &stream, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle = Common::Rect(0, 0, 0, 0));
+ void renderImageToScreen(Common::SeekableReadStream &stream, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle = Common::Rect(0, 0, 0, 0), bool autoCenter = false);
/**
* Sets the current background image to be used by the RenderManager and immediately
@@ -98,7 +98,7 @@ public:
bool needsScreenUpdate() { return _needsScreenUpdate; };
private:
- void renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uint32 imageHeight, uint32 horizontalPitch, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle);
+ void renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uint32 imageHeight, uint32 horizontalPitch, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool autoCenter);
};
} // End of namespace ZVision