aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/support
diff options
context:
space:
mode:
authorPaul Gilbert2017-08-08 22:24:22 -0400
committerPaul Gilbert2017-08-08 22:24:22 -0400
commit660f7bf11479222689cf77060077fe47d65a465e (patch)
tree48798a2d991a3d9bb533efeb42ca41d9b485d5f1 /engines/titanic/support
parent6fac0ace2c844aa68c2482362021981ed1db931b (diff)
downloadscummvm-rg350-660f7bf11479222689cf77060077fe47d65a465e.tar.gz
scummvm-rg350-660f7bf11479222689cf77060077fe47d65a465e.tar.bz2
scummvm-rg350-660f7bf11479222689cf77060077fe47d65a465e.zip
TITANIC: Further improvements to arrow key movement
The movement code, when deciding on an item or link that matches the desired direction, will check five points on the object/links area.. center, left edge, right edge, top edge, and bottom edge. For each of these, it makes sure that at that point, clicking will actually get passed to it. Otherwise, it moves onto one of the other edges. This helps avoid issues where links weren't working because standard scene objects were partially obscuring them.
Diffstat (limited to 'engines/titanic/support')
-rw-r--r--engines/titanic/support/rect.cpp18
-rw-r--r--engines/titanic/support/rect.h9
2 files changed, 27 insertions, 0 deletions
diff --git a/engines/titanic/support/rect.cpp b/engines/titanic/support/rect.cpp
index b39ffc1c45..f7f8f14d2f 100644
--- a/engines/titanic/support/rect.cpp
+++ b/engines/titanic/support/rect.cpp
@@ -42,4 +42,22 @@ void Rect::constrain(const Rect &r) {
}
}
+Point Rect::getPoint(Quadrant quadrant) {
+ if (isEmpty())
+ return Point(left, top);
+
+ switch (quadrant) {
+ case Q_LEFT:
+ return Point(MIN(left + 10, (int)right), (top + bottom) / 2);
+ case Q_RIGHT:
+ return Point(MAX(right - 10, (int)left), (top + bottom) / 2);
+ case Q_TOP:
+ return Point((left + right) / 2, MIN(top + 10, (int)bottom));
+ case Q_BOTTOM:
+ return Point((left + right) / 2, MAX(bottom - 10, (int)top));
+ default:
+ return Point((left + right) / 2, (top + bottom) / 2);
+ }
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/support/rect.h b/engines/titanic/support/rect.h
index 1661711870..eca256df56 100644
--- a/engines/titanic/support/rect.h
+++ b/engines/titanic/support/rect.h
@@ -27,6 +27,10 @@
namespace Titanic {
+enum Quadrant {
+ Q_CENTER = 0, Q_LEFT, Q_RIGHT, Q_TOP, Q_BOTTOM
+};
+
typedef Common::Point Point;
class Rect : public Common::Rect {
@@ -54,6 +58,11 @@ public:
* Constrains/clips to the intersection area of the given rect
*/
void constrain(const Rect &r);
+
+ /**
+ * Returns a center point for a given edge or center of the rect
+ */
+ Point getPoint(Quadrant quadrant);
};
} // End of namespace Titanic