SLUDGE: Fix backdrop loading for images not of the window size

This commit is contained in:
Simei Yin 2017-07-20 01:55:21 +02:00
parent aded7ce9e9
commit 7e95f7dc63
6 changed files with 22 additions and 16 deletions

View File

@ -236,6 +236,7 @@ void GraphicsManager::killAllBackDrop() {
}
bool GraphicsManager::resizeBackdrop(int x, int y) {
debug(kSludgeDebugGraphics, "Load HSI");
_sceneWidth = x;
_sceneHeight = y;
return reserveBackdrop();
@ -247,7 +248,7 @@ bool GraphicsManager::killResizeBackdrop(int x, int y) {
}
void GraphicsManager::loadBackDrop(int fileNum, int x, int y) {
debug(kSludgeDebugGraphics, "Load back drop");
debug(kSludgeDebugGraphics, "Load back drop of num %i at position %i, %i", fileNum, x, y);
setResourceForFatal(fileNum);
if (!g_sludge->_resMan->openFileFromNum(fileNum)) {
fatal("Can't load overlay image");
@ -262,14 +263,14 @@ void GraphicsManager::loadBackDrop(int fileNum, int x, int y) {
g_sludge->_resMan->finishAccess();
setResourceForFatal(-1);
// set zBuffer if it's not set
if (_zBufferToSet >= 0) {
setZBuffer(_zBufferToSet);
_zBufferToSet = -1;
// reset zBuffer
if (_zBuffer->originalNum >= 0) {
setZBuffer(_zBuffer->originalNum);
}
}
void GraphicsManager::mixBackDrop(int fileNum, int x, int y) {
debug(kSludgeDebugGraphics, "Mix back drop of num %i at position %i, %i", fileNum, x, y);
setResourceForFatal(fileNum);
if (!g_sludge->_resMan->openFileFromNum(fileNum)) {
fatal("Can't load overlay image");
@ -285,9 +286,9 @@ void GraphicsManager::mixBackDrop(int fileNum, int x, int y) {
}
void GraphicsManager::blankScreen(int x1, int y1, int x2, int y2) {
// in case of no backdrop added at all
// in case of no backdrop added at all, create it
if (!_backdropSurface.getPixels()) {
return;
_backdropSurface.create(_winWidth, _winHeight, _renderSurface.format);
}
if (y1 < 0)
@ -410,11 +411,13 @@ bool GraphicsManager::loadHSI(Common::SeekableReadStream *stream, int x, int y,
killAllBackDrop(); // kill all
}
if (!ImgLoader::loadImage(stream, &_backdropSurface, (int)reserve))
Graphics::Surface tmp;
if (!ImgLoader::loadImage(stream, &tmp, (int)reserve))
return false;
uint realPicWidth = _backdropSurface.w;
uint realPicHeight = _backdropSurface.h;
uint realPicWidth = tmp.w;
uint realPicHeight = tmp.h;
// resize backdrop
if (reserve) {
@ -431,6 +434,10 @@ bool GraphicsManager::loadHSI(Common::SeekableReadStream *stream, int x, int y,
return false;
}
// copy surface loaded to backdrop
_backdropSurface.copyRectToSurface(tmp.getPixels(), tmp.pitch, x, y, tmp.w, tmp.h);
tmp.free();
_origBackdropSurface.copyFrom(_backdropSurface);
_backdropExists = true;

View File

@ -77,7 +77,6 @@ extern float speechSpeed;
extern byte brightnessLevel;
extern byte fadeMode;
extern uint16 saveEncoding;
extern byte currentBurnR, currentBurnG, currentBurnB;
int paramNum[] = { -1, 0, 1, 1, -1, -1, 1, 3, 4, 1, 0, 0, 8, -1, // SAY->MOVEMOUSE
-1, 0, 0, -1, -1, 1, 1, 1, 1, 4, 1, 1, 2, 1,// FOCUS->REMOVEREGION

View File

@ -64,8 +64,8 @@ GraphicsManager::GraphicsManager(SludgeEngine *vm) {
_spriteLayers->numLayers = 0;
// ZBuffer
_zBufferToSet = -1;
_zBuffer = new ZBufferData;
_zBuffer->originalNum = -1;
_zBuffer->sprites = nullptr;
// Colors

View File

@ -110,7 +110,7 @@ public:
// Screen
int getCenterX(int width) { return (_winWidth - width) >> 1; }
int checkSizeValide(int width, int height) { return ((width >= 0) && (height >= 0) && (width < (int)_winWidth) && (height > (int)_winHeight)); }
int checkSizeValide(int width, int height) { return ((width >= 0) && (height >= 0) && (width < (int)_winWidth) && (height < (int)_winHeight)); }
// Freeze
bool freeze();
@ -194,7 +194,6 @@ private:
uint32 getDrawColor(onScreenPerson *thisPerson);
// ZBuffer
int _zBufferToSet;
ZBufferData *_zBuffer;
void sortZPal(int *oldpal, int *newpal, int size);

View File

@ -838,6 +838,7 @@ bool addPerson(int x, int y, int objNum, persona *p) {
newPerson->colourmix = 0;
newPerson->transparency = 0;
newPerson->myPersona = p;
newPerson->lastUsedAnim = 0;
setFrames(*newPerson, ANI_STAND);

View File

@ -44,7 +44,7 @@ void GraphicsManager::killZBuffer() {
_zBuffer->sprites = nullptr;
}
_zBuffer->numPanels = 0;
_zBuffer->originalNum = 0;
_zBuffer->originalNum = -1;
}
void GraphicsManager::sortZPal(int *oldpal, int *newpal, int size) {
@ -71,7 +71,7 @@ bool GraphicsManager::setZBuffer(int num) {
// if the backdrop has not been set yet
// set zbuffer later
if (!_backdropSurface.getPixels()) {
_zBufferToSet = num;
_zBuffer->originalNum = num;
return true;
}