aboutsummaryrefslogtreecommitdiff
path: root/engines/sherlock/tattoo
diff options
context:
space:
mode:
authorPaul Gilbert2015-06-30 08:29:09 -0400
committerPaul Gilbert2015-06-30 08:29:09 -0400
commit2664ee63141a18283984e2e1c9325a1362c2133c (patch)
tree916e7247aad3ea51b1e1b067c9710d0cb85098a0 /engines/sherlock/tattoo
parent9ef857bc6fdad24420872aa9dab91505cb6acfbf (diff)
downloadscummvm-rg350-2664ee63141a18283984e2e1c9325a1362c2133c.tar.gz
scummvm-rg350-2664ee63141a18283984e2e1c9325a1362c2133c.tar.bz2
scummvm-rg350-2664ee63141a18283984e2e1c9325a1362c2133c.zip
SHERLOCK: RT: Create a tooltip base clsas
Diffstat (limited to 'engines/sherlock/tattoo')
-rw-r--r--engines/sherlock/tattoo/widget_base.cpp2
-rw-r--r--engines/sherlock/tattoo/widget_base.h3
-rw-r--r--engines/sherlock/tattoo/widget_inventory.cpp4
-rw-r--r--engines/sherlock/tattoo/widget_inventory.h2
-rw-r--r--engines/sherlock/tattoo/widget_tooltip.cpp38
-rw-r--r--engines/sherlock/tattoo/widget_tooltip.h21
6 files changed, 58 insertions, 12 deletions
diff --git a/engines/sherlock/tattoo/widget_base.cpp b/engines/sherlock/tattoo/widget_base.cpp
index b3c089bf6a..b958053286 100644
--- a/engines/sherlock/tattoo/widget_base.cpp
+++ b/engines/sherlock/tattoo/widget_base.cpp
@@ -61,7 +61,7 @@ void WidgetBase::erase() {
screen._backBuffer1.blitFrom(screen._backBuffer2, Common::Point(oldBounds.left, oldBounds.top), oldBounds);
screen.blitFrom(screen._backBuffer1, Common::Point(_oldBounds.left, _oldBounds.top), oldBounds);
- // Reset the old bounds so
+ // Reset the old bounds so it won't be erased again
_oldBounds = Common::Rect(0, 0, 0, 0);
}
}
diff --git a/engines/sherlock/tattoo/widget_base.h b/engines/sherlock/tattoo/widget_base.h
index 2e57e74d83..f5ac2ea52b 100644
--- a/engines/sherlock/tattoo/widget_base.h
+++ b/engines/sherlock/tattoo/widget_base.h
@@ -36,11 +36,10 @@ class ImageFile;
namespace Tattoo {
class WidgetBase {
-private:
- Common::Rect _oldBounds;
protected:
SherlockEngine *_vm;
Common::Rect _bounds;
+ Common::Rect _oldBounds;
Surface _surface;
bool _outsideMenu;
diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp
index 30a8c3cf10..b4a6daabc2 100644
--- a/engines/sherlock/tattoo/widget_inventory.cpp
+++ b/engines/sherlock/tattoo/widget_inventory.cpp
@@ -36,7 +36,7 @@ namespace Tattoo {
#define MAX_INV_COMMANDS 10 // Maximum elements in dialog
WidgetInventoryTooltip::WidgetInventoryTooltip(SherlockEngine *vm, WidgetInventory *owner) :
- WidgetBase(vm), _owner(owner) {
+ WidgetTooltipBase(vm), _owner(owner) {
}
void WidgetInventoryTooltip::setText(const Common::String &str) {
@@ -48,7 +48,7 @@ void WidgetInventoryTooltip::setText(const Common::String &str) {
}
int width = _surface.stringWidth(str) + 2;
- int height;
+ int height = 0;
Common::String line1 = str, line2;
// See if we need to split it into two lines
diff --git a/engines/sherlock/tattoo/widget_inventory.h b/engines/sherlock/tattoo/widget_inventory.h
index 99086ad801..77caddf86b 100644
--- a/engines/sherlock/tattoo/widget_inventory.h
+++ b/engines/sherlock/tattoo/widget_inventory.h
@@ -37,7 +37,7 @@ namespace Tattoo {
class WidgetInventory;
-class WidgetInventoryTooltip: public WidgetBase {
+class WidgetInventoryTooltip: public WidgetTooltipBase {
private:
WidgetInventory *_owner;
Common::Rect _oldInvGraphicBounds, _invGraphicBounds;
diff --git a/engines/sherlock/tattoo/widget_tooltip.cpp b/engines/sherlock/tattoo/widget_tooltip.cpp
index 69df7e0ede..5c4478d32b 100644
--- a/engines/sherlock/tattoo/widget_tooltip.cpp
+++ b/engines/sherlock/tattoo/widget_tooltip.cpp
@@ -31,7 +31,43 @@ namespace Tattoo {
#define MAX_TOOLTIP_WIDTH 150
-WidgetTooltip::WidgetTooltip(SherlockEngine *vm) : WidgetBase(vm) {
+void WidgetTooltipBase::draw() {
+ Screen &screen = *_vm->_screen;
+ const Common::Point &currentScroll = getCurrentScroll();
+
+ // 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()) {
+ // Blit the affected area to the screen
+ screen.slamRect(_bounds, currentScroll);
+
+ // Draw the widget directly onto the screen. Unlike other widgets, we don't draw to the back buffer,
+ // since nothing should be drawing on top of tooltips, so there's no need to store in the back buffer
+ screen.transBlitFrom(_surface, Common::Point(_bounds.left, _bounds.top));
+
+ // Store a copy of the drawn area for later erasing
+ _oldBounds = _bounds;
+ }
+}
+
+void WidgetTooltipBase::erase() {
+ Screen &screen = *_vm->_screen;
+ const Common::Point &currentScroll = getCurrentScroll();
+
+ if (_oldBounds.width() > 0) {
+ // Restore the affected area from the back buffer to the screen
+ screen.slamRect(_oldBounds, currentScroll);
+
+ // Reset the old bounds so it won't be erased again
+ _oldBounds = Common::Rect(0, 0, 0, 0);
+ }
+}
+
+/*----------------------------------------------------------------*/
+
+WidgetTooltip::WidgetTooltip(SherlockEngine *vm) : WidgetTooltipBase (vm) {
}
void WidgetTooltip::setText(const Common::String &str) {
diff --git a/engines/sherlock/tattoo/widget_tooltip.h b/engines/sherlock/tattoo/widget_tooltip.h
index 32e54ed2bb..38d3ad9efd 100644
--- a/engines/sherlock/tattoo/widget_tooltip.h
+++ b/engines/sherlock/tattoo/widget_tooltip.h
@@ -33,12 +33,23 @@ class SherlockEngine;
namespace Tattoo {
-class WidgetTooltip: public WidgetBase {
-protected:
+class WidgetTooltipBase : public WidgetBase {
+public:
+ WidgetTooltipBase(SherlockEngine *vm) : WidgetBase(vm) {}
+ virtual ~WidgetTooltipBase() {}
+
/**
- * Overriden from base class, since tooltips have a completely transparent background
- */
- virtual void drawBackground() {}
+ * Erase any previous display of the widget on the screen
+ */
+ virtual void erase();
+
+ /**
+ * Update the display of the widget on the screen
+ */
+ virtual void draw();
+};
+
+class WidgetTooltip: public WidgetTooltipBase {
public:
WidgetTooltip(SherlockEngine *vm);
virtual ~WidgetTooltip() {}