[Scummvm-git-logs] scummvm master -> b1ce54a86e745552e2b64a51c194e9e8e236d885
mgerhardy
martin.gerhardy at gmail.com
Wed Nov 25 18:42:09 UTC 2020
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
a967242757 TWINE: more Common::Rect refactorings
e3f9ecc996 TWINE: converted debug windows to use Common::Rect
b1ce54a86e TWINE: reduced code duplication in debug window code
Commit: a967242757f099bb5deec786e4759121754c24b7
https://github.com/scummvm/scummvm/commit/a967242757f099bb5deec786e4759121754c24b7
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-25T19:41:52+01:00
Commit Message:
TWINE: more Common::Rect refactorings
Changed paths:
engines/twine/debug.cpp
engines/twine/debug_scene.cpp
engines/twine/extra.cpp
engines/twine/gamestate.cpp
engines/twine/grid.cpp
engines/twine/interface.cpp
engines/twine/interface.h
engines/twine/menu.cpp
engines/twine/menuoptions.cpp
engines/twine/redraw.cpp
engines/twine/redraw.h
engines/twine/renderer.cpp
engines/twine/script_life_v1.cpp
engines/twine/text.cpp
engines/twine/text.h
engines/twine/twine.cpp
diff --git a/engines/twine/debug.cpp b/engines/twine/debug.cpp
index 54df6327b1..11e15aeeca 100644
--- a/engines/twine/debug.cpp
+++ b/engines/twine/debug.cpp
@@ -55,9 +55,9 @@ void Debug::debugDrawButton(int32 left, int32 top, int32 right, int32 bottom, co
}
void Debug::debugDrawWindowBox(int32 left, int32 top, int32 right, int32 bottom, int32 alpha) {
- _engine->_interface->drawTransparentBox(left, top, right, bottom, alpha);
+ _engine->_interface->drawTransparentBox(Common::Rect(left, top, right, bottom), alpha);
_engine->_menu->drawBox(left, top, right, bottom);
- //_engine->copyBlockPhys(left,top,right,bottom);
+ //_engine->copyBlockPhys(left, top, right, bottom);
}
void Debug::debugDrawWindowButtons(int32 w) {
diff --git a/engines/twine/debug_scene.cpp b/engines/twine/debug_scene.cpp
index fa5d3ecbb6..897d8b9735 100644
--- a/engines/twine/debug_scene.cpp
+++ b/engines/twine/debug_scene.cpp
@@ -39,20 +39,20 @@ void DebugScene::drawBoundingBoxProjectPoints(ScenePoint *pPoint3d, ScenePoint *
pPoint3dProjected->y = _engine->_renderer->projPosY;
pPoint3dProjected->z = _engine->_renderer->projPosZ;
- if (_engine->_redraw->renderLeft > _engine->_renderer->projPosX) {
- _engine->_redraw->renderLeft = _engine->_renderer->projPosX;
+ if (_engine->_redraw->renderRect.left > _engine->_renderer->projPosX) {
+ _engine->_redraw->renderRect.left = _engine->_renderer->projPosX;
}
- if (_engine->_redraw->renderRight < _engine->_renderer->projPosX) {
- _engine->_redraw->renderRight = _engine->_renderer->projPosX;
+ if (_engine->_redraw->renderRect.right < _engine->_renderer->projPosX) {
+ _engine->_redraw->renderRect.right = _engine->_renderer->projPosX;
}
- if (_engine->_redraw->renderTop > _engine->_renderer->projPosY) {
- _engine->_redraw->renderTop = _engine->_renderer->projPosY;
+ if (_engine->_redraw->renderRect.top > _engine->_renderer->projPosY) {
+ _engine->_redraw->renderRect.top = _engine->_renderer->projPosY;
}
- if (_engine->_redraw->renderBottom < _engine->_renderer->projPosY) {
- _engine->_redraw->renderBottom = _engine->_renderer->projPosY;
+ if (_engine->_redraw->renderRect.bottom < _engine->_renderer->projPosY) {
+ _engine->_redraw->renderRect.bottom = _engine->_renderer->projPosY;
}
}
diff --git a/engines/twine/extra.cpp b/engines/twine/extra.cpp
index 27a61c9269..faa24db797 100644
--- a/engines/twine/extra.cpp
+++ b/engines/twine/extra.cpp
@@ -439,30 +439,30 @@ void Extra::drawSpecialShape(const int16 *shapeTable, int32 x, int32 y, int32 co
int16 var_x = ((*(shapeTable++)) * size) >> 4;
int16 var_z = ((*(shapeTable++)) * size) >> 4;
- _engine->_redraw->renderLeft = 0x7D00;
- _engine->_redraw->renderRight = -0x7D00;
- _engine->_redraw->renderTop = 0x7D00;
- _engine->_redraw->renderBottom = -0x7D00;
+ _engine->_redraw->renderRect.left = 0x7D00;
+ _engine->_redraw->renderRect.right = -0x7D00;
+ _engine->_redraw->renderRect.top = 0x7D00;
+ _engine->_redraw->renderRect.bottom = -0x7D00;
_engine->_movements->rotateActor(var_x, var_z, angle);
int32 computedX = _engine->_renderer->destX + x;
int32 computedY = _engine->_renderer->destZ + y;
- if (computedX < _engine->_redraw->renderLeft) {
- _engine->_redraw->renderLeft = computedX;
+ if (computedX < _engine->_redraw->renderRect.left) {
+ _engine->_redraw->renderRect.left = computedX;
}
- if (computedX > _engine->_redraw->renderRight) {
- _engine->_redraw->renderRight = computedX;
+ if (computedX > _engine->_redraw->renderRect.right) {
+ _engine->_redraw->renderRect.right = computedX;
}
- if (computedY < _engine->_redraw->renderTop) {
- _engine->_redraw->renderTop = computedY;
+ if (computedY < _engine->_redraw->renderRect.top) {
+ _engine->_redraw->renderRect.top = computedY;
}
- if (computedY > _engine->_redraw->renderBottom) {
- _engine->_redraw->renderBottom = computedY;
+ if (computedY > _engine->_redraw->renderRect.bottom) {
+ _engine->_redraw->renderRect.bottom = computedY;
}
int32 numEntries = 1;
@@ -485,20 +485,20 @@ void Extra::drawSpecialShape(const int16 *shapeTable, int32 x, int32 y, int32 co
currentX = _engine->_renderer->destX + x;
currentY = _engine->_renderer->destZ + y;
- if (currentX < _engine->_redraw->renderLeft) {
- _engine->_redraw->renderLeft = currentX;
+ if (currentX < _engine->_redraw->renderRect.left) {
+ _engine->_redraw->renderRect.left = currentX;
}
- if (currentX > _engine->_redraw->renderRight) {
- _engine->_redraw->renderRight = currentX;
+ if (currentX > _engine->_redraw->renderRect.right) {
+ _engine->_redraw->renderRect.right = currentX;
}
- if (currentY < _engine->_redraw->renderTop) {
- _engine->_redraw->renderTop = currentY;
+ if (currentY < _engine->_redraw->renderRect.top) {
+ _engine->_redraw->renderRect.top = currentY;
}
- if (currentY > _engine->_redraw->renderBottom) {
- _engine->_redraw->renderBottom = currentY;
+ if (currentY > _engine->_redraw->renderRect.bottom) {
+ _engine->_redraw->renderRect.bottom = currentY;
}
_engine->_renderer->projPosX = currentX;
diff --git a/engines/twine/gamestate.cpp b/engines/twine/gamestate.cpp
index 9a2d4f15c3..ef8b79b574 100644
--- a/engines/twine/gamestate.cpp
+++ b/engines/twine/gamestate.cpp
@@ -22,6 +22,7 @@
#include "twine/gamestate.h"
#include "common/file.h"
+#include "common/rect.h"
#include "common/str.h"
#include "common/system.h"
#include "common/textconsole.h"
@@ -283,7 +284,7 @@ void GameState::processFoundItem(int32 item) {
const int32 itemCameraZ = _engine->_grid->newCameraZ << 9;
_engine->_renderer->renderIsoModel(_engine->_scene->sceneHero->x - itemCameraX, _engine->_scene->sceneHero->y - itemCameraY, _engine->_scene->sceneHero->z - itemCameraZ, 0, 0x80, 0, _engine->_actor->bodyTable[_engine->_scene->sceneHero->entity]);
- _engine->_interface->setClip(_engine->_redraw->renderLeft, _engine->_redraw->renderTop, _engine->_redraw->renderRight, _engine->_redraw->renderBottom);
+ _engine->_interface->setClip(_engine->_redraw->renderRect);
const int32 itemX = (_engine->_scene->sceneHero->x + 0x100) >> 9;
int32 itemY = _engine->_scene->sceneHero->y >> 8;
@@ -302,7 +303,7 @@ void GameState::processFoundItem(int32 item) {
const int32 boxTopLeftY = _engine->_renderer->projPosY - 65;
const int32 boxBottomRightX = _engine->_renderer->projPosX + 65;
const int32 boxBottomRightY = _engine->_renderer->projPosY + 65;
-
+ const Common::Rect boxRect(boxTopLeftX, boxTopLeftY, boxBottomRightX, boxBottomRightY);
_engine->_sound->playSample(Samples::BigItemFound);
// process vox play
@@ -334,16 +335,16 @@ void GameState::processFoundItem(int32 item) {
_engine->_interface->resetClip();
_engine->_redraw->currNumOfRedrawBox = 0;
_engine->_redraw->blitBackgroundAreas();
- _engine->_interface->drawTransparentBox(boxTopLeftX, boxTopLeftY, boxBottomRightX, boxBottomRightY, 4);
+ _engine->_interface->drawTransparentBox(boxRect, 4);
- _engine->_interface->setClip(boxTopLeftX, boxTopLeftY, boxBottomRightX, boxBottomRightY);
+ _engine->_interface->setClip(boxRect);
_engine->_menu->itemAngle[item] += 8;
_engine->_renderer->renderInventoryItem(_engine->_renderer->projPosX, _engine->_renderer->projPosY, _engine->_resources->inventoryTable[item], _engine->_menu->itemAngle[item], 10000);
- _engine->_menu->drawBox(boxTopLeftX, boxTopLeftY, boxBottomRightX, boxBottomRightY);
- _engine->_redraw->addRedrawArea(boxTopLeftX, boxTopLeftY, boxBottomRightX, boxBottomRightY);
+ _engine->_menu->drawBox(boxRect);
+ _engine->_redraw->addRedrawArea(boxRect);
_engine->_interface->resetClip();
initEngineProjections();
@@ -355,9 +356,9 @@ void GameState::processFoundItem(int32 item) {
}
_engine->_renderer->renderIsoModel(_engine->_scene->sceneHero->x - itemCameraX, _engine->_scene->sceneHero->y - itemCameraY, _engine->_scene->sceneHero->z - itemCameraZ, ANGLE_0, ANGLE_45, ANGLE_0, _engine->_actor->bodyTable[_engine->_scene->sceneHero->entity]);
- _engine->_interface->setClip(_engine->_redraw->renderLeft, _engine->_redraw->renderTop, _engine->_redraw->renderRight, _engine->_redraw->renderBottom);
+ _engine->_interface->setClip(_engine->_redraw->renderRect);
_engine->_grid->drawOverModelActor(itemX, itemY, itemZ);
- _engine->_redraw->addRedrawArea(_engine->_redraw->renderLeft, _engine->_redraw->renderTop, _engine->_redraw->renderRight, _engine->_redraw->renderBottom);
+ _engine->_redraw->addRedrawArea(_engine->_redraw->renderRect);
if (textState) {
_engine->_interface->resetClip();
@@ -450,12 +451,13 @@ void GameState::processGameoverAnimation() {
const int32 top = 120;
const int32 right = 519;
const int32 bottom = 359;
+ const Common::Rect rect(left, top, right, bottom);
_engine->_renderer->prepareIsoModel(gameOverPtr);
_engine->_sound->stopSamples();
_engine->_music->stopMidiMusic(); // stop fade music
_engine->_renderer->setCameraPosition(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, 128, 200, 200);
int32 startLbaTime = _engine->lbaTime;
- _engine->_interface->setClip(left, top, right, bottom);
+ _engine->_interface->setClip(rect);
while (!_engine->_input->toggleAbortAction() && (_engine->lbaTime - startLbaTime) <= 500) {
_engine->readKeys();
@@ -467,20 +469,20 @@ void GameState::processGameoverAnimation() {
const int32 avg = _engine->_collision->getAverageValue(40000, 3200, 500, _engine->lbaTime - startLbaTime);
const int32 cdot = _engine->_screens->crossDot(1, 1024, 100, (_engine->lbaTime - startLbaTime) % 100);
- _engine->_interface->blitBox(left, top, right, bottom, _engine->workVideoBuffer, 120, 120, _engine->frontVideoBuffer);
+ _engine->_interface->blitBox(rect, _engine->workVideoBuffer, 120, 120, _engine->frontVideoBuffer);
_engine->_renderer->setCameraAngle(0, 0, 0, 0, -cdot, 0, avg);
_engine->_renderer->renderIsoModel(0, 0, 0, 0, 0, 0, gameOverPtr);
- _engine->copyBlockPhys(left, top, right, bottom);
+ _engine->copyBlockPhys(rect);
_engine->lbaTime++;
_engine->_system->delayMillis(15);
}
_engine->_sound->playSample(Samples::Explode, _engine->getRandomNumber(2000) + 3096);
- _engine->_interface->blitBox(left, top, right, bottom, _engine->workVideoBuffer, 120, 120, _engine->frontVideoBuffer);
+ _engine->_interface->blitBox(rect, _engine->workVideoBuffer, 120, 120, _engine->frontVideoBuffer);
_engine->_renderer->setCameraAngle(0, 0, 0, 0, 0, 0, 3200);
_engine->_renderer->renderIsoModel(0, 0, 0, 0, 0, 0, gameOverPtr);
- _engine->copyBlockPhys(left, top, right, bottom);
+ _engine->copyBlockPhys(rect);
_engine->delaySkip(2000);
diff --git a/engines/twine/grid.cpp b/engines/twine/grid.cpp
index e3fea56e5f..5b35358aba 100644
--- a/engines/twine/grid.cpp
+++ b/engines/twine/grid.cpp
@@ -61,7 +61,7 @@ void Grid::copyGridMask(int32 index, int32 x, int32 y, const Graphics::ManagedSu
int32 right = *ptr + left - 1;
int32 bottom = *(ptr + 1) + top - 1;
- if (left > _engine->_interface->textWindowRight || right < _engine->_interface->textWindowLeft || bottom < _engine->_interface->textWindowTop || top > _engine->_interface->textWindowBottom) {
+ if (left > _engine->_interface->textWindow.right || right < _engine->_interface->textWindow.left || bottom < _engine->_interface->textWindow.top || top > _engine->_interface->textWindow.bottom) {
return;
}
@@ -82,8 +82,8 @@ void Grid::copyGridMask(int32 index, int32 x, int32 y, const Graphics::ManagedSu
bottom++;
// if line on top aren't in the blitting area...
- if (absY < _engine->_interface->textWindowTop) {
- int numOfLineToRemove = _engine->_interface->textWindowTop - absY;
+ if (absY < _engine->_interface->textWindow.top) {
+ int numOfLineToRemove = _engine->_interface->textWindow.top - absY;
vSize -= numOfLineToRemove;
if (vSize <= 0) {
@@ -101,8 +101,8 @@ void Grid::copyGridMask(int32 index, int32 x, int32 y, const Graphics::ManagedSu
}
// reduce the vSize to remove lines on bottom
- if (absY + vSize - 1 > _engine->_interface->textWindowBottom) {
- vSize = _engine->_interface->textWindowBottom - absY + 1;
+ if (absY + vSize - 1 > _engine->_interface->textWindow.bottom) {
+ vSize = _engine->_interface->textWindow.bottom - absY + 1;
if (vSize <= 0) {
return;
}
@@ -129,7 +129,7 @@ void Grid::copyGridMask(int32 index, int32 x, int32 y, const Graphics::ManagedSu
temp = *(ptr++); // copy size
for (int32 j = 0; j < temp; j++) {
- if (absX >= _engine->_interface->textWindowLeft && absX <= _engine->_interface->textWindowRight) {
+ if (absX >= _engine->_interface->textWindow.left && absX <= _engine->_interface->textWindow.right) {
*outPtr = *inPtr;
}
@@ -147,14 +147,14 @@ void Grid::copyGridMask(int32 index, int32 x, int32 y, const Graphics::ManagedSu
}
void Grid::drawOverModelActor(int32 x, int32 y, int32 z) {
- const int32 copyBlockPhysLeft = ((_engine->_interface->textWindowLeft + 24) / 24) - 1;
- const int32 copyBlockPhysRight = ((_engine->_interface->textWindowRight + 24) / 24);
+ const int32 copyBlockPhysLeft = ((_engine->_interface->textWindow.left + 24) / 24) - 1;
+ const int32 copyBlockPhysRight = ((_engine->_interface->textWindow.right + 24) / 24);
for (int32 j = copyBlockPhysLeft; j <= copyBlockPhysRight; j++) {
for (int32 i = 0; i < brickInfoBuffer[j]; i++) {
BrickEntry *currBrickEntry = &bricksDataBuffer[j][i];
- if (currBrickEntry->posY + 38 > _engine->_interface->textWindowTop && currBrickEntry->posY <= _engine->_interface->textWindowBottom && currBrickEntry->y >= y) {
+ if (currBrickEntry->posY + 38 > _engine->_interface->textWindow.top && currBrickEntry->posY <= _engine->_interface->textWindow.bottom && currBrickEntry->y >= y) {
if (currBrickEntry->x + currBrickEntry->z > z + x) {
copyGridMask(currBrickEntry->index, (j * 24) - 24, currBrickEntry->posY, _engine->workVideoBuffer);
}
@@ -164,14 +164,14 @@ void Grid::drawOverModelActor(int32 x, int32 y, int32 z) {
}
void Grid::drawOverSpriteActor(int32 x, int32 y, int32 z) {
- const int32 copyBlockPhysLeft = ((_engine->_interface->textWindowLeft + 24) / 24) - 1;
- const int32 copyBlockPhysRight = (_engine->_interface->textWindowRight + 24) / 24;
+ const int32 copyBlockPhysLeft = ((_engine->_interface->textWindow.left + 24) / 24) - 1;
+ const int32 copyBlockPhysRight = (_engine->_interface->textWindow.right + 24) / 24;
for (int32 j = copyBlockPhysLeft; j <= copyBlockPhysRight; j++) {
for (int32 i = 0; i < brickInfoBuffer[j]; i++) {
BrickEntry *currBrickEntry = &bricksDataBuffer[j][i];
- if (currBrickEntry->posY + 38 > _engine->_interface->textWindowTop && currBrickEntry->posY <= _engine->_interface->textWindowBottom && currBrickEntry->y >= y) {
+ if (currBrickEntry->posY + 38 > _engine->_interface->textWindow.top && currBrickEntry->posY <= _engine->_interface->textWindow.bottom && currBrickEntry->y >= y) {
if ((currBrickEntry->x == x) && (currBrickEntry->z == z)) {
copyGridMask(currBrickEntry->index, (j * 24) - 24, currBrickEntry->posY, _engine->workVideoBuffer);
}
@@ -507,7 +507,7 @@ void Grid::drawBrickSprite(int32 index, int32 posX, int32 posY, const uint8 *ptr
if (!(temp & 0x40)) {
temp = *(ptr++);
for (int32 i = 0; i < iteration; i++) {
- if (x >= _engine->_interface->textWindowLeft && x < _engine->_interface->textWindowRight && y >= _engine->_interface->textWindowTop && y < _engine->_interface->textWindowBottom) {
+ if (x >= _engine->_interface->textWindow.left && x < _engine->_interface->textWindow.right && y >= _engine->_interface->textWindow.top && y < _engine->_interface->textWindow.bottom) {
*(uint8 *)_engine->frontVideoBuffer.getBasePtr(x, y) = temp;
}
@@ -516,7 +516,7 @@ void Grid::drawBrickSprite(int32 index, int32 posX, int32 posY, const uint8 *ptr
}
} else {
for (int32 i = 0; i < iteration; i++) {
- if (x >= _engine->_interface->textWindowLeft && x < _engine->_interface->textWindowRight && y >= _engine->_interface->textWindowTop && y < _engine->_interface->textWindowBottom) {
+ if (x >= _engine->_interface->textWindow.left && x < _engine->_interface->textWindow.right && y >= _engine->_interface->textWindow.top && y < _engine->_interface->textWindow.bottom) {
*(uint8 *)_engine->frontVideoBuffer.getBasePtr(x, y) = *ptr;
}
diff --git a/engines/twine/interface.cpp b/engines/twine/interface.cpp
index c80ef72158..3fed07a217 100644
--- a/engines/twine/interface.cpp
+++ b/engines/twine/interface.cpp
@@ -36,14 +36,14 @@ const int32 BOTTOM = 8; // 1000
int32 Interface::checkClipping(int32 x, int32 y) {
int32 code = INSIDE;
- if (x < textWindowLeft) {
+ if (x < textWindow.left) {
code |= LEFT;
- } else if (x > textWindowRight) {
+ } else if (x > textWindow.right) {
code |= RIGHT;
}
- if (y < textWindowTop) {
+ if (y < textWindow.top) {
code |= TOP;
- } else if (y > textWindowBottom) {
+ } else if (y > textWindow.bottom) {
code |= BOTTOM;
}
return code;
@@ -79,17 +79,17 @@ void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, in
int32 x = 0;
int32 y = 0;
if (outcodeOut & TOP) { // point is above the clip rectangle
- x = startWidth + (int)((endWidth - startWidth) * (float)(textWindowTop - startHeight) / (float)(endHeight - startHeight));
- y = textWindowTop;
+ x = startWidth + (int)((endWidth - startWidth) * (float)(textWindow.top - startHeight) / (float)(endHeight - startHeight));
+ y = textWindow.top;
} else if (outcodeOut & BOTTOM) { // point is below the clip rectangle
- x = startWidth + (int)((endWidth - startWidth) * (float)(textWindowBottom - startHeight) / (float)(endHeight - startHeight));
- y = textWindowBottom;
+ x = startWidth + (int)((endWidth - startWidth) * (float)(textWindow.bottom - startHeight) / (float)(endHeight - startHeight));
+ y = textWindow.bottom;
} else if (outcodeOut & RIGHT) { // point is to the right of clip rectangle
- y = startHeight + (int)((endHeight - startHeight) * (float)(textWindowRight - startWidth) / (float)(endWidth - startWidth));
- x = textWindowRight;
+ y = startHeight + (int)((endHeight - startHeight) * (float)(textWindow.right - startWidth) / (float)(endWidth - startWidth));
+ x = textWindow.right;
} else if (outcodeOut & LEFT) { // point is to the left of clip rectangle
- y = startHeight + (int)((endHeight - startHeight) * (float)(textWindowLeft - startWidth) / (float)(endWidth - startWidth));
- x = textWindowLeft;
+ y = startHeight + (int)((endHeight - startHeight) * (float)(textWindow.left - startWidth) / (float)(endWidth - startWidth));
+ x = textWindow.left;
}
// Clip the point
@@ -153,10 +153,11 @@ void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, in
}
void Interface::blitBox(const Common::Rect &rect, const Graphics::ManagedSurface &source, int32 leftDest, int32 topDest, Graphics::ManagedSurface &dest) {
- blitBox(rect.left, rect.top, rect.right, rect.bottom, source, leftDest, topDest, dest);
-}
+ int32 left = rect.left;
+ const int32 top = rect.top;
+ const int32 right = rect.right;
+ const int32 bottom = rect.bottom;
-void Interface::blitBox(int32 left, int32 top, int32 right, int32 bottom, const Graphics::ManagedSurface &source, int32 leftDest, int32 topDest, Graphics::ManagedSurface &dest) {
const int8 *s = (const int8 *)source.getBasePtr(left, top);
int8 *d = (int8 *)dest.getBasePtr(left, top);
@@ -180,10 +181,11 @@ void Interface::blitBox(int32 left, int32 top, int32 right, int32 bottom, const
}
void Interface::drawTransparentBox(const Common::Rect &rect, int32 colorAdj) {
- drawTransparentBox(rect.left, rect.top, rect.right, rect.bottom, colorAdj);
-}
+ int32 left = rect.left;
+ int32 top = rect.top;
+ int32 right = rect.right;
+ int32 bottom = rect.bottom;
-void Interface::drawTransparentBox(int32 left, int32 top, int32 right, int32 bottom, int32 colorAdj) {
if (left > SCREEN_TEXTLIMIT_RIGHT) {
return;
}
@@ -237,10 +239,11 @@ void Interface::drawTransparentBox(int32 left, int32 top, int32 right, int32 bot
}
void Interface::drawSplittedBox(const Common::Rect &rect, uint8 colorIndex) {
- drawSplittedBox(rect.left, rect.top, rect.right, rect.bottom, colorIndex);
-}
+ const int32 left = rect.left;
+ const int32 top = rect.top;
+ const int32 right = rect.right;
+ const int32 bottom = rect.bottom;
-void Interface::drawSplittedBox(int32 left, int32 top, int32 right, int32 bottom, uint8 colorIndex) { // Box
if (left > SCREEN_TEXTLIMIT_RIGHT) {
return;
}
@@ -268,49 +271,50 @@ void Interface::drawSplittedBox(int32 left, int32 top, int32 right, int32 bottom
}
void Interface::setClip(const Common::Rect &rect) {
- setClip(rect.left, rect.top, rect.right, rect.bottom);
-}
+ int32 left = rect.left;
+ int32 top = rect.top;
+ int32 right = rect.right;
+ int32 bottom = rect.bottom;
-void Interface::setClip(int32 left, int32 top, int32 right, int32 bottom) {
if (left < 0) {
left = 0;
}
- textWindowLeft = left;
+ textWindow.left = left;
if (top < 0) {
top = 0;
}
- textWindowTop = top;
+ textWindow.top = top;
if (right >= SCREEN_WIDTH) {
right = SCREEN_TEXTLIMIT_RIGHT;
}
- textWindowRight = right;
+ textWindow.right = right;
if (bottom >= SCREEN_HEIGHT) {
bottom = SCREEN_TEXTLIMIT_BOTTOM;
}
- textWindowBottom = bottom;
+ textWindow.bottom = bottom;
}
void Interface::saveClip() { // saveTextWindow
- textWindowLeftSave = textWindowLeft;
- textWindowTopSave = textWindowTop;
- textWindowRightSave = textWindowRight;
- textWindowBottomSave = textWindowBottom;
+ textWindowLeftSave = textWindow.left;
+ textWindowTopSave = textWindow.top;
+ textWindowRightSave = textWindow.right;
+ textWindowBottomSave = textWindow.bottom;
}
void Interface::loadClip() { // loadSavedTextWindow
- textWindowLeft = textWindowLeftSave;
- textWindowTop = textWindowTopSave;
- textWindowRight = textWindowRightSave;
- textWindowBottom = textWindowBottomSave;
+ textWindow.left = textWindowLeftSave;
+ textWindow.top = textWindowTopSave;
+ textWindow.right = textWindowRightSave;
+ textWindow.bottom = textWindowBottomSave;
}
void Interface::resetClip() {
- textWindowTop = textWindowLeft = SCREEN_TEXTLIMIT_TOP;
- textWindowRight = SCREEN_TEXTLIMIT_RIGHT;
- textWindowBottom = SCREEN_TEXTLIMIT_BOTTOM;
+ textWindow.top = textWindow.left = SCREEN_TEXTLIMIT_TOP;
+ textWindow.right = SCREEN_TEXTLIMIT_RIGHT;
+ textWindow.bottom = SCREEN_TEXTLIMIT_BOTTOM;
}
} // namespace TwinE
diff --git a/engines/twine/interface.h b/engines/twine/interface.h
index dde51f6d9d..f0596c8258 100644
--- a/engines/twine/interface.h
+++ b/engines/twine/interface.h
@@ -54,10 +54,7 @@ private:
public:
Interface(TwinEEngine *engine);
- int32 textWindowTop = 0;
- int32 textWindowLeft = 0;
- int32 textWindowRight = 0;
- int32 textWindowBottom = 0;
+ Common::Rect textWindow { 0, 0, 0, 0 };
/**
* Draw button line
@@ -71,32 +68,20 @@ public:
/**
* Blit button box from working buffer to front buffer
- * @param left start width to draw the button
- * @param top start height to draw the button
- * @param right end width to draw the button
- * @param bottom end height to draw the button
* @param source source screen buffer, in this case working buffer
* @param leftDest start width to draw the button in destination buffer
* @param topDest start height to draw the button in destination buffer
* @param dest destination screen buffer, in this case front buffer
*/
- void blitBox(int32 left, int32 top, int32 right, int32 bottom, const Graphics::ManagedSurface &source, int32 leftDest, int32 topDest, Graphics::ManagedSurface &dest);
void blitBox(const Common::Rect &rect, const Graphics::ManagedSurface &source, int32 leftDest, int32 topDest, Graphics::ManagedSurface &dest);
/**
* Draws inside buttons transparent area
- * @param left start width to draw the button
- * @param top start height to draw the button
- * @param right end width to draw the button
- * @param bottom end height to draw the button
* @param colorAdj index to adjust the transparent box color
*/
- void drawTransparentBox(int32 left, int32 top, int32 right, int32 bottom, int32 colorAdj);
void drawTransparentBox(const Common::Rect &rect, int32 colorAdj);
- void drawSplittedBox(int32 left, int32 top, int32 right, int32 bottom, uint8 colorIndex);
void drawSplittedBox(const Common::Rect &rect, uint8 colorIndex);
- void setClip(int32 left, int32 top, int32 right, int32 bottom);
void setClip(const Common::Rect &rect);
void saveClip(); // saveTextWindow
void loadClip(); // loadSavedTextWindow
diff --git a/engines/twine/menu.cpp b/engines/twine/menu.cpp
index 4c30b3b5db..1f6c2c9b3e 100644
--- a/engines/twine/menu.cpp
+++ b/engines/twine/menu.cpp
@@ -279,7 +279,7 @@ void Menu::drawButtonGfx(const MenuSettings *menuSettings, const Common::Rect &r
if (!(_engine->getRandomNumber() % 5)) {
plasmaEffectPtr[_engine->getRandomNumber() % 140 * 10 + 1900] = 255;
}
- _engine->_interface->drawSplittedBox(newWidth, rect.top, rect.right, rect.bottom, 68);
+ _engine->_interface->drawSplittedBox(Common::Rect(newWidth, rect.top, rect.right, rect.bottom), 68);
} else {
processPlasmaEffect(rect.left, rect.top, 64);
if (!(_engine->getRandomNumber() % 5)) {
@@ -633,9 +633,9 @@ int32 Menu::volumeMenu() {
void Menu::inGameOptionsMenu() {
_engine->_text->initTextBank(TextBankId::Options_and_menus);
- _engine->_menu->optionsMenuState.setButtonTextId(0, TextId::kReturnGame);
+ optionsMenuState.setButtonTextId(0, TextId::kReturnGame);
_engine->_screens->copyScreen(_engine->frontVideoBuffer, _engine->workVideoBuffer);
- _engine->_menu->optionsMenu();
+ optionsMenu();
_engine->_text->initTextBank(_engine->_scene->sceneTextBank + 3);
optionsMenuState.setButtonTextId(0, TextId::kReturnMenu);
}
@@ -792,7 +792,7 @@ void Menu::drawInfoMenu(int16 left, int16 top) {
const int32 width = 450;
const int32 height = 80;
drawBox(left, top, left + width, top + height);
- _engine->_interface->drawSplittedBox(left + 1, top + 1, left + width - 1, top + height - 1, 0);
+ _engine->_interface->drawSplittedBox(Common::Rect(left + 1, top + 1, left + width - 1, top + height - 1), 0);
int32 newBoxLeft2 = left + 9;
@@ -804,13 +804,13 @@ void Menu::drawInfoMenu(int16 left, int16 top) {
int32 boxTop = top + 10;
int32 boxBottom = top + 25;
- _engine->_interface->drawSplittedBox(newBoxLeft, boxTop, boxLeft, boxBottom, 91);
+ _engine->_interface->drawSplittedBox(Common::Rect(newBoxLeft, boxTop, boxLeft, boxBottom), 91);
drawBox(left + 25, top + 10, left + 324, top + 10 + 14);
if (!_engine->_gameState->inventoryDisabled() && _engine->_gameState->hasItem(InventoryItems::kiTunic)) {
_engine->_grid->drawSprite(0, newBoxLeft2, top + 36, _engine->_resources->spriteTable[SPRITEHQR_MAGICPOINTS]);
if (_engine->_gameState->magicLevelIdx > 0) {
- _engine->_interface->drawSplittedBox(newBoxLeft, top + 35, _engine->_screens->crossDot(newBoxLeft, boxRight, 80, _engine->_gameState->inventoryMagicPoints), top + 50, 75);
+ _engine->_interface->drawSplittedBox(Common::Rect(newBoxLeft, top + 35, _engine->_screens->crossDot(newBoxLeft, boxRight, 80, _engine->_gameState->inventoryMagicPoints), top + 50), 75);
}
drawBox(left + 25, top + 35, left + _engine->_gameState->magicLevelIdx * 80 + 20, top + 35 + 15);
}
@@ -873,6 +873,7 @@ void Menu::drawBehaviour(HeroBehaviourType behaviour, int32 angle, bool cantDraw
const int32 titleBoxRight = 540;
const int32 titleBoxTop = boxRect.bottom + titleOffset;
const int32 titleBoxBottom = titleBoxTop + titleHeight;
+ const Common::Rect titleRect(titleBoxLeft, titleBoxTop, titleBoxRight, titleBoxBottom);
const uint8 *currentAnim = _engine->_resources->animTable[_engine->_actor->heroAnimIdx[(byte)behaviour]];
int16 currentAnimState = behaviourAnimState[(byte)behaviour];
@@ -900,8 +901,8 @@ void Menu::drawBehaviour(HeroBehaviourType behaviour, int32 angle, bool cantDraw
_engine->_interface->drawSplittedBox(boxRect, 69);
// behaviour menu title
- _engine->_interface->drawSplittedBox(titleBoxLeft, titleBoxTop, titleBoxRight, titleBoxBottom, 0);
- drawBox(titleBoxLeft, titleBoxTop, titleBoxRight, titleBoxBottom);
+ _engine->_interface->drawSplittedBox(titleRect, 0);
+ drawBox(titleRect);
_engine->_text->setFontColor(15);
@@ -914,7 +915,7 @@ void Menu::drawBehaviour(HeroBehaviourType behaviour, int32 angle, bool cantDraw
_engine->_renderer->renderBehaviourModel(boxRect, -600, angle, behaviourEntity);
_engine->copyBlockPhys(boxRect);
- _engine->copyBlockPhys(titleBoxLeft, titleBoxTop, titleBoxRight, titleBoxBottom);
+ _engine->copyBlockPhys(titleRect);
_engine->_interface->loadClip();
}
@@ -925,17 +926,21 @@ void Menu::prepareAndDrawBehaviour(int32 angle, HeroBehaviourType behaviour) {
}
void Menu::drawBehaviourMenu(int32 angle) {
- drawBox(100, 100, 550, 290);
- _engine->_interface->drawTransparentBox(101, 101, 549, 289, 2);
+ const Common::Rect titleRect(100, 100, 550, 290);
+ drawBox(titleRect);
+
+ Common::Rect boxRect(titleRect);
+ boxRect.grow(-1);
+ _engine->_interface->drawTransparentBox(boxRect, 2);
prepareAndDrawBehaviour(angle, HeroBehaviourType::kNormal);
prepareAndDrawBehaviour(angle, HeroBehaviourType::kAthletic);
prepareAndDrawBehaviour(angle, HeroBehaviourType::kAggressive);
prepareAndDrawBehaviour(angle, HeroBehaviourType::kDiscrete);
- drawInfoMenu(100, 300);
+ drawInfoMenu(titleRect.left, titleRect.top);
- _engine->copyBlockPhys(100, 100, 550, 290);
+ _engine->copyBlockPhys(titleRect);
}
void Menu::processBehaviourMenu() {
@@ -1039,9 +1044,8 @@ void Menu::drawItem(int32 item) {
const int32 right = itemX + 37;
const int32 top = itemY - 32;
const int32 bottom = itemY + 32;
-
- _engine->_interface->drawSplittedBox(left, top, right, bottom,
- inventorySelectedItem == item ? inventorySelectedColor : 0);
+ const Common::Rect rect(left, top, right, bottom);
+ _engine->_interface->drawSplittedBox(rect, inventorySelectedItem == item ? inventorySelectedColor : 0);
if (item < NUM_INVENTORY_ITEMS && _engine->_gameState->hasItem((InventoryItems)item) && !_engine->_gameState->inventoryDisabled()) {
_engine->_renderer->prepareIsoModel(_engine->_resources->inventoryTable[item]);
@@ -1055,15 +1059,16 @@ void Menu::drawItem(int32 item) {
}
}
- drawBox(left, top, right, bottom);
- _engine->copyBlockPhys(left, top, right, bottom);
+ drawBox(rect);
+ _engine->copyBlockPhys(rect);
}
void Menu::drawInventoryItems() {
- _engine->_interface->drawTransparentBox(17, 10, 622, 320, 4);
- drawBox(17, 10, 622, 320);
+ const Common::Rect rect(17, 10, 622, 320);
+ _engine->_interface->drawTransparentBox(rect, 4);
+ drawBox(rect);
drawMagicItemsBox(110, 18, 188, 311, 75);
- _engine->copyBlockPhys(17, 10, 622, 320);
+ _engine->copyBlockPhys(rect);
for (int32 item = 0; item < NUM_INVENTORY_ITEMS; item++) {
drawItem(item);
diff --git a/engines/twine/menuoptions.cpp b/engines/twine/menuoptions.cpp
index e2e4eaf215..c3e8e07c0b 100644
--- a/engines/twine/menuoptions.cpp
+++ b/engines/twine/menuoptions.cpp
@@ -203,11 +203,14 @@ void MenuOptions::drawPlayerName(int32 centerx, int32 top, int32 type) {
const int right = SCREEN_WIDTH - left;
const int bottom = top + PLASMA_HEIGHT;
- _engine->_menu->drawBox(left, top, right, bottom);
- _engine->_interface->drawTransparentBox(left + 1, top + 1, right - 1, bottom - 1, 3);
+ const Common::Rect rect(left, top, right, bottom);
+ Common::Rect rectBox(rect);
+ rectBox.grow(-1);
+ _engine->_menu->drawBox(rect);
+ _engine->_interface->drawTransparentBox(rectBox, 3);
_engine->_text->drawText(centerx - _engine->_text->getTextSize(playerName) / 2, top + 6, playerName);
- _engine->copyBlockPhys(left, top, right, bottom);
+ _engine->copyBlockPhys(rect);
}
/**
diff --git a/engines/twine/redraw.cpp b/engines/twine/redraw.cpp
index f1c08afe54..3d88bc1b4f 100644
--- a/engines/twine/redraw.cpp
+++ b/engines/twine/redraw.cpp
@@ -155,10 +155,10 @@ void Redraw::flipRedrawAreas() {
}
void Redraw::blitBackgroundAreas() {
- const RedrawStruct *currentArea = currentRedrawList;
+ const Common::Rect *currentArea = currentRedrawList;
for (int32 i = 0; i < numOfRedrawBox; i++) {
- _engine->_interface->blitBox(currentArea->left, currentArea->top, currentArea->right, currentArea->bottom, _engine->workVideoBuffer, currentArea->left, currentArea->top, _engine->frontVideoBuffer);
+ _engine->_interface->blitBox(*currentArea, _engine->workVideoBuffer, currentArea->left, currentArea->top, _engine->frontVideoBuffer);
currentArea++;
}
}
@@ -361,25 +361,25 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
_engine->_animations->setModelAnimation(actor2->animPosition, _engine->_resources->animTable[actor2->previousAnimIdx], _engine->_actor->bodyTable[actor2->entity], &actor2->animTimerData);
if (!_engine->_renderer->renderIsoModel(actor2->x - _engine->_grid->cameraX, actor2->y - _engine->_grid->cameraY, actor2->z - _engine->_grid->cameraZ, 0, actor2->angle, 0, _engine->_actor->bodyTable[actor2->entity])) {
- if (renderLeft < SCREEN_TEXTLIMIT_LEFT) {
- renderLeft = SCREEN_TEXTLIMIT_LEFT;
+ if (renderRect.left < SCREEN_TEXTLIMIT_LEFT) {
+ renderRect.left = SCREEN_TEXTLIMIT_LEFT;
}
- if (renderTop < SCREEN_TEXTLIMIT_TOP) {
- renderTop = SCREEN_TEXTLIMIT_TOP;
+ if (renderRect.top < SCREEN_TEXTLIMIT_TOP) {
+ renderRect.top = SCREEN_TEXTLIMIT_TOP;
}
- if (renderRight >= SCREEN_WIDTH) {
- renderRight = SCREEN_TEXTLIMIT_RIGHT;
+ if (renderRect.right >= SCREEN_WIDTH) {
+ renderRect.right = SCREEN_TEXTLIMIT_RIGHT;
}
- if (renderBottom >= SCREEN_HEIGHT) {
- renderBottom = SCREEN_TEXTLIMIT_BOTTOM;
+ if (renderRect.bottom >= SCREEN_HEIGHT) {
+ renderRect.bottom = SCREEN_TEXTLIMIT_BOTTOM;
}
- _engine->_interface->setClip(renderLeft, renderTop, renderRight, renderBottom);
+ _engine->_interface->setClip(renderRect);
- if (_engine->_interface->textWindowLeft <= _engine->_interface->textWindowRight && _engine->_interface->textWindowTop <= _engine->_interface->textWindowBottom) {
+ if (_engine->_interface->textWindow.left <= _engine->_interface->textWindow.right && _engine->_interface->textWindow.top <= _engine->_interface->textWindow.bottom) {
actor2->dynamicFlags.bIsVisible = 1;
const int32 tempX = (actor2->x + 0x100) >> 9;
@@ -393,13 +393,14 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
_engine->_grid->drawOverModelActor(tempX, tempY, tempZ);
if (_engine->_actor->cropBottomScreen) {
- renderBottom = _engine->_interface->textWindowBottom = _engine->_actor->cropBottomScreen + 10;
+ renderRect.bottom = _engine->_interface->textWindow.bottom = _engine->_actor->cropBottomScreen + 10;
}
- addRedrawArea(_engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, renderRight, renderBottom);
+ const Common::Rect rect(_engine->_interface->textWindow.left, _engine->_interface->textWindow.top, renderRect.right, renderRect.bottom);
+ addRedrawArea(rect);
if (actor2->staticFlags.bIsBackgrounded && bgRedraw == 1) {
- _engine->_interface->blitBox(_engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, renderRight, renderBottom, _engine->frontVideoBuffer, _engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, _engine->workVideoBuffer);
+ _engine->_interface->blitBox(rect, _engine->frontVideoBuffer, _engine->_interface->textWindow.left, _engine->_interface->textWindow.top, _engine->workVideoBuffer);
}
}
}
@@ -416,15 +417,15 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
_engine->_grid->getSpriteSize(shadow.offset, &spriteWidth, &spriteHeight, _engine->_resources->spriteShadowPtr);
// calculate sprite size and position on screen
- renderLeft = _engine->_renderer->projPosX - (spriteWidth / 2);
- renderTop = _engine->_renderer->projPosY - (spriteHeight / 2);
- renderRight = _engine->_renderer->projPosX + (spriteWidth / 2);
- renderBottom = _engine->_renderer->projPosY + (spriteHeight / 2);
+ renderRect.left = _engine->_renderer->projPosX - (spriteWidth / 2);
+ renderRect.top = _engine->_renderer->projPosY - (spriteHeight / 2);
+ renderRect.right = _engine->_renderer->projPosX + (spriteWidth / 2);
+ renderRect.bottom = _engine->_renderer->projPosY + (spriteHeight / 2);
- _engine->_interface->setClip(renderLeft, renderTop, renderRight, renderBottom);
+ _engine->_interface->setClip(renderRect);
- if (_engine->_interface->textWindowLeft <= _engine->_interface->textWindowRight && _engine->_interface->textWindowTop <= _engine->_interface->textWindowBottom) {
- _engine->_grid->drawSprite(shadow.offset, renderLeft, renderTop, _engine->_resources->spriteShadowPtr);
+ if (_engine->_interface->textWindow.left <= _engine->_interface->textWindow.right && _engine->_interface->textWindow.top <= _engine->_interface->textWindow.bottom) {
+ _engine->_grid->drawSprite(shadow.offset, renderRect.left, renderRect.top, _engine->_resources->spriteShadowPtr);
}
const int32 tmpX = (shadow.x + 0x100) >> 9;
@@ -433,10 +434,10 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
_engine->_grid->drawOverModelActor(tmpX, tmpY, tmpZ);
- addRedrawArea(_engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, renderRight, renderBottom);
+ addRedrawArea(_engine->_interface->textWindow.left, _engine->_interface->textWindow.top, renderRect.right, renderRect.bottom);
// show clipping area
- //drawBox(_engine->_renderer->renderLeft, _engine->_renderer->renderTop, _engine->_renderer->renderRight, _engine->_renderer->renderBottom);
+ //drawBox(_engine->_renderer->renderRect.left, _engine->_renderer->renderRect.top, _engine->_renderer->renderRect.right, _engine->_renderer->renderRect.bottom);
}
// Drawing unknown
else if (flags < 0x1000) {
@@ -456,19 +457,20 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
// calculate sprite position on screen
Common::MemoryReadStream stream(_engine->_resources->spriteBoundingBoxPtr, _engine->_resources->spriteBoundingBoxSize);
stream.seek(actor2->entity * 16);
- renderLeft = _engine->_renderer->projPosX + stream.readSint16LE();
- renderTop = _engine->_renderer->projPosY + stream.readSint16LE();
- renderRight = renderLeft + spriteWidth;
- renderBottom = renderTop + spriteHeight;
+ renderRect.left = _engine->_renderer->projPosX + stream.readSint16LE();
+ renderRect.top = _engine->_renderer->projPosY + stream.readSint16LE();
+ renderRect.right = renderRect.left + spriteWidth;
+ renderRect.bottom = renderRect.top + spriteHeight;
if (actor2->staticFlags.bUsesClipping) {
- _engine->_interface->setClip(_engine->_renderer->projPosXScreen + actor2->cropLeft, _engine->_renderer->projPosYScreen + actor2->cropTop, _engine->_renderer->projPosXScreen + actor2->cropRight, _engine->_renderer->projPosYScreen + actor2->cropBottom);
+ const Common::Rect rect(_engine->_renderer->projPosXScreen + actor2->cropLeft, _engine->_renderer->projPosYScreen + actor2->cropTop, _engine->_renderer->projPosXScreen + actor2->cropRight, _engine->_renderer->projPosYScreen + actor2->cropBottom);
+ _engine->_interface->setClip(rect);
} else {
- _engine->_interface->setClip(renderLeft, renderTop, renderRight, renderBottom);
+ _engine->_interface->setClip(renderRect);
}
- if (_engine->_interface->textWindowLeft <= _engine->_interface->textWindowRight && _engine->_interface->textWindowTop <= _engine->_interface->textWindowBottom) {
- _engine->_grid->drawSprite(0, renderLeft, renderTop, spritePtr);
+ if (_engine->_interface->textWindow.left <= _engine->_interface->textWindow.right && _engine->_interface->textWindow.top <= _engine->_interface->textWindow.bottom) {
+ _engine->_grid->drawSprite(0, renderRect.left, renderRect.top, spritePtr);
actor2->dynamicFlags.bIsVisible = 1;
@@ -485,14 +487,14 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
_engine->_grid->drawOverSpriteActor(tmpX, tmpY, tmpZ);
}
- addRedrawArea(_engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, _engine->_interface->textWindowRight, _engine->_interface->textWindowBottom);
+ addRedrawArea(_engine->_interface->textWindow.left, _engine->_interface->textWindow.top, _engine->_interface->textWindow.right, _engine->_interface->textWindow.bottom);
if (actor2->staticFlags.bIsBackgrounded && bgRedraw == 1) {
- _engine->_interface->blitBox(_engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, _engine->_interface->textWindowRight, _engine->_interface->textWindowBottom, _engine->frontVideoBuffer, _engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, _engine->workVideoBuffer);
+ _engine->_interface->blitBox(_engine->_interface->textWindow, _engine->frontVideoBuffer, _engine->_interface->textWindow.left, _engine->_interface->textWindow.top, _engine->workVideoBuffer);
}
// show clipping area
- //drawBox(renderLeft, renderTop, renderRight, renderBottom);
+ //drawBox(renderRect.left, renderRect.top, renderRect.right, renderRect.bottom);
}
}
// Drawing extras
@@ -510,26 +512,26 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
// calculate sprite position on screen
Common::MemoryReadStream stream(_engine->_resources->spriteBoundingBoxPtr, _engine->_resources->spriteBoundingBoxSize);
stream.seek(extra->info0 * 16);
- renderLeft = _engine->_renderer->projPosX + stream.readSint16LE();
- renderTop = _engine->_renderer->projPosY + stream.readSint16LE();
- renderRight = renderLeft + spriteWidth;
- renderBottom = renderTop + spriteHeight;
+ renderRect.left = _engine->_renderer->projPosX + stream.readSint16LE();
+ renderRect.top = _engine->_renderer->projPosY + stream.readSint16LE();
+ renderRect.right = renderRect.left + spriteWidth;
+ renderRect.bottom = renderRect.top + spriteHeight;
- _engine->_grid->drawSprite(0, renderLeft, renderTop, _engine->_resources->spriteTable[extra->info0]);
+ _engine->_grid->drawSprite(0, renderRect.left, renderRect.top, _engine->_resources->spriteTable[extra->info0]);
}
- _engine->_interface->setClip(renderLeft, renderTop, renderRight, renderBottom);
+ _engine->_interface->setClip(renderRect);
- if (_engine->_interface->textWindowLeft <= _engine->_interface->textWindowRight && _engine->_interface->textWindowTop <= _engine->_interface->textWindowBottom) {
+ if (_engine->_interface->textWindow.left <= _engine->_interface->textWindow.right && _engine->_interface->textWindow.top <= _engine->_interface->textWindow.bottom) {
const int32 tmpX = (drawList[pos].x + 0x100) >> 9;
const int32 tmpY = drawList[pos].y >> 8;
const int32 tmpZ = (drawList[pos].z + 0x100) >> 9;
_engine->_grid->drawOverModelActor(tmpX, tmpY, tmpZ);
- addRedrawArea(_engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, renderRight, renderBottom);
+ addRedrawArea(_engine->_interface->textWindow.left, _engine->_interface->textWindow.top, renderRect.right, renderRect.bottom);
// show clipping area
- //drawBox(renderLeft, renderTop, renderRight, renderBottom);
+ //drawBox(renderRect);
}
}
@@ -582,15 +584,15 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
const int16 offsetX = stream.readSint16LE();
const int16 offsetY = stream.readSint16LE();
- renderLeft = offsetX + overlay->x;
- renderTop = offsetY + overlay->y;
- renderRight = renderLeft + spriteWidth;
- renderBottom = renderTop + spriteHeight;
+ renderRect.left = offsetX + overlay->x;
+ renderRect.top = offsetY + overlay->y;
+ renderRect.right = renderRect.left + spriteWidth;
+ renderRect.bottom = renderRect.top + spriteHeight;
- _engine->_grid->drawSprite(0, renderLeft, renderTop, spritePtr);
+ _engine->_grid->drawSprite(0, renderRect.left, renderRect.top, spritePtr);
- if (_engine->_interface->textWindowLeft <= _engine->_interface->textWindowRight && _engine->_interface->textWindowTop <= _engine->_interface->textWindowBottom) {
- addRedrawArea(_engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, renderRight, renderBottom);
+ if (_engine->_interface->textWindow.left <= _engine->_interface->textWindow.right && _engine->_interface->textWindow.top <= _engine->_interface->textWindow.bottom) {
+ addRedrawArea(_engine->_interface->textWindow.left, _engine->_interface->textWindow.top, renderRect.right, renderRect.bottom);
}
break;
}
@@ -601,19 +603,19 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
const int32 textLength = _engine->_text->getTextSize(text);
const int32 textHeight = 48;
- renderLeft = overlay->x - (textLength / 2);
- renderTop = overlay->y - 24;
- renderRight = overlay->x + (textLength / 2);
- renderBottom = overlay->y + textHeight;
+ renderRect.left = overlay->x - (textLength / 2);
+ renderRect.top = overlay->y - 24;
+ renderRect.right = overlay->x + (textLength / 2);
+ renderRect.bottom = overlay->y + textHeight;
- _engine->_interface->setClip(renderLeft, renderTop, renderRight, renderBottom);
+ _engine->_interface->setClip(renderRect);
_engine->_text->setFontColor(overlay->info1);
- _engine->_text->drawText(renderLeft, renderTop, text);
+ _engine->_text->drawText(renderRect.left, renderRect.top, text);
- if (_engine->_interface->textWindowLeft <= _engine->_interface->textWindowRight && _engine->_interface->textWindowTop <= _engine->_interface->textWindowBottom) {
- addRedrawArea(_engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, renderRight, renderBottom);
+ if (_engine->_interface->textWindow.left <= _engine->_interface->textWindow.right && _engine->_interface->textWindow.top <= _engine->_interface->textWindow.bottom) {
+ addRedrawArea(_engine->_interface->textWindow.left, _engine->_interface->textWindow.top, renderRect.right, renderRect.bottom);
}
break;
}
@@ -626,19 +628,19 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
const int32 textLength = _engine->_text->getTextSize(text);
const int32 textHeight = 48;
- renderLeft = overlay->x - (textLength / 2);
- renderTop = overlay->y - 24;
- renderRight = overlay->x + (textLength / 2);
- renderBottom = overlay->y + textHeight;
+ renderRect.left = overlay->x - (textLength / 2);
+ renderRect.top = overlay->y - 24;
+ renderRect.right = overlay->x + (textLength / 2);
+ renderRect.bottom = overlay->y + textHeight;
- _engine->_interface->setClip(renderLeft, renderTop, renderRight, renderBottom);
+ _engine->_interface->setClip(renderRect);
_engine->_text->setFontColor(155);
- _engine->_text->drawText(renderLeft, renderTop, text);
+ _engine->_text->drawText(renderRect.left, renderRect.top, text);
- if (_engine->_interface->textWindowLeft <= _engine->_interface->textWindowRight && _engine->_interface->textWindowTop <= _engine->_interface->textWindowBottom) {
- addRedrawArea(_engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, renderRight, renderBottom);
+ if (_engine->_interface->textWindow.left <= _engine->_interface->textWindow.right && _engine->_interface->textWindow.top <= _engine->_interface->textWindow.bottom) {
+ addRedrawArea(_engine->_interface->textWindow.left, _engine->_interface->textWindow.top, renderRect.right, renderRect.bottom);
}
break;
}
@@ -668,35 +670,35 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
const int32 textLength = _engine->_text->getTextSize(text);
const int32 textHeight = 48;
- renderLeft = overlay->x - (textLength / 2);
- renderTop = overlay->y - 24;
- renderRight = overlay->x + (textLength / 2);
- renderBottom = overlay->y + textHeight;
+ renderRect.left = overlay->x - (textLength / 2);
+ renderRect.top = overlay->y - 24;
+ renderRect.right = overlay->x + (textLength / 2);
+ renderRect.bottom = overlay->y + textHeight;
- if (renderLeft < SCREEN_TEXTLIMIT_LEFT) {
- renderLeft = SCREEN_TEXTLIMIT_LEFT;
+ if (renderRect.left < SCREEN_TEXTLIMIT_LEFT) {
+ renderRect.left = SCREEN_TEXTLIMIT_LEFT;
}
- if (renderTop < SCREEN_TEXTLIMIT_TOP) {
- renderTop = SCREEN_TEXTLIMIT_TOP;
+ if (renderRect.top < SCREEN_TEXTLIMIT_TOP) {
+ renderRect.top = SCREEN_TEXTLIMIT_TOP;
}
- if (renderRight > SCREEN_TEXTLIMIT_RIGHT) {
- renderRight = SCREEN_TEXTLIMIT_RIGHT;
+ if (renderRect.right > SCREEN_TEXTLIMIT_RIGHT) {
+ renderRect.right = SCREEN_TEXTLIMIT_RIGHT;
}
- if (renderBottom > SCREEN_TEXTLIMIT_BOTTOM) {
- renderBottom = SCREEN_TEXTLIMIT_BOTTOM;
+ if (renderRect.bottom > SCREEN_TEXTLIMIT_BOTTOM) {
+ renderRect.bottom = SCREEN_TEXTLIMIT_BOTTOM;
}
- _engine->_interface->setClip(renderLeft, renderTop, renderRight, renderBottom);
+ _engine->_interface->setClip(renderRect);
_engine->_text->setFontColor(_engine->_scene->getActor(overlay->info1)->talkColor);
- _engine->_text->drawText(renderLeft, renderTop, text);
+ _engine->_text->drawText(renderRect.left, renderRect.top, text);
- if (_engine->_interface->textWindowLeft <= _engine->_interface->textWindowRight && _engine->_interface->textWindowTop <= _engine->_interface->textWindowBottom) {
- addRedrawArea(_engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, renderRight, renderBottom);
+ if (_engine->_interface->textWindow.left <= _engine->_interface->textWindow.right && _engine->_interface->textWindow.top <= _engine->_interface->textWindow.bottom) {
+ addRedrawArea(_engine->_interface->textWindow.left, _engine->_interface->textWindow.top, renderRect.right, renderRect.bottom);
}
break;
}
@@ -752,19 +754,19 @@ void Redraw::drawBubble(int32 actorIdx) {
// calculate sprite position on screen
if (bubbleSpriteIndex == SPRITEHQR_DIAG_BUBBLE_RIGHT) {
- renderLeft = _engine->_renderer->projPosX + 10;
+ renderRect.left = _engine->_renderer->projPosX + 10;
} else {
- renderLeft = _engine->_renderer->projPosX - 10 - spriteWidth;
+ renderRect.left = _engine->_renderer->projPosX - 10 - spriteWidth;
}
- renderTop = _engine->_renderer->projPosY - 20;
- renderRight = spriteWidth + renderLeft - 1;
- renderBottom = spriteHeight + renderTop - 1;
+ renderRect.top = _engine->_renderer->projPosY - 20;
+ renderRect.right = spriteWidth + renderRect.left - 1;
+ renderRect.bottom = spriteHeight + renderRect.top - 1;
- _engine->_interface->setClip(renderLeft, renderTop, renderRight, renderBottom);
+ _engine->_interface->setClip(renderRect);
- _engine->_grid->drawSprite(0, renderLeft, renderTop, spritePtr);
- if (_engine->_interface->textWindowLeft <= _engine->_interface->textWindowRight && _engine->_interface->textWindowTop <= _engine->_interface->textWindowBottom) {
- _engine->copyBlockPhys(renderLeft, renderTop, renderRight, renderBottom);
+ _engine->_grid->drawSprite(0, renderRect.left, renderRect.top, spritePtr);
+ if (_engine->_interface->textWindow.left <= _engine->_interface->textWindow.right && _engine->_interface->textWindow.top <= _engine->_interface->textWindow.bottom) {
+ _engine->copyBlockPhys(renderRect);
}
_engine->_interface->resetClip();
diff --git a/engines/twine/redraw.h b/engines/twine/redraw.h
index 7f50d9446f..09dd965aaa 100644
--- a/engines/twine/redraw.h
+++ b/engines/twine/redraw.h
@@ -73,15 +73,8 @@ private:
/** Draw list array to grab the necessary */
DrawListStruct drawList[150];
- struct RedrawStruct {
- uint16 left = 0;
- uint16 top = 0;
- uint16 right = 0;
- uint16 bottom = 0;
- };
-
- RedrawStruct currentRedrawList[300];
- RedrawStruct nextRedrawList[300];
+ Common::Rect currentRedrawList[300];
+ Common::Rect nextRedrawList[300];
int16 overlayRotation = 0;
/**
@@ -105,14 +98,8 @@ private:
public:
Redraw(TwinEEngine *engine) : _engine(engine) {}
- /** Auxiliar object render left position on screen */
- int32 renderLeft = 0;
- /** Auxiliar object render right position on screen */
- int32 renderRight = 0;
- /** Auxiliar object render top position on screen */
- int32 renderTop = 0;
- /** Auxiliar object render bottom position on screen */
- int32 renderBottom = 0;
+ /** Auxiliar object render position on screen */
+ Common::Rect renderRect { 0, 0, 0, 0 };
bool drawInGameTransBox = false;
diff --git a/engines/twine/renderer.cpp b/engines/twine/renderer.cpp
index 1a4246b836..5fb83269db 100644
--- a/engines/twine/renderer.cpp
+++ b/engines/twine/renderer.cpp
@@ -1273,10 +1273,10 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer, rende
// prepare to render elements
if (numOfPrimitives == 0) {
- _engine->_redraw->renderRight = -1;
- _engine->_redraw->renderBottom = -1;
- _engine->_redraw->renderLeft = -1;
- _engine->_redraw->renderTop = -1;
+ _engine->_redraw->renderRect.right = -1;
+ _engine->_redraw->renderRect.bottom = -1;
+ _engine->_redraw->renderRect.left = -1;
+ _engine->_redraw->renderRect.top = -1;
return -1;
}
@@ -1335,20 +1335,20 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer, rende
circleParam3 += 3;
- if (circleParam4 + circleParam3 > _engine->_redraw->renderRight) {
- _engine->_redraw->renderRight = circleParam4 + circleParam3;
+ if (circleParam4 + circleParam3 > _engine->_redraw->renderRect.right) {
+ _engine->_redraw->renderRect.right = circleParam4 + circleParam3;
}
- if (circleParam4 - circleParam3 < _engine->_redraw->renderLeft) {
- _engine->_redraw->renderLeft = circleParam4 - circleParam3;
+ if (circleParam4 - circleParam3 < _engine->_redraw->renderRect.left) {
+ _engine->_redraw->renderRect.left = circleParam4 - circleParam3;
}
- if (circleParam5 + circleParam3 > _engine->_redraw->renderBottom) {
- _engine->_redraw->renderBottom = circleParam5 + circleParam3;
+ if (circleParam5 + circleParam3 > _engine->_redraw->renderRect.bottom) {
+ _engine->_redraw->renderRect.bottom = circleParam5 + circleParam3;
}
- if (circleParam5 - circleParam3 < _engine->_redraw->renderTop) {
- _engine->_redraw->renderTop = circleParam5 - circleParam3;
+ if (circleParam5 - circleParam3 < _engine->_redraw->renderRect.top) {
+ _engine->_redraw->renderRect.top = circleParam5 - circleParam3;
}
circleParam3 -= 3;
@@ -1424,18 +1424,18 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr, renderTabEntry *renderTabEnt
pointPtrDest->y = (((coX - coZ) * 12) - coY * 30) / 512 + orthoProjY;
pointPtrDest->z = coZ - coX - coY;
- if (pointPtrDest->x < _engine->_redraw->renderLeft) {
- _engine->_redraw->renderLeft = pointPtrDest->x;
+ if (pointPtrDest->x < _engine->_redraw->renderRect.left) {
+ _engine->_redraw->renderRect.left = pointPtrDest->x;
}
- if (pointPtrDest->x > _engine->_redraw->renderRight) {
- _engine->_redraw->renderRight = pointPtrDest->x;
+ if (pointPtrDest->x > _engine->_redraw->renderRect.right) {
+ _engine->_redraw->renderRect.right = pointPtrDest->x;
}
- if (pointPtrDest->y < _engine->_redraw->renderTop) {
- _engine->_redraw->renderTop = pointPtrDest->y;
+ if (pointPtrDest->y < _engine->_redraw->renderRect.top) {
+ _engine->_redraw->renderRect.top = pointPtrDest->y;
}
- if (pointPtrDest->y > _engine->_redraw->renderBottom) {
- _engine->_redraw->renderBottom = pointPtrDest->y;
+ if (pointPtrDest->y > _engine->_redraw->renderRect.bottom) {
+ _engine->_redraw->renderRect.bottom = pointPtrDest->y;
}
pointPtr++;
@@ -1463,12 +1463,12 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr, renderTabEntry *renderTabEnt
pointPtrDest->x = coX;
- if (pointPtrDest->x < _engine->_redraw->renderLeft) {
- _engine->_redraw->renderLeft = pointPtrDest->x;
+ if (pointPtrDest->x < _engine->_redraw->renderRect.left) {
+ _engine->_redraw->renderRect.left = pointPtrDest->x;
}
- if (pointPtrDest->x > _engine->_redraw->renderRight) {
- _engine->_redraw->renderRight = pointPtrDest->x;
+ if (pointPtrDest->x > _engine->_redraw->renderRect.right) {
+ _engine->_redraw->renderRect.right = pointPtrDest->x;
}
}
@@ -1482,10 +1482,10 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr, renderTabEntry *renderTabEnt
pointPtrDest->y = coY;
- if (pointPtrDest->y < _engine->_redraw->renderTop)
- _engine->_redraw->renderTop = pointPtrDest->y;
- if (pointPtrDest->y > _engine->_redraw->renderBottom)
- _engine->_redraw->renderBottom = pointPtrDest->y;
+ if (pointPtrDest->y < _engine->_redraw->renderRect.top)
+ _engine->_redraw->renderRect.top = pointPtrDest->y;
+ if (pointPtrDest->y > _engine->_redraw->renderRect.bottom)
+ _engine->_redraw->renderRect.bottom = pointPtrDest->y;
}
// Z projection
@@ -1612,10 +1612,10 @@ int32 Renderer::renderIsoModel(int32 x, int32 y, int32 z, int32 angleX, int32 an
renderAngleZ = angleZ;
// model render size reset
- _engine->_redraw->renderLeft = 32767;
- _engine->_redraw->renderTop = 32767;
- _engine->_redraw->renderRight = -32767;
- _engine->_redraw->renderBottom = -32767;
+ _engine->_redraw->renderRect.left = 32767;
+ _engine->_redraw->renderRect.top = 32767;
+ _engine->_redraw->renderRect.right = -32767;
+ _engine->_redraw->renderRect.bottom = -32767;
if (isUsingOrhoProjection) {
renderX = x;
@@ -1702,7 +1702,7 @@ void Renderer::renderBehaviourModel(int32 boxLeft, int32 boxTop, int32 boxRight,
xpos >>= 1;
setOrthoProjection(xpos, ypos, 0);
- _engine->_interface->setClip(boxLeft, boxTop, tmpBoxRight, boxBottom);
+ _engine->_interface->setClip(Common::Rect(boxLeft, boxTop, tmpBoxRight, boxBottom));
if (angle == -1) {
ActorMoveStruct &move = _engine->_menu->moveMenu;
diff --git a/engines/twine/script_life_v1.cpp b/engines/twine/script_life_v1.cpp
index 353ed252a3..c9db46f5dd 100644
--- a/engines/twine/script_life_v1.cpp
+++ b/engines/twine/script_life_v1.cpp
@@ -1768,8 +1768,9 @@ static int32 lTEXT(TwinEEngine *engine, LifeScriptContext &ctx) {
*/
static int32 lCLEAR_TEXT(TwinEEngine *engine, LifeScriptContext &ctx) {
drawVar1 = 0;
- engine->_interface->drawSplittedBox(0, 0, 639, 240, 0);
- engine->copyBlockPhys(0, 0, 639, 240);
+ const Common::Rect rect(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT / 2);
+ engine->_interface->drawSplittedBox(rect, 0);
+ engine->copyBlockPhys(rect);
return 0;
}
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index 969dff03e3..4066f9b21c 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -283,21 +283,23 @@ int32 Text::getTextSize(const char *dialogue) { // SizeFont
}
void Text::initDialogueBox() { // InitDialWindow
- _engine->_interface->blitBox(_dialTextBoxLeft, _dialTextBoxTop, _dialTextBoxRight, _dialTextBoxBottom, _engine->workVideoBuffer, _dialTextBoxLeft, _dialTextBoxTop, _engine->frontVideoBuffer);
+ _engine->_interface->blitBox(_dialTextBox, _engine->workVideoBuffer, _dialTextBox.left, _dialTextBox.top, _engine->frontVideoBuffer);
if (drawTextBoxBackground) {
- _engine->_menu->drawBox(_dialTextBoxLeft, _dialTextBoxTop, _dialTextBoxRight, _dialTextBoxBottom);
- _engine->_interface->drawTransparentBox(_dialTextBoxLeft + 1, _dialTextBoxTop + 1, _dialTextBoxRight - 1, _dialTextBoxBottom - 1, 3);
+ _engine->_menu->drawBox(_dialTextBox);
+ Common::Rect rect(_dialTextBox);
+ rect.grow(-1);
+ _engine->_interface->drawTransparentBox(rect, 3);
}
- _engine->copyBlockPhys(_dialTextBoxLeft, _dialTextBoxTop, _dialTextBoxRight, _dialTextBoxBottom);
+ _engine->copyBlockPhys(_dialTextBox);
_fadeInCharactersPos = 0;
- _engine->_interface->blitBox(_dialTextBoxLeft, _dialTextBoxTop, _dialTextBoxRight, _dialTextBoxBottom, _engine->frontVideoBuffer, _dialTextBoxLeft, _dialTextBoxTop, _engine->workVideoBuffer);
+ _engine->_interface->blitBox(_dialTextBox, _engine->frontVideoBuffer, _dialTextBox.left, _dialTextBox.top, _engine->workVideoBuffer);
}
void Text::initInventoryDialogueBox() { // SecondInitDialWindow
- _engine->_interface->blitBox(_dialTextBoxLeft, _dialTextBoxTop, _dialTextBoxRight, _dialTextBoxBottom, _engine->workVideoBuffer, _dialTextBoxLeft, _dialTextBoxTop, _engine->frontVideoBuffer);
- _engine->copyBlockPhys(_dialTextBoxLeft, _dialTextBoxTop, _dialTextBoxRight, _dialTextBoxBottom);
+ _engine->_interface->blitBox(_dialTextBox, _engine->workVideoBuffer, _dialTextBox.left, _dialTextBox.top, _engine->frontVideoBuffer);
+ _engine->copyBlockPhys(_dialTextBox);
_fadeInCharactersPos = 0;
}
@@ -315,10 +317,10 @@ void Text::initText(int32 index) {
_dialTextBoxCurrentLine = 0;
_progressiveTextBuffer[0] = '\0';
_fadeInCharactersPos = 0;
- _dialTextYPos = _dialTextBoxLeft + 8;
+ _dialTextYPos = _dialTextBox.left + 8;
_progressiveTextEnd = false;
_progressiveTextNextPage = false;
- _dialTextXPos = _dialTextBoxTop + 8;
+ _dialTextXPos = _dialTextBox.top + 8;
printText8Var8 = _currDialTextPtr;
// lba font is get while engine start
@@ -449,10 +451,10 @@ void Text::processTextLine() {
}
void Text::renderContinueReadingTriangle() {
- const int32 right = _dialTextBoxRight - 3;
- const int32 left = _dialTextBoxRight - 24;
- const int32 top = _dialTextBoxBottom - 24;
- const int32 bottom = _dialTextBoxBottom - 3;
+ const int32 right = _dialTextBox.right - 3;
+ const int32 left = _dialTextBox.right - 24;
+ const int32 top = _dialTextBox.bottom - 24;
+ const int32 bottom = _dialTextBox.bottom - 3;
_engine->_renderer->vertexCoordinates[0] = _dialTextStopColor;
_engine->_renderer->vertexCoordinates[1] = right;
@@ -515,12 +517,12 @@ int Text::updateProgressiveText() {
return 0;
}
if (_progressiveTextNextPage) {
- _engine->_interface->blitBox(_dialTextBoxLeft, _dialTextBoxTop, _dialTextBoxRight, _dialTextBoxBottom, _engine->workVideoBuffer, _dialTextBoxLeft, _dialTextBoxTop, _engine->frontVideoBuffer);
- _engine->copyBlockPhys(_dialTextBoxLeft, _dialTextBoxTop, _dialTextBoxRight, _dialTextBoxBottom);
+ _engine->_interface->blitBox(_dialTextBox, _engine->workVideoBuffer, _dialTextBox.left, _dialTextBox.top, _engine->frontVideoBuffer);
+ _engine->copyBlockPhys(_dialTextBox);
_fadeInCharactersPos = 0;
_progressiveTextNextPage = false;
- _dialTextYPos = _dialTextBoxLeft + 8;
- _dialTextXPos = _dialTextBoxTop + 8;
+ _dialTextYPos = _dialTextBox.left + 8;
+ _dialTextXPos = _dialTextBox.top + 8;
}
if (*printText8Var8 == '\0') {
initProgressiveTextBuffer();
@@ -558,7 +560,7 @@ int Text::updateProgressiveText() {
const int32 lineHeight = 38;
_dialTextXPos += lineHeight;
- _dialTextYPos = _dialTextBoxLeft + 8;
+ _dialTextYPos = _dialTextBox.left + 8;
if (_progressiveTextNextPage && !_progressiveTextEnd) {
renderContinueReadingTriangle();
@@ -736,10 +738,10 @@ bool Text::getMenuText(int32 index, char *text, uint32 textSize) {
void Text::textClipFull() {
const int padding = 9;
- _dialTextBoxLeft = padding - 1;
- _dialTextBoxTop = padding - 1;
- _dialTextBoxRight = SCREEN_WIDTH - padding;
- _dialTextBoxBottom = SCREEN_HEIGHT - padding;
+ _dialTextBox.left = padding - 1;
+ _dialTextBox.top = padding - 1;
+ _dialTextBox.right = SCREEN_WIDTH - padding;
+ _dialTextBox.bottom = SCREEN_HEIGHT - padding;
_dialTextBoxLines = 11;
_dialTextBoxParam2 = 607;
@@ -747,10 +749,10 @@ void Text::textClipFull() {
void Text::textClipSmall() {
const int padding = 17;
- _dialTextBoxLeft = padding - 1;
- _dialTextBoxTop = 334;
- _dialTextBoxRight = SCREEN_WIDTH - padding;
- _dialTextBoxBottom = SCREEN_HEIGHT - padding;
+ _dialTextBox.left = padding - 1;
+ _dialTextBox.top = 334;
+ _dialTextBox.right = SCREEN_WIDTH - padding;
+ _dialTextBox.bottom = SCREEN_HEIGHT - padding;
_dialTextBoxLines = 3;
_dialTextBoxParam2 = 591;
diff --git a/engines/twine/text.h b/engines/twine/text.h
index 2e375bcc2e..6b1523839d 100644
--- a/engines/twine/text.h
+++ b/engines/twine/text.h
@@ -25,6 +25,7 @@
#include "common/scummsys.h"
#include "common/str.h"
+#include "common/rect.h"
namespace TwinE {
@@ -205,10 +206,7 @@ private:
/** Dialogue text buffer size for cross coloring dialogues */
int32 _dialTextBufferSize = 0;
- int32 _dialTextBoxLeft = 0; // dialogueBoxLeft
- int32 _dialTextBoxTop = 0; // dialogueBoxTop
- int32 _dialTextBoxRight = 0; // dialogueBoxRight
- int32 _dialTextBoxBottom = 0; // dialogueBoxBottom
+ Common::Rect _dialTextBox { 0, 0, 0, 0};
int32 _dialTextBoxLines = 0; // dialogueBoxParam1
int32 _dialTextBoxParam2 = 0; // dialogueBoxParam2
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index 1c512fdf6a..bdbfd46dba 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -414,8 +414,8 @@ void TwinEEngine::initAll() {
_scene->sceneHero = _scene->getActor(OWN_ACTOR_SCENE_INDEX);
- _redraw->renderRight = SCREEN_TEXTLIMIT_RIGHT;
- _redraw->renderBottom = SCREEN_TEXTLIMIT_BOTTOM;
+ _redraw->renderRect.right = SCREEN_TEXTLIMIT_RIGHT;
+ _redraw->renderRect.bottom = SCREEN_TEXTLIMIT_BOTTOM;
// Set clip to fullscreen by default, allows main menu to render properly after load
_interface->resetClip();
Commit: e3f9ecc99678afb12a60788a88c6fce9ccb911f7
https://github.com/scummvm/scummvm/commit/e3f9ecc99678afb12a60788a88c6fce9ccb911f7
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-25T19:41:52+01:00
Commit Message:
TWINE: converted debug windows to use Common::Rect
Changed paths:
engines/twine/debug.cpp
engines/twine/debug.h
engines/twine/text.cpp
diff --git a/engines/twine/debug.cpp b/engines/twine/debug.cpp
index 11e15aeeca..db99e4c082 100644
--- a/engines/twine/debug.cpp
+++ b/engines/twine/debug.cpp
@@ -36,7 +36,7 @@
namespace TwinE {
void Debug::debugFillButton(int32 x, int32 y, int32 width, int32 height, int8 color) {
- uint8 *ptr = (uint8*)_engine->frontVideoBuffer.getBasePtr(x, y);
+ uint8 *ptr = (uint8 *)_engine->frontVideoBuffer.getBasePtr(x, y);
int32 offset = SCREEN_WIDTH - width;
for (int32 i = 0; i < height; i++) {
@@ -47,27 +47,23 @@ void Debug::debugFillButton(int32 x, int32 y, int32 width, int32 height, int8 co
}
}
-void Debug::debugDrawButton(int32 left, int32 top, int32 right, int32 bottom, const char *text, int32 textLeft, int32 textRight, int32 isActive, int8 color) {
- debugFillButton(left + 1, top + 1, right - left - 1, bottom - top - 1, color);
- _engine->_menu->drawBox(left, top, right, bottom);
+void Debug::debugDrawButton(const Common::Rect &rect, const char *text, int32 textLeft, int32 textRight, int32 isActive, int8 color) {
+ debugFillButton(rect.left + 1, rect.top + 1, rect.right - rect.left - 1, rect.bottom - rect.top - 1, color);
+ _engine->_menu->drawBox(rect);
_engine->drawText(textLeft, textRight, text, 0);
- _engine->copyBlockPhys(left, top, right, bottom);
+ _engine->copyBlockPhys(rect);
}
-void Debug::debugDrawWindowBox(int32 left, int32 top, int32 right, int32 bottom, int32 alpha) {
- _engine->_interface->drawTransparentBox(Common::Rect(left, top, right, bottom), alpha);
- _engine->_menu->drawBox(left, top, right, bottom);
- //_engine->copyBlockPhys(left, top, right, bottom);
+void Debug::debugDrawWindowBox(const Common::Rect &rect, int32 alpha) {
+ _engine->_interface->drawTransparentBox(rect, alpha);
+ _engine->_menu->drawBox(rect);
+ //_engine->copyBlockPhys(rect);
}
void Debug::debugDrawWindowButtons(int32 w) {
int32 b;
for (b = 0; b < debugWindows[w].numButtons; b++) {
- int32 left = debugWindows[w].debugButtons[b].left;
- int32 top = debugWindows[w].debugButtons[b].top;
- int32 right = debugWindows[w].debugButtons[b].right;
- int32 bottom = debugWindows[w].debugButtons[b].bottom;
const char *text = debugWindows[w].debugButtons[b].text;
int32 textLeft = debugWindows[w].debugButtons[b].textLeft;
int32 textTop = debugWindows[w].debugButtons[b].textTop;
@@ -77,81 +73,83 @@ void Debug::debugDrawWindowButtons(int32 w) {
color = debugWindows[w].debugButtons[b].activeColor;
}
- debugDrawButton(left, top, right, bottom, text, textLeft, textTop, isActive, color);
+ debugDrawButton(debugWindows[w].debugButtons[b].rect, text, textLeft, textTop, isActive, color);
}
}
void Debug::debugDrawWindow(int32 w) {
- int32 left = debugWindows[w].left;
- int32 top = debugWindows[w].top;
- int32 right = debugWindows[w].right;
- int32 bottom = debugWindows[w].bottom;
+ const Common::Rect &rect = debugWindows[w].rect;
int32 alpha = debugWindows[w].alpha;
- debugDrawWindowBox(left, top, right, bottom, alpha);
+ debugDrawWindowBox(rect, alpha);
if (debugWindows[w].numLines > 0) {
for (int32 l = 0; l < debugWindows[w].numLines; l++) {
- _engine->drawText(left + 10, top + l * 20 + 5, debugWindows[w].text[l], 0);
+ _engine->drawText(rect.left + 10, rect.top + l * 20 + 5, debugWindows[w].text[l], 0);
}
}
- _engine->copyBlockPhys(left, top, right, bottom);
+ _engine->copyBlockPhys(rect);
debugDrawWindowButtons(w);
}
int32 Debug::debugTypeUseMenu(int32 type) {
for (int32 w = 0; w < numDebugWindows; w++) {
- if (debugWindows[w].isActive > 0) {
- for (int32 b = 0; b < debugWindows[w].numButtons; b++) {
- if (debugWindows[w].debugButtons[b].type == type) {
- int submenu = debugWindows[w].debugButtons[b].submenu;
- if (submenu > 0) {
- debugWindows[submenu].isActive = !debugWindows[submenu].isActive;
- }
- return submenu;
- }
+ if (debugWindows[w].isActive <= 0) {
+ continue;
+ }
+ for (int32 b = 0; b < debugWindows[w].numButtons; b++) {
+ if (debugWindows[w].debugButtons[b].type != type) {
+ continue;
+ }
+ int submenu = debugWindows[w].debugButtons[b].submenu;
+ if (submenu > 0) {
+ debugWindows[submenu].isActive = !debugWindows[submenu].isActive;
}
+ return submenu;
}
}
return 0;
}
void Debug::debugResetButtonsState() {
- for (int32 w = 0; w < numDebugWindows; w++) {
- if (debugWindows[w].isActive > 0) {
- for (int32 b = 0; b < debugWindows[w].numButtons; b++) {
- if (debugWindows[w].debugButtons[b].type <= -1)
- debugWindows[w].debugButtons[b].isActive = 0;
+ for (int32 w = 0; w < numDebugWindows; w++) {
+ if (debugWindows[w].isActive <= 0) {
+ continue;
+ }
+ for (int32 b = 0; b < debugWindows[w].numButtons; b++) {
+ if (debugWindows[w].debugButtons[b].type > -1) {
+ continue;
}
+ debugWindows[w].debugButtons[b].isActive = 0;
}
}
}
void Debug::debugRefreshButtons(int32 type) {
for (int32 w = 0; w < numDebugWindows; w++) {
- if (debugWindows[w].isActive > 0) {
- for (int32 b = 0; b < debugWindows[w].numButtons; b++) {
- if (debugWindows[w].debugButtons[b].type == type) {
- int32 left = debugWindows[w].debugButtons[b].left;
- int32 top = debugWindows[w].debugButtons[b].top;
- int32 right = debugWindows[w].debugButtons[b].right;
- int32 bottom = debugWindows[w].debugButtons[b].bottom;
- const char *text = debugWindows[w].debugButtons[b].text;
- int32 textLeft = debugWindows[w].debugButtons[b].textLeft;
- int32 textTop = debugWindows[w].debugButtons[b].textTop;
- int8 color = debugWindows[w].debugButtons[b].color;
- int32 isActive = debugWindows[w].debugButtons[b].isActive = !debugWindows[w].debugButtons[b].isActive;
-
- if (isActive > 0)
- color = debugWindows[w].debugButtons[b].activeColor;
-
- debugDrawButton(left, top, right, bottom, text, textLeft, textTop, isActive, color);
-
- if (debugWindows[w].debugButtons[b].submenu && isActive > 0)
- debugDrawWindow(debugWindows[w].debugButtons[b].submenu);
- }
+ if (debugWindows[w].isActive <= 0) {
+ continue;
+ }
+ for (int32 b = 0; b < debugWindows[w].numButtons; b++) {
+ if (debugWindows[w].debugButtons[b].type != type) {
+ continue;
+ }
+ const char *text = debugWindows[w].debugButtons[b].text;
+ const int32 textLeft = debugWindows[w].debugButtons[b].textLeft;
+ const int32 textTop = debugWindows[w].debugButtons[b].textTop;
+ int8 color = debugWindows[w].debugButtons[b].color;
+ const int32 isActive = debugWindows[w].debugButtons[b].isActive = !debugWindows[w].debugButtons[b].isActive;
+
+ if (isActive > 0) {
+ color = debugWindows[w].debugButtons[b].activeColor;
+ }
+
+ debugDrawButton(debugWindows[w].debugButtons[b].rect, text, textLeft, textTop, isActive, color);
+
+ if (debugWindows[w].debugButtons[b].submenu && isActive > 0) {
+ debugDrawWindow(debugWindows[w].debugButtons[b].submenu);
}
}
}
@@ -167,18 +165,19 @@ void Debug::debugDrawWindows() {
void Debug::debugResetButton(int32 type) {
for (int32 w = 0; w < numDebugWindows; w++) {
- if (debugWindows[w].isActive > 0) {
- for (int32 b = 0; b < debugWindows[w].numButtons; b++) {
- if (debugWindows[w].debugButtons[b].type == type) {
- int submenu = debugWindows[w].debugButtons[b].submenu;
- debugWindows[w].debugButtons[b].isActive = 0;
- if (submenu > 0) {
- debugWindows[submenu].debugButtons[b].isActive = !debugWindows[submenu].debugButtons[b].isActive;
- }
-
- return;
- }
+ if (debugWindows[w].isActive <= 0) {
+ continue;
+ }
+ for (int32 b = 0; b < debugWindows[w].numButtons; b++) {
+ if (debugWindows[w].debugButtons[b].type != type) {
+ continue;
+ }
+ int submenu = debugWindows[w].debugButtons[b].submenu;
+ debugWindows[w].debugButtons[b].isActive = 0;
+ if (submenu > 0) {
+ debugWindows[submenu].debugButtons[b].isActive = !debugWindows[submenu].debugButtons[b].isActive;
}
+ break;
}
}
}
@@ -312,12 +311,9 @@ void Debug::debugSetActions(int32 type) {
}
}
-void Debug::debugAddButton(int32 window, int32 left, int32 top, int32 right, int32 bottom, const char *text, int32 textLeft, int32 textTop, int32 isActive, int32 color, int32 activeColor, int32 submenu, int32 type) {
+void Debug::debugAddButton(int32 window, const Common::Rect &rect, const char *text, int32 textLeft, int32 textTop, int32 isActive, int32 color, int32 activeColor, int32 submenu, int32 type) {
int32 button = debugWindows[window].numButtons;
- debugWindows[window].debugButtons[button].left = left;
- debugWindows[window].debugButtons[button].top = top;
- debugWindows[window].debugButtons[button].right = right;
- debugWindows[window].debugButtons[button].bottom = bottom;
+ debugWindows[window].debugButtons[button].rect = rect;
debugWindows[window].debugButtons[button].text = text;
debugWindows[window].debugButtons[button].textLeft = textLeft;
debugWindows[window].debugButtons[button].textTop = textTop;
@@ -335,11 +331,8 @@ void Debug::debugAddWindowText(int32 window, const char *text) {
debugWindows[window].numLines++;
}
-void Debug::debugAddWindow(int32 left, int32 top, int32 right, int32 bottom, int32 alpha, int32 isActive) {
- debugWindows[numDebugWindows].left = left;
- debugWindows[numDebugWindows].top = top;
- debugWindows[numDebugWindows].right = right;
- debugWindows[numDebugWindows].bottom = bottom;
+void Debug::debugAddWindow(const Common::Rect &rect, int32 alpha, int32 isActive) {
+ debugWindows[numDebugWindows].rect = rect;
debugWindows[numDebugWindows].alpha = alpha;
debugWindows[numDebugWindows].numButtons = 0;
debugWindows[numDebugWindows].isActive = isActive;
@@ -348,17 +341,17 @@ void Debug::debugAddWindow(int32 left, int32 top, int32 right, int32 bottom, int
void Debug::debugLeftMenu() {
// left menu window
- debugAddWindow(5, 60, 200, 474, 4, 1);
- debugAddButton(0, 5, 55, 160, 75, "Use free camera", 30, 60, 0, 87, 119, NO_MENU, FREE_CAMERA);
- debugAddButton(0, 161, 55, 200, 75, "info", 171, 60, 0, 87, 119, FREE_CAMERA_INFO_MENU, -1);
- debugAddButton(0, 5, 76, 160, 96, "Change scenes", 30, 81, 0, 87, 119, NO_MENU, CHANGE_SCENE);
- debugAddButton(0, 161, 76, 200, 96, "info", 171, 81, 0, 87, 119, CHANGE_SCENE_INFO_MENU, -2);
- debugAddButton(0, 5, 97, 200, 117, "Show celling grids", 30, 102, 0, 87, 119, NO_MENU, 3);
- debugAddButton(0, 5, 118, 200, 138, "Show zones", 30, 123, 0, 87, 119, ZONES_MENU, SHOW_ZONES);
+ debugAddWindow(Common::Rect(5, 60, 200, 474), 4, 1);
+ debugAddButton(0, Common::Rect(5, 55, 160, 75), "Use free camera", 30, 60, 0, 87, 119, NO_MENU, FREE_CAMERA);
+ debugAddButton(0, Common::Rect(161, 55, 200, 75), "info", 171, 60, 0, 87, 119, FREE_CAMERA_INFO_MENU, -1);
+ debugAddButton(0, Common::Rect(5, 76, 160, 96), "Change scenes", 30, 81, 0, 87, 119, NO_MENU, CHANGE_SCENE);
+ debugAddButton(0, Common::Rect(161, 76, 200, 96), "info", 171, 81, 0, 87, 119, CHANGE_SCENE_INFO_MENU, -2);
+ debugAddButton(0, Common::Rect(5, 97, 200, 117), "Show celling grids", 30, 102, 0, 87, 119, NO_MENU, 3);
+ debugAddButton(0, Common::Rect(5, 118, 200, 138), "Show zones", 30, 123, 0, 87, 119, ZONES_MENU, SHOW_ZONES);
// add submenu windows
// - free camera window
- debugAddWindow(205, 55, 634, 160, 4, 0);
+ debugAddWindow(Common::Rect(205, 55, 634, 160), 4, 0);
debugAddWindowText(FREE_CAMERA_INFO_MENU, "When enable, use the following keys to browse through the scenes:");
debugAddWindowText(FREE_CAMERA_INFO_MENU, " - S to go North");
debugAddWindowText(FREE_CAMERA_INFO_MENU, " - X to go South");
@@ -366,27 +359,28 @@ void Debug::debugLeftMenu() {
debugAddWindowText(FREE_CAMERA_INFO_MENU, " - C to go East");
// - change scene window
- debugAddWindow(205, 55, 634, 137, 4, 0);
+ debugAddWindow(Common::Rect(205, 55, 634, 137), 4, 0);
debugAddWindowText(CHANGE_SCENE_INFO_MENU, "When enable, use the following keys to change to another scene:");
debugAddWindowText(CHANGE_SCENE_INFO_MENU, " - R to go Next Scene");
debugAddWindowText(CHANGE_SCENE_INFO_MENU, " - F to go Previous Scene");
// - zones window
- debugAddWindow(205, 55, 634, 97, 4, 0);
+ debugAddWindow(Common::Rect(205, 55, 634, 97), 4, 0);
debugAddWindowText(ZONES_MENU, "You can enable or disable each zone type:");
- debugAddButton(ZONES_MENU, 205, 118, 350, 138, "Cube Zones", 215, 123, 1, 87, 119, 0, SHOW_ZONE_CUBE);
- debugAddButton(ZONES_MENU, 205, 139, 350, 159, "Camera Zones", 215, 144, 2, 87, 119, 0, SHOW_ZONE_CAMERA);
- debugAddButton(ZONES_MENU, 205, 160, 350, 180, "Scenaric Zones", 215, 165, 3, 87, 119, 0, SHOW_ZONE_SCENARIC);
- debugAddButton(ZONES_MENU, 205, 181, 350, 201, "Celling Grid Zones", 215, 186, 4, 87, 119, 0, SHOW_ZONE_CELLINGGRID);
- debugAddButton(ZONES_MENU, 205, 202, 350, 222, "Object Zones", 215, 207, 5, 87, 119, 0, SHOW_ZONE_OBJECT);
- debugAddButton(ZONES_MENU, 205, 223, 350, 243, "Text Zones", 215, 228, 6, 87, 119, 0, SHOW_ZONE_TEXT);
- debugAddButton(ZONES_MENU, 205, 244, 350, 264, "Ladder Zones", 215, 249, 7, 87, 119, 0, SHOW_ZONE_LADDER);
+ debugAddButton(ZONES_MENU, Common::Rect(205, 118, 350, 138), "Cube Zones", 215, 123, 1, 87, 119, 0, SHOW_ZONE_CUBE);
+ debugAddButton(ZONES_MENU, Common::Rect(205, 139, 350, 159), "Camera Zones", 215, 144, 2, 87, 119, 0, SHOW_ZONE_CAMERA);
+ debugAddButton(ZONES_MENU, Common::Rect(205, 160, 350, 180), "Scenaric Zones", 215, 165, 3, 87, 119, 0, SHOW_ZONE_SCENARIC);
+ debugAddButton(ZONES_MENU, Common::Rect(205, 181, 350, 201), "Celling Grid Zones", 215, 186, 4, 87, 119, 0, SHOW_ZONE_CELLINGGRID);
+ debugAddButton(ZONES_MENU, Common::Rect(205, 202, 350, 222), "Object Zones", 215, 207, 5, 87, 119, 0, SHOW_ZONE_OBJECT);
+ debugAddButton(ZONES_MENU, Common::Rect(205, 223, 350, 243), "Text Zones", 215, 228, 6, 87, 119, 0, SHOW_ZONE_TEXT);
+ debugAddButton(ZONES_MENU, Common::Rect(205, 244, 350, 264), "Ladder Zones", 215, 249, 7, 87, 119, 0, SHOW_ZONE_LADDER);
}
int32 Debug::debugProcessButton(int32 x, int32 y) {
for (int32 i = 0; i < numDebugWindows; i++) {
for (int32 j = 0; j < debugWindows[i].numButtons; j++) {
- if (x > (debugWindows[i].debugButtons[j].left) && x < (debugWindows[i].debugButtons[j].right) && y > (debugWindows[i].debugButtons[j].top) && y < (debugWindows[i].debugButtons[j].bottom)) {
+ const Common::Rect &rect = debugWindows[i].debugButtons[j].rect;
+ if (x > rect.left && x < rect.right && y > rect.top && y < rect.bottom) {
return (debugWindows[i].debugButtons[j].type);
}
}
diff --git a/engines/twine/debug.h b/engines/twine/debug.h
index 92b5534bf7..e9f568e1d8 100644
--- a/engines/twine/debug.h
+++ b/engines/twine/debug.h
@@ -24,6 +24,7 @@
#define TWINE_DEBUG_H
#include "common/scummsys.h"
+#include "common/rect.h"
namespace TwinE {
@@ -50,10 +51,7 @@ enum WindowType {
};
struct DebugButtonStruct {
- int32 left = 0;
- int32 top = 0;
- int32 right = 0;
- int32 bottom = 0;
+ Common::Rect rect { 0, 0, 0, 0 };
const char *text = "";
int32 textLeft = 0;
int32 textTop = 0;
@@ -65,10 +63,7 @@ struct DebugButtonStruct {
};
struct DebugWindowStruct {
- int32 left = 0;
- int32 top = 0;
- int32 right = 0;
- int32 bottom = 0;
+ Common::Rect rect { 0, 0, 0, 0 };
int32 alpha = 0;
int32 isActive = 0;
int32 numLines = 0;
@@ -85,9 +80,9 @@ private:
DebugWindowStruct debugWindows[10];
int32 numDebugWindows = 0;
- void debugFillButton(int32 X, int32 Y, int32 width, int32 height, int8 color);
- void debugDrawButton(int32 left, int32 top, int32 right, int32 bottom, const char *text, int32 textLeft, int32 textRight, int32 isActive, int8 color);
- void debugDrawWindowBox(int32 left, int32 top, int32 right, int32 bottom, int32 alpha);
+ void debugFillButton(int32 x, int32 y, int32 width, int32 height, int8 color);
+ void debugDrawButton(const Common::Rect &rect, const char *text, int32 textLeft, int32 textRight, int32 isActive, int8 color);
+ void debugDrawWindowBox(const Common::Rect &rect, int32 alpha);
void debugDrawWindowButtons(int32 w);
void debugDrawWindow(int32 w);
int32 debugTypeUseMenu(int32 type);
@@ -98,11 +93,11 @@ private:
void debugRedrawScreen();
int32 debugGetActionsState(int32 type);
void debugSetActions(int32 type);
- void debugAddButton(int32 window, int32 left, int32 top, int32 right, int32 bottom, const char *text, int32 textLeft, int32 textTop, int32 isActive, int32 color, int32 activeColor, int32 submenu, int32 type);
+ void debugAddButton(int32 window, const Common::Rect &rect, const char *text, int32 textLeft, int32 textTop, int32 isActive, int32 color, int32 activeColor, int32 submenu, int32 type);
void debugAddWindowText(int32 window, const char *text);
- void debugAddWindow(int32 left, int32 top, int32 right, int32 bottom, int32 alpha, int32 isActive);
+ void debugAddWindow(const Common::Rect &rect, int32 alpha, int32 isActive);
void debugLeftMenu();
- int32 debugProcessButton(int32 X, int32 Y);
+ int32 debugProcessButton(int32 x, int32 y);
void debugPlasmaWindow(const char *text, int32 color);
void debugProcessWindow();
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index 4066f9b21c..0115016152 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -472,7 +472,7 @@ void Text::renderContinueReadingTriangle() {
_engine->_renderer->renderPolygons(POLYGONTYPE_FLAT, _dialTextStopColor);
- _engine->copyBlockPhys(left, top, right, bottom);
+ _engine->copyBlockPhys(Common::Rect(left, top, right, bottom));
}
void Text::fadeInCharacters(int32 counter, int32 fontColor) {
Commit: b1ce54a86e745552e2b64a51c194e9e8e236d885
https://github.com/scummvm/scummvm/commit/b1ce54a86e745552e2b64a51c194e9e8e236d885
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-25T19:41:52+01:00
Commit Message:
TWINE: reduced code duplication in debug window code
Changed paths:
engines/twine/debug.cpp
diff --git a/engines/twine/debug.cpp b/engines/twine/debug.cpp
index db99e4c082..63f29635c7 100644
--- a/engines/twine/debug.cpp
+++ b/engines/twine/debug.cpp
@@ -37,7 +37,7 @@ namespace TwinE {
void Debug::debugFillButton(int32 x, int32 y, int32 width, int32 height, int8 color) {
uint8 *ptr = (uint8 *)_engine->frontVideoBuffer.getBasePtr(x, y);
- int32 offset = SCREEN_WIDTH - width;
+ const int32 offset = SCREEN_WIDTH - width;
for (int32 i = 0; i < height; i++) {
for (int32 j = 0; j < width; j++) {
@@ -61,31 +61,32 @@ void Debug::debugDrawWindowBox(const Common::Rect &rect, int32 alpha) {
}
void Debug::debugDrawWindowButtons(int32 w) {
- int32 b;
-
- for (b = 0; b < debugWindows[w].numButtons; b++) {
- const char *text = debugWindows[w].debugButtons[b].text;
- int32 textLeft = debugWindows[w].debugButtons[b].textLeft;
- int32 textTop = debugWindows[w].debugButtons[b].textTop;
- int32 isActive = debugWindows[w].debugButtons[b].isActive;
- int8 color = debugWindows[w].debugButtons[b].color;
+ DebugWindowStruct &window = debugWindows[w];
+ for (int32 b = 0; b < window.numButtons; b++) {
+ DebugButtonStruct &btn = window.debugButtons[b];
+ const char *text = btn.text;
+ const int32 textLeft = btn.textLeft;
+ const int32 textTop = btn.textTop;
+ const int32 isActive = btn.isActive;
+ int8 color = btn.color;
if (isActive > 0) {
- color = debugWindows[w].debugButtons[b].activeColor;
+ color = btn.activeColor;
}
- debugDrawButton(debugWindows[w].debugButtons[b].rect, text, textLeft, textTop, isActive, color);
+ debugDrawButton(btn.rect, text, textLeft, textTop, isActive, color);
}
}
void Debug::debugDrawWindow(int32 w) {
- const Common::Rect &rect = debugWindows[w].rect;
- int32 alpha = debugWindows[w].alpha;
+ DebugWindowStruct &window = debugWindows[w];
+ const Common::Rect &rect = window.rect;
+ const int32 alpha = window.alpha;
debugDrawWindowBox(rect, alpha);
- if (debugWindows[w].numLines > 0) {
- for (int32 l = 0; l < debugWindows[w].numLines; l++) {
- _engine->drawText(rect.left + 10, rect.top + l * 20 + 5, debugWindows[w].text[l], 0);
+ if (window.numLines > 0) {
+ for (int32 l = 0; l < window.numLines; l++) {
+ _engine->drawText(rect.left + 10, rect.top + l * 20 + 5, window.text[l], 0);
}
}
@@ -96,14 +97,16 @@ void Debug::debugDrawWindow(int32 w) {
int32 Debug::debugTypeUseMenu(int32 type) {
for (int32 w = 0; w < numDebugWindows; w++) {
- if (debugWindows[w].isActive <= 0) {
+ DebugWindowStruct &window = debugWindows[w];
+ if (window.isActive <= 0) {
continue;
}
- for (int32 b = 0; b < debugWindows[w].numButtons; b++) {
- if (debugWindows[w].debugButtons[b].type != type) {
+ for (int32 b = 0; b < window.numButtons; b++) {
+ DebugButtonStruct &btn = window.debugButtons[b];
+ if (btn.type != type) {
continue;
}
- int submenu = debugWindows[w].debugButtons[b].submenu;
+ int submenu = btn.submenu;
if (submenu > 0) {
debugWindows[submenu].isActive = !debugWindows[submenu].isActive;
}
@@ -115,41 +118,45 @@ int32 Debug::debugTypeUseMenu(int32 type) {
void Debug::debugResetButtonsState() {
for (int32 w = 0; w < numDebugWindows; w++) {
- if (debugWindows[w].isActive <= 0) {
+ DebugWindowStruct &window = debugWindows[w];
+ if (window.isActive <= 0) {
continue;
}
- for (int32 b = 0; b < debugWindows[w].numButtons; b++) {
- if (debugWindows[w].debugButtons[b].type > -1) {
+ for (int32 b = 0; b < window.numButtons; b++) {
+ DebugButtonStruct &btn = window.debugButtons[b];
+ if (btn.type > -1) {
continue;
}
- debugWindows[w].debugButtons[b].isActive = 0;
+ btn.isActive = 0;
}
}
}
void Debug::debugRefreshButtons(int32 type) {
for (int32 w = 0; w < numDebugWindows; w++) {
- if (debugWindows[w].isActive <= 0) {
+ DebugWindowStruct &window = debugWindows[w];
+ if (window.isActive <= 0) {
continue;
}
- for (int32 b = 0; b < debugWindows[w].numButtons; b++) {
- if (debugWindows[w].debugButtons[b].type != type) {
+ for (int32 b = 0; b < window.numButtons; b++) {
+ DebugButtonStruct &btn = window.debugButtons[b];
+ if (btn.type != type) {
continue;
}
- const char *text = debugWindows[w].debugButtons[b].text;
- const int32 textLeft = debugWindows[w].debugButtons[b].textLeft;
- const int32 textTop = debugWindows[w].debugButtons[b].textTop;
- int8 color = debugWindows[w].debugButtons[b].color;
- const int32 isActive = debugWindows[w].debugButtons[b].isActive = !debugWindows[w].debugButtons[b].isActive;
+ const char *text = btn.text;
+ const int32 textLeft = btn.textLeft;
+ const int32 textTop = btn.textTop;
+ int8 color = btn.color;
+ const int32 isActive = btn.isActive = !btn.isActive;
if (isActive > 0) {
- color = debugWindows[w].debugButtons[b].activeColor;
+ color = btn.activeColor;
}
- debugDrawButton(debugWindows[w].debugButtons[b].rect, text, textLeft, textTop, isActive, color);
+ debugDrawButton(btn.rect, text, textLeft, textTop, isActive, color);
- if (debugWindows[w].debugButtons[b].submenu && isActive > 0) {
- debugDrawWindow(debugWindows[w].debugButtons[b].submenu);
+ if (btn.submenu && isActive > 0) {
+ debugDrawWindow(btn.submenu);
}
}
}
@@ -157,7 +164,8 @@ void Debug::debugRefreshButtons(int32 type) {
void Debug::debugDrawWindows() {
for (int32 w = 0; w < numDebugWindows; w++) {
- if (debugWindows[w].isActive > 0) {
+ DebugWindowStruct &window = debugWindows[w];
+ if (window.isActive > 0) {
debugDrawWindow(w);
}
}
@@ -165,15 +173,17 @@ void Debug::debugDrawWindows() {
void Debug::debugResetButton(int32 type) {
for (int32 w = 0; w < numDebugWindows; w++) {
- if (debugWindows[w].isActive <= 0) {
+ DebugWindowStruct &window = debugWindows[w];
+ if (window.isActive <= 0) {
continue;
}
- for (int32 b = 0; b < debugWindows[w].numButtons; b++) {
- if (debugWindows[w].debugButtons[b].type != type) {
+ for (int32 b = 0; b < window.numButtons; b++) {
+ DebugButtonStruct &btn = window.debugButtons[b];
+ if (btn.type != type) {
continue;
}
- int submenu = debugWindows[w].debugButtons[b].submenu;
- debugWindows[w].debugButtons[b].isActive = 0;
+ int submenu = btn.submenu;
+ btn.isActive = 0;
if (submenu > 0) {
debugWindows[submenu].debugButtons[b].isActive = !debugWindows[submenu].debugButtons[b].isActive;
}
@@ -312,16 +322,17 @@ void Debug::debugSetActions(int32 type) {
}
void Debug::debugAddButton(int32 window, const Common::Rect &rect, const char *text, int32 textLeft, int32 textTop, int32 isActive, int32 color, int32 activeColor, int32 submenu, int32 type) {
- int32 button = debugWindows[window].numButtons;
- debugWindows[window].debugButtons[button].rect = rect;
- debugWindows[window].debugButtons[button].text = text;
- debugWindows[window].debugButtons[button].textLeft = textLeft;
- debugWindows[window].debugButtons[button].textTop = textTop;
- debugWindows[window].debugButtons[button].isActive = debugGetActionsState(type);
- debugWindows[window].debugButtons[button].color = color;
- debugWindows[window].debugButtons[button].activeColor = activeColor;
- debugWindows[window].debugButtons[button].submenu = submenu;
- debugWindows[window].debugButtons[button].type = type;
+ const int32 button = debugWindows[window].numButtons;
+ DebugButtonStruct &btn = debugWindows[window].debugButtons[button];
+ btn.rect = rect;
+ btn.text = text;
+ btn.textLeft = textLeft;
+ btn.textTop = textTop;
+ btn.isActive = debugGetActionsState(type);
+ btn.color = color;
+ btn.activeColor = activeColor;
+ btn.submenu = submenu;
+ btn.type = type;
debugWindows[window].numButtons++;
}
@@ -380,8 +391,8 @@ int32 Debug::debugProcessButton(int32 x, int32 y) {
for (int32 i = 0; i < numDebugWindows; i++) {
for (int32 j = 0; j < debugWindows[i].numButtons; j++) {
const Common::Rect &rect = debugWindows[i].debugButtons[j].rect;
- if (x > rect.left && x < rect.right && y > rect.top && y < rect.bottom) {
- return (debugWindows[i].debugButtons[j].type);
+ if (rect.contains(x, y)) {
+ return debugWindows[i].debugButtons[j].type;
}
}
}
More information about the Scummvm-git-logs
mailing list