aboutsummaryrefslogtreecommitdiff
path: root/engines/parallaction/objects.cpp
diff options
context:
space:
mode:
authorNicola Mettifogo2008-12-17 11:15:47 +0000
committerNicola Mettifogo2008-12-17 11:15:47 +0000
commit774773b7cd02e3c6932095af4905a25eb1862392 (patch)
treefd2bc1c6ee9ccaa47372639a7dfdda207335e3fd /engines/parallaction/objects.cpp
parent3591f8859ed5fe6ad4cc94671d7d43a52b9f01b6 (diff)
downloadscummvm-rg350-774773b7cd02e3c6932095af4905a25eb1862392.tar.gz
scummvm-rg350-774773b7cd02e3c6932095af4905a25eb1862392.tar.bz2
scummvm-rg350-774773b7cd02e3c6932095af4905a25eb1862392.zip
Reduced code duplication when manipulating Animations, and cleanup.
svn-id: r35408
Diffstat (limited to 'engines/parallaction/objects.cpp')
-rw-r--r--engines/parallaction/objects.cpp57
1 files changed, 31 insertions, 26 deletions
diff --git a/engines/parallaction/objects.cpp b/engines/parallaction/objects.cpp
index 59e2fb0868..8cbcb293ce 100644
--- a/engines/parallaction/objects.cpp
+++ b/engines/parallaction/objects.cpp
@@ -57,32 +57,36 @@ Animation::~Animation() {
gfxobj->release();
}
-uint16 Animation::width() const {
- if (!gfxobj) return 0;
- Common::Rect r;
+void Animation::getFrameRect(Common::Rect &r) const {
+ r.setWidth(0); r.setHeight(0);
+ if (!gfxobj) {
+ return;
+ }
gfxobj->getRect(_frame, r);
- return r.width();
+ r.translate(_left, _top);
}
-uint16 Animation::height() const {
- if (!gfxobj) return 0;
+bool Animation::hitFrameRect(int x, int y) const {
+ if (!gfxobj) {
+ return false;
+ }
Common::Rect r;
- gfxobj->getRect(_frame, r);
- return r.height();
+ getFrameRect(r);
+ return r.contains(x, y);
}
-int16 Animation::getFrameX() const {
- if (!gfxobj) return _left;
- Common::Rect r;
- gfxobj->getRect(_frame, r);
- return r.left + _left;
+int16 Animation::getBottom() const {
+ int bottom = _top;
+ if (gfxobj) {
+ Common::Rect r;
+ getFrameRect(r);
+ bottom = r.bottom;
+ }
+ return bottom;
}
-int16 Animation::getFrameY() const {
- if (!gfxobj) return _top;
- Common::Rect r;
- gfxobj->getRect(_frame, r);
- return r.top + _top;
+void Animation::resetZ() {
+ setZ(getBottom());
}
uint16 Animation::getFrameNum() const {
@@ -90,9 +94,9 @@ uint16 Animation::getFrameNum() const {
return gfxobj->getNum();
}
-byte* Animation::getFrameData(uint32 index) const {
+byte* Animation::getFrameData() const {
if (!gfxobj) return NULL;
- return gfxobj->getData(index);
+ return gfxobj->getData(_frame);
}
void Animation::validateScriptVars() {
@@ -221,12 +225,13 @@ void Zone::translate(int16 x, int16 y) {
_bottom += y;
}
-uint16 Zone::width() const {
- return _right - _left;
-}
-
-uint16 Zone::height() const {
- return _bottom - _top;
+bool Zone::hitRect(int x, int y) const {
+ // The scripts of Nippon Safes are full of invalid rectangles, used to
+ // provide 'special' features.
+ if (_right < _left || _bottom < _top) {
+ return false;
+ }
+ return Common::Rect(_left, _top, _right, _bottom).contains(x, y);
}
Dialogue::Dialogue() {