aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sherlock/tattoo/tattoo_user_interface.cpp5
-rw-r--r--engines/sherlock/tattoo/widget_base.cpp29
-rw-r--r--engines/sherlock/tattoo/widget_base.h14
-rw-r--r--engines/sherlock/tattoo/widget_tooltip.cpp45
-rw-r--r--engines/sherlock/tattoo/widget_tooltip.h14
5 files changed, 54 insertions, 53 deletions
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.cpp b/engines/sherlock/tattoo/tattoo_user_interface.cpp
index d7de2de6cf..d12f0e7a02 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.cpp
+++ b/engines/sherlock/tattoo/tattoo_user_interface.cpp
@@ -322,9 +322,6 @@ void TattooUserInterface::drawInterface(int bufferNum) {
_oldInvMenuBounds.left = _oldInvMenuBounds.top = _oldInvMenuBounds.right = _oldInvMenuBounds.bottom = 0;
}
- // Clear the tooltip if necessary
- _tooltipWidget.erase();
-
// See if we need to flush areas assocaited with the inventory graphic
if (_oldInvGraphicBounds.right) {
screen.slamArea(_oldInvGraphicBounds.left - _currentScroll.x, _oldInvGraphicBounds.top,
@@ -360,7 +357,7 @@ void TattooUserInterface::doBgAnimRestoreUI() {
screen._backBuffer1.blitFrom(screen._backBuffer2, Common::Point(_invMenuBounds.left, _invMenuBounds.top), _invMenuBounds);
// If there is a Text Tag being display, restore the area underneath it
- _tooltipWidget.erasePrevious();
+ _tooltipWidget.erase();
// If there is an Inventory being shown, restore the graphics underneath it
if (_oldInvGraphicBounds.width() > 0)
diff --git a/engines/sherlock/tattoo/widget_base.cpp b/engines/sherlock/tattoo/widget_base.cpp
index 0fddb2759c..adb09d5404 100644
--- a/engines/sherlock/tattoo/widget_base.cpp
+++ b/engines/sherlock/tattoo/widget_base.cpp
@@ -44,6 +44,35 @@ void WidgetBase::banishWindow() {
_surface.free();
}
+void WidgetBase::erase() {
+ Screen &screen = *_vm->_screen;
+
+ if (_oldBounds.width() > 0) {
+ screen._backBuffer1.blitFrom(screen._backBuffer2, Common::Point(_oldBounds.left, _oldBounds.top), _oldBounds);
+ screen.slamRect(_oldBounds);
+
+ _oldBounds = Common::Rect(0, 0, 0, 0);
+ }
+}
+
+void WidgetBase::draw() {
+ Screen &screen = *_vm->_screen;
+
+ // If there was a previously drawn frame in a different position that hasn't yet been erased, then erase it
+ if (_oldBounds.width() > 0 && _oldBounds != _bounds)
+ erase();
+
+ if (_bounds.width() > 0 && !_surface.empty()) {
+ // Copy any area to be drawn on from the secondary back buffer, and then draw surface on top
+ screen._backBuffer1.blitFrom(screen._backBuffer2, Common::Point(_bounds.left, _bounds.top), _bounds);
+ screen._backBuffer1.transBlitFrom(_surface, Common::Point(_bounds.left, _bounds.top));
+ screen.slamRect(_bounds);
+
+ // Store a copy of the drawn area for later erasing
+ _oldBounds = _bounds;
+ }
+}
+
Common::String WidgetBase::splitLines(const Common::String &str, Common::StringArray &lines, int maxWidth, uint maxLines) {
Talk &talk = *_vm->_talk;
const char *strP = str.c_str();
diff --git a/engines/sherlock/tattoo/widget_base.h b/engines/sherlock/tattoo/widget_base.h
index 4b7ae2ebde..5eacad610b 100644
--- a/engines/sherlock/tattoo/widget_base.h
+++ b/engines/sherlock/tattoo/widget_base.h
@@ -36,9 +36,11 @@ class ImageFile;
namespace Tattoo {
class WidgetBase {
+private:
+ Common::Rect _oldBounds;
protected:
SherlockEngine *_vm;
- Common::Rect _bounds, _oldBounds;
+ Common::Rect _bounds;
Surface _surface;
ImageFile *_images;
bool _outsideMenu;
@@ -59,6 +61,16 @@ public:
virtual ~WidgetBase() {}
/**
+ * Erase any previous display of the widget on the screen
+ */
+ void erase();
+
+ /**
+ * Update the display of the widget on the screen
+ */
+ void draw();
+
+ /**
* Summon the window
*/
virtual void summonWindow();
diff --git a/engines/sherlock/tattoo/widget_tooltip.cpp b/engines/sherlock/tattoo/widget_tooltip.cpp
index 2e55d4bfff..69a9300b34 100644
--- a/engines/sherlock/tattoo/widget_tooltip.cpp
+++ b/engines/sherlock/tattoo/widget_tooltip.cpp
@@ -117,36 +117,15 @@ void WidgetTooltip::setText(const Common::String &str) {
}
}
-void WidgetTooltip::draw() {
- Screen &screen = *_vm->_screen;
-
- if (!_surface.empty())
- screen._backBuffer1.transBlitFrom(_surface, Common::Point(_bounds.left, _bounds.top));
-}
-
-void WidgetTooltip::erase() {
- Screen &screen = *_vm->_screen;
- TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
-
- if (_bounds.width() > 0) {
- screen.slamArea(_oldBounds.left - ui._currentScroll.x, _oldBounds.top, _oldBounds.width(), _oldBounds.height());
-
- // If there's no text actually being displayed, then reset bounds so we don't keep restoring the area
- if (_surface.empty()) {
- _bounds.left = _bounds.top = _bounds.right = _bounds.bottom = 0;
- _oldBounds.left = _oldBounds.top = _oldBounds.right = _oldBounds.bottom = 0;
- }
- }
+void WidgetTooltip::handleEvents() {
+ Events &events = *_vm->_events;
+ Common::Point mousePos = events.mousePos();
- if (!_surface.empty())
- screen.slamArea(_bounds.left - ui._currentScroll.x, _bounds.top, _bounds.width(), _bounds.height());
-}
+ // Set the new position for the tooltip
+ int xp = CLIP(mousePos.x - _bounds.width() / 2, 0, SHERLOCK_SCREEN_WIDTH - _bounds.width());
+ int yp = MAX(mousePos.y - _bounds.height(), 0);
-void WidgetTooltip::erasePrevious() {
- Screen &screen = *_vm->_screen;
- if (_oldBounds.width() > 0)
- screen._backBuffer1.blitFrom(screen._backBuffer2, Common::Point(_oldBounds.left, _oldBounds.top),
- _oldBounds);
+ _bounds.moveTo(xp, yp);
}
/*----------------------------------------------------------------*/
@@ -155,17 +134,13 @@ void WidgetSceneTooltip::handleEvents() {
Events &events = *_vm->_events;
People &people = *_vm->_people;
Scene &scene = *_vm->_scene;
- Screen &screen = *_vm->_screen;
TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
Common::Point mousePos = events.mousePos();
// See if thay are pointing at a different object and we need to regenerate the tooltip text
if (ui._bgFound != ui._oldBgFound || (ui._bgFound != -1 && _surface.empty()) ||
ui._arrowZone != ui._oldArrowZone || (ui._arrowZone != -1 && _surface.empty())) {
- // Keep track of the last place we drew the text
- _oldBounds = _bounds;
-
- // See if there is a new object to be displayed
+ // See if there is a new object to display text for
if ((ui._bgFound != -1 && (ui._bgFound != ui._oldBgFound || (ui._bgFound != -1 && _surface.empty()))) ||
(ui._arrowZone != -1 && (ui._arrowZone != ui._oldArrowZone || (ui._arrowZone != -1 && _surface.empty())))) {
Common::String str;
@@ -189,10 +164,8 @@ void WidgetSceneTooltip::handleEvents() {
ui._oldBgFound = ui._bgFound;
} else {
- // Keep track of the last place we drew the Text
- _oldBounds = _bounds;
- // Set the New position of the Text Tag
+ // Set the new position for the tooltip
int tagX = CLIP(mousePos.x - _bounds.width() / 2, 0, SHERLOCK_SCREEN_WIDTH - _bounds.width());
int tagY = MAX(mousePos.y - _bounds.height(), 0);
diff --git a/engines/sherlock/tattoo/widget_tooltip.h b/engines/sherlock/tattoo/widget_tooltip.h
index ae93f15f1b..a44faac875 100644
--- a/engines/sherlock/tattoo/widget_tooltip.h
+++ b/engines/sherlock/tattoo/widget_tooltip.h
@@ -44,19 +44,9 @@ public:
void setText(const Common::String &str);
/**
- * Draw the tooltip if necessary
- */
- void draw();
-
- /**
- * Erase the area covered by the tooltip if it's active
- */
- void erase();
-
- /**
- * Erase any area of the screen drawn by the tooltip in the previous frame
+ * Handle updating the tooltip state
*/
- void erasePrevious();
+ virtual void handleEvents();
};
class WidgetSceneTooltip : public WidgetTooltip {