aboutsummaryrefslogtreecommitdiff
path: root/engines/sherlock
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sherlock')
-rw-r--r--engines/sherlock/events.cpp59
-rw-r--r--engines/sherlock/events.h2
-rw-r--r--engines/sherlock/tattoo/widget_inventory.cpp2
-rw-r--r--engines/sherlock/tattoo/widget_lab.cpp6
4 files changed, 42 insertions, 27 deletions
diff --git a/engines/sherlock/events.cpp b/engines/sherlock/events.cpp
index cb8a4288f2..456f055e1a 100644
--- a/engines/sherlock/events.cpp
+++ b/engines/sherlock/events.cpp
@@ -101,36 +101,48 @@ void Events::setCursor(const Graphics::Surface &src, int hotspotX, int hotspotY)
showCursor();
}
-void Events::setCursor(CursorId cursorId, const Graphics::Surface &surface) {
+void Events::setCursor(CursorId cursorId, const Common::Point &cursorPos, const Graphics::Surface &surface) {
_cursorId = cursorId;
- int hotspotX, hotspotY;
- if (cursorId == MAGNIFY) {
- hotspotX = 8;
- hotspotY = 8;
- } else {
- hotspotX = 0;
- hotspotY = 0;
- }
-
// Get the standard cursor frame
- Graphics::Surface &surface2 = (*_cursorImages)[cursorId]._frame;
-
- // Form a single surface containing both frames
- int maxWidth = MAX(surface.w, surface2.w);
- Graphics::Surface s;
- s.create(maxWidth, surface.h + surface2.h, Graphics::PixelFormat::createFormatCLUT8());
- s.fillRect(Common::Rect(0, 0, maxWidth, surface.h + surface2.h), TRANSPARENCY);
+ Graphics::Surface &cursorImg = (*_cursorImages)[cursorId]._frame;
- s.copyRectToSurface(surface, (maxWidth - surface.w) / 2, 0, Common::Rect(0, 0, surface.w, surface.h));
- s.copyRectToSurface(surface2, (maxWidth - surface2.w) / 2, surface.h, Common::Rect(0, 0, surface2.w, surface2.h));
+ // If the X pos for the cursor image is -100, this is a special value to indicate
+ // the cursor should be horizontally centered
+ Common::Point cursorPt = cursorPos;
+ if (cursorPos.x == -100)
+ cursorPt.x = (surface.w - cursorImg.w) / 2;
- // Adjust hotspot position
- hotspotX += (maxWidth - surface2.w) / 2;
- hotspotY += surface.h;
+ // Figure total bounds needed for cursor image and passed image
+ Common::Rect bounds(surface.w, surface.h);
+ bounds.extend(Common::Rect(cursorPt.x, cursorPt.y, cursorPt.x + cursorImg.w, cursorPt.y + cursorImg.h));
+ Common::Rect r = bounds;
+ r.moveTo(0, 0);
+ // Form a single surface containing both frames
+ Graphics::Surface s;
+ s.create(r.width(), r.height(), Graphics::PixelFormat::createFormatCLUT8());
+ s.fillRect(r, TRANSPARENCY);
+
+ // Draw the passed image
+ Common::Point drawPos;
+ if (cursorPt.x < 0)
+ drawPos.x = -cursorPt.x;
+ if (cursorPt.y < 0)
+ drawPos.y = -cursorPt.y;
+ s.copyRectToSurface(surface, drawPos.x, drawPos.y, Common::Rect(0, 0, surface.w, surface.h));
+
+ // Draw the cursor image
+ drawPos = Common::Point(MAX(cursorPt.x, (int16)0), MAX(cursorPt.y, (int16)0));
+ s.copyRectToSurface(cursorImg, drawPos.x, drawPos.y, Common::Rect(0, 0, cursorImg.w, cursorImg.h));
+
+ // Set up hotspot position for cursor, adjusting for cursor image's position within the surface
+ Common::Point hotspot;
+ if (cursorId == MAGNIFY)
+ hotspot = Common::Point(8, 8);
+ hotspot += drawPos;
// Set the cursor
- setCursor(s, hotspotX, hotspotY);
+ setCursor(s, hotspot.x, hotspot.y);
}
void Events::animateCursorIfNeeded() {
@@ -140,7 +152,6 @@ void Events::animateCursorIfNeeded() {
}
}
-
void Events::showCursor() {
CursorMan.showMouse(true);
}
diff --git a/engines/sherlock/events.h b/engines/sherlock/events.h
index 9718a30fd3..15724ad60f 100644
--- a/engines/sherlock/events.h
+++ b/engines/sherlock/events.h
@@ -83,7 +83,7 @@ public:
/**
* Set both a standard cursor as well as an inventory item above it
*/
- void setCursor(CursorId cursorId, const Graphics::Surface &surface);
+ void setCursor(CursorId cursorId, const Common::Point &cursorPos, const Graphics::Surface &surface);
/**
* Animates the mouse cursor if the Wait cursor is showing
diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp
index 170fb02481..c2de61fda8 100644
--- a/engines/sherlock/tattoo/widget_inventory.cpp
+++ b/engines/sherlock/tattoo/widget_inventory.cpp
@@ -428,7 +428,7 @@ void WidgetInventoryVerbs::handleEvents() {
if (ui._menuMode == INV_MODE) {
// Add the inventory item to the cursor
ImageFrame &imgFrame = (*inv._invShapes[_owner->_invSelect - inv._invIndex])[0];
- events.setCursor(ARROW, imgFrame._frame);
+ events.setCursor(ARROW, Common::Point(-100, imgFrame._height), imgFrame._frame);
// Close the inventory dialog without banishing it, so it can keep getting events
// to handle tooltips and actually making the selection of what object to use them item on
diff --git a/engines/sherlock/tattoo/widget_lab.cpp b/engines/sherlock/tattoo/widget_lab.cpp
index 5824977e04..2572b7a693 100644
--- a/engines/sherlock/tattoo/widget_lab.cpp
+++ b/engines/sherlock/tattoo/widget_lab.cpp
@@ -42,6 +42,8 @@ void WidgetLab::handleEvents() {
Events &events = *_vm->_events;
Scene &scene = *_vm->_scene;
TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
+ Common::Point mousePos = events.mousePos();
+
WidgetBase::handleEvents();
bool noDesc = false;
@@ -146,7 +148,9 @@ void WidgetLab::handleEvents() {
// Set the mouse cursor to the object
Graphics::Surface &img = _labObject->_imageFrame->_frame;
- events.setCursor(img, img.w / 2, img.h / 2);
+ Common::Point cursorOffset = mousePos - _labObject->_position;
+ events.setCursor(ARROW, cursorOffset, img);
+ warning("%d,%d", cursorOffset.x, cursorOffset.y);//**DEBUG****
// Hide this object until they are done with it (releasing it)
_labObject->toggleHidden();