diff options
-rw-r--r-- | common/rect.h | 9 | ||||
-rw-r--r-- | engines/scumm/actor.cpp | 3 | ||||
-rw-r--r-- | engines/sky/logic.cpp | 3 | ||||
-rw-r--r-- | engines/sword2/function.cpp | 3 |
4 files changed, 11 insertions, 7 deletions
diff --git a/common/rect.h b/common/rect.h index b4355052f6..2230111538 100644 --- a/common/rect.h +++ b/common/rect.h @@ -189,7 +189,7 @@ struct Rect { } void translate(int16 dx, int16 dy) { - left += dx; right += dx; + left += dx; right += dx; top += dy; bottom += dy; } @@ -200,6 +200,13 @@ struct Rect { void debugPrint(int debuglevel = 0, const char *caption = "Rect:") const { debug(debuglevel, "%s %d, %d, %d, %d", caption, left, top, right, bottom); } + + /*! @brief create a rectangle around the given center */ + static Rect center(int16 cx, int16 cy, int16 w, int16 h) { + w /= 2; + h /= 2; + return Rect(cx - w, cy - h, cx + w, cy + h); + } }; } // End of namespace Common diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp index fd330c02bc..8e3526f9f6 100644 --- a/engines/scumm/actor.cpp +++ b/engines/scumm/actor.cpp @@ -1827,8 +1827,7 @@ void ScummEngine::setTalkingActor(int i) { // Set the focus area to the calculated position // TODO: Make the size adjust depending on what it's focusing on. - Common::Rect rect(x - 96, y - 64, x + 96, y + 64); - _system->setFocusRectangle(rect); + _system->setFocusRectangle(Common::Rect::center(x, y, 192, 128)); } if (_game.id == GID_MANIAC && _game.version <= 1 && !(_game.platform == Common::kPlatformNES)) diff --git a/engines/sky/logic.cpp b/engines/sky/logic.cpp index 773e64ae97..0242b2a99e 100644 --- a/engines/sky/logic.cpp +++ b/engines/sky/logic.cpp @@ -2525,8 +2525,7 @@ void Logic::stdSpeak(Compact *target, uint32 textNum, uint32 animNum, uint32 bas int x = target->xcood - TOP_LEFT_X; int y = target->ycood - TOP_LEFT_Y; // TODO: Make the box size change based on the object that has the focus - Common::Rect rect(x - 96, y - 64, x + 96, y + 64); - _skyScreen->setFocusRectangle(rect); + _skyScreen->setFocusRectangle(Common::Rect::center(x, y, 192, 128)); if ((SkyEngine::_systemVars.systemFlags & SF_ALLOW_TEXT) || !speechFileFound) { diff --git a/engines/sword2/function.cpp b/engines/sword2/function.cpp index f09ca0cd1b..99211c3ece 100644 --- a/engines/sword2/function.cpp +++ b/engines/sword2/function.cpp @@ -925,8 +925,7 @@ int32 Logic::fnISpeak(int32 *params) { // position. if (_animId) { - Common::Rect rect(_textX - 96, _textY - 64, _textX + 96, _textY + 64); - _vm->_system->setFocusRectangle(rect); + _vm->_system->setFocusRectangle(Common::Rect::center(_textX, _textY, 192, 128)); } // Is it to be speech or subtitles or both? |