From cfca829e46d40381142c5f024d7f3c555a34564f Mon Sep 17 00:00:00 2001 From: Arnaud Boutonné Date: Fri, 28 Jan 2011 19:54:48 +0000 Subject: HUGO: Add a function to display exit hotspots in God Mode svn-id: r55599 --- engines/hugo/display.cpp | 32 ++++++++++++++++++++++++++++++-- engines/hugo/display.h | 1 + engines/hugo/hugo.cpp | 3 ++- 3 files changed, 33 insertions(+), 3 deletions(-) (limited to 'engines/hugo') diff --git a/engines/hugo/display.cpp b/engines/hugo/display.cpp index 8980a4570d..613371327f 100644 --- a/engines/hugo/display.cpp +++ b/engines/hugo/display.cpp @@ -486,7 +486,9 @@ void Screen::drawShape(int x, int y, int color1, int color2) { } } } - +/** +* Display rectangle (filles or empty) +*/ void Screen::drawRectangle(bool filledFl, int16 x1, int16 y1, int16 x2, int16 y2, int color) { assert(x1 <= x2); assert(y1 <= y2); @@ -496,10 +498,18 @@ void Screen::drawRectangle(bool filledFl, int16 x1, int16 y1, int16 x2, int16 y2 for (int j = x1; j < x2; j++) { _backBuffer[320 * i + j] = color; _frontBuffer[320 * i + j] = color; + _backBufferBackup[320 * i + j] = color; } } } else { - warning("STUB: drawRectangle()"); + for (int i = y1; i < y2; i++) { + _frontBuffer[320 * i + x1] = color; + _frontBuffer[320 * i + x2] = color; + } + for (int i = x1; i < x2; i++) { + _frontBuffer[320 * y1 + i] = color; + _frontBuffer[320 * y2 + i] = color; + } } } @@ -595,11 +605,29 @@ bool Screen::isInY(int16 y, rect_t *rect) { return (y >= rect->y) && (y <= rect->y + rect->dy); } +/** +* Check if two rectangles are over lapping +*/ bool Screen::isOverlaping(rect_t *rectA, rect_t *rectB) { return (isInX(rectA->x, rectB) || isInX(rectA->x + rectA->dx, rectB) || isInX(rectB->x, rectA) || isInX(rectB->x + rectB->dx, rectA)) && (isInY(rectA->y, rectB) || isInY(rectA->y + rectA->dy, rectB) || isInY(rectB->y, rectA) || isInY(rectB->y + rectB->dy, rectA)); } +/** +* Display exit hotspots in God Mode +*/ +void Screen::drawHotspots() { + if (!_vm->getGameStatus().godModeFl) + return; + + for (int i = 0; _vm->_hotspots[i].screenIndex >= 0; i++) { + hotspot_t *hotspot = &_vm->_hotspots[i]; + if (hotspot->screenIndex == _vm->_hero->screenIndex) + drawRectangle(false, hotspot->x1, hotspot->y1, hotspot->x2, hotspot->y2, _TLIGHTRED); + } + g_system->copyRectToScreen(_frontBuffer, 320, 0, 0, 320, 200); +} + Screen_v1d::Screen_v1d(HugoEngine *vm) : Screen(vm) { } diff --git a/engines/hugo/display.h b/engines/hugo/display.h index 2805061a42..454005b47a 100644 --- a/engines/hugo/display.h +++ b/engines/hugo/display.h @@ -97,6 +97,7 @@ public: void displayFrame(int sx, int sy, seq_t *seq, bool foreFl); void displayList(dupdate_t update, ...); void displayRect(int16 x, int16 y, int16 dx, int16 dy); + void drawHotspots(); void drawRectangle(bool filledFl, int16 x1, int16 y1, int16 x2, int16 y2, int color); void drawShape(int x, int y, int color1, int color2); void drawStatusText(); diff --git a/engines/hugo/hugo.cpp b/engines/hugo/hugo.cpp index 3f37bcb256..77b3dede50 100644 --- a/engines/hugo/hugo.cpp +++ b/engines/hugo/hugo.cpp @@ -254,6 +254,8 @@ Common::Error HugoEngine::run() { _status.doQuitFl = false; while (!_status.doQuitFl) { + _screen->drawHotspots(); + g_system->updateScreen(); _sound->pcspkr_player(); runMachine(); @@ -287,7 +289,6 @@ Common::Error HugoEngine::run() { } _mouse->mouseHandler(); // Mouse activity - adds to display list _screen->displayList(kDisplayDisplay); // Blit the display list to screen - _status.doQuitFl |= shouldQuit(); // update game quit flag } return Common::kNoError; -- cgit v1.2.3