From eaff9344a457d14a90175d8fe613d0cd952290f9 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 9 Jul 2006 09:40:44 +0000 Subject: Added OSystem::setFocusRectangle (first part of Nintendo DS patch) svn-id: r23449 --- engines/queen/display.cpp | 4 ++++ engines/queen/display.h | 6 ++++++ engines/queen/talk.cpp | 11 +++++++++++ engines/scumm/actor.cpp | 15 +++++++++++++++ engines/sky/logic.cpp | 12 ++++++++++++ engines/sky/screen.cpp | 4 ++++ engines/sky/screen.h | 4 ++++ 7 files changed, 56 insertions(+) (limited to 'engines') diff --git a/engines/queen/display.cpp b/engines/queen/display.cpp index 237c42e86e..5f57922817 100644 --- a/engines/queen/display.cpp +++ b/engines/queen/display.cpp @@ -851,6 +851,10 @@ void Display::clearTexts(uint16 y1, uint16 y2) { } } +void Display::setFocusRect(const Common::Rect& rect) { + _system->setFocusRectangle(rect); +} + int Display::textCenterX(const char *text) const { return (GAME_SCREEN_WIDTH - textWidth(text)) / 2; } diff --git a/engines/queen/display.h b/engines/queen/display.h index 6b8ea26011..8f81f11791 100644 --- a/engines/queen/display.h +++ b/engines/queen/display.h @@ -28,6 +28,9 @@ #include "queen/defs.h" class OSystem; +namespace Common { + struct Rect; +} namespace Queen { @@ -148,6 +151,9 @@ public: //! change the text color for the specified texts list entry void textColor(uint16 y, uint8 color) { _texts[y].color = color; } + + //! Set the focus rectangle to the speaking character + void setFocusRect(const Common::Rect& rect); int textCenterX(const char *text) const; uint16 textWidth(const char *text) const; diff --git a/engines/queen/talk.cpp b/engines/queen/talk.cpp index 223bd320f5..2b8d3c9508 100644 --- a/engines/queen/talk.cpp +++ b/engines/queen/talk.cpp @@ -21,6 +21,7 @@ */ #include "common/stdafx.h" +#include "common/rect.h" #include "queen/talk.h" #include "queen/bankman.h" @@ -865,6 +866,16 @@ void Talk::speakSegment( textY = bob->y; } + // Set the focus rectangle + // FIXME: This may not be correct! + BobFrame *pbf = _vm->bankMan()->fetchFrame(bob->frameNum); + + int height = (pbf->height * bob->scale) / 100; + + Common::Rect focus(textX - 96, textY - height - 64, textX + 96, textY + height + 64); + _vm->display()->setFocusRect(focus); + + //int SF = _vm->grid()->findScale(textX, textY); const SpeechParameters *parameters = NULL; diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp index 70dc9a2316..fb89554247 100644 --- a/engines/scumm/actor.cpp +++ b/engines/scumm/actor.cpp @@ -22,6 +22,7 @@ */ #include "common/stdafx.h" +#include "common/system.h" // for setFocusRectangle/clearFocusRectangle #include "scumm/scumm.h" #include "scumm/actor.h" #include "scumm/akos.h" @@ -844,6 +845,20 @@ int ScummEngine::getTalkingActor() { } void ScummEngine::setTalkingActor(int value) { + + if (value == 255) { + _system->clearFocusRectangle(); + } else { + // Work out the screen co-ordinates of the actor + int x = _actors[value]._pos.x - (camera._cur.x - (_screenWidth >> 1)); + int y = _actors[value]._top - (camera._cur.y - (_screenHeight >> 1)); + + // 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); + } + if (_game.id == GID_MANIAC && _game.version <= 1 && !(_game.platform == Common::kPlatformNES)) _V1TalkingActor = value; else diff --git a/engines/sky/logic.cpp b/engines/sky/logic.cpp index 7d2d91f9b6..bbe01a5576 100644 --- a/engines/sky/logic.cpp +++ b/engines/sky/logic.cpp @@ -22,6 +22,7 @@ #include "common/stdafx.h" #include "common/endian.h" +#include "common/rect.h" #include "sky/autoroute.h" #include "sky/compact.h" @@ -2512,6 +2513,17 @@ void Logic::stdSpeak(Compact *target, uint32 textNum, uint32 animNum, uint32 bas if (SkyEngine::isCDVersion()) speechFileFound = _skySound->startSpeech((uint16)textNum); + + // Calculate the point where the character is + int x = (((uint32) (target->xcood)) * GAME_SCREEN_WIDTH) >> 9; + int y = ((((uint32) (target->ycood)) * GAME_SCREEN_HEIGHT) >> 9); + + // Set the focus region to that area + // 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); + + if ((SkyEngine::_systemVars.systemFlags & SF_ALLOW_TEXT) || !speechFileFound) { // form the text sprite, if player wants subtitles or // if we couldn't find the speech file diff --git a/engines/sky/screen.cpp b/engines/sky/screen.cpp index 1b262f5659..3cf545b001 100644 --- a/engines/sky/screen.cpp +++ b/engines/sky/screen.cpp @@ -105,6 +105,10 @@ void Screen::clearScreen(void) { _system->updateScreen(); } +void Screen::setFocusRectangle(const Common::Rect& rect) { + _system->setFocusRectangle(rect); +} + //set a new palette, pal is a pointer to dos vga rgb components 0..63 void Screen::setPalette(uint8 *pal) { diff --git a/engines/sky/screen.h b/engines/sky/screen.h index c1e504a87f..f412d31c4c 100644 --- a/engines/sky/screen.h +++ b/engines/sky/screen.h @@ -28,6 +28,9 @@ #include "sky/skydefs.h" class OSystem; +namespace Common { + struct Rect; +} namespace Sky { @@ -80,6 +83,7 @@ public: void fnFadeDown(uint32 scroll); void fnDrawScreen(uint32 palette, uint32 scroll); void clearScreen(void); + void setFocusRectangle(const Common::Rect& rect); void recreate(void); void flip(bool doUpdate = true); -- cgit v1.2.3