Updated layer calculation: animations are now hidden properly by background elements (but not items yet).
svn-id: r33894
This commit is contained in:
parent
0606fef24e
commit
22eaffcb34
7 changed files with 62 additions and 29 deletions
|
@ -187,19 +187,19 @@ bool Debugger::Cmd_GfxObjects(int argc, const char **argv) {
|
|||
|
||||
const char *objType[] = { "DOOR", "GET", "ANIM" };
|
||||
|
||||
DebugPrintf("+--------------------+-----+-----+-----+-----+--------+--------+\n"
|
||||
"| name | x | y | z | f | type | visi |\n"
|
||||
"+--------------------+-----+-----+-----+-----+--------+--------+\n");
|
||||
DebugPrintf("+--------------------+-----+-----+-----+-------+-----+--------+--------+\n"
|
||||
"| name | x | y | z | layer | f | type | visi |\n"
|
||||
"+--------------------+-----+-----+-----+-------+-----+--------+--------+\n");
|
||||
|
||||
GfxObjList::iterator b = _vm->_gfx->_gfxobjList.begin();
|
||||
GfxObjList::iterator e = _vm->_gfx->_gfxobjList.end();
|
||||
|
||||
for ( ; b != e; b++) {
|
||||
GfxObj *obj = *b;
|
||||
DebugPrintf("|%-20s|%5i|%5i|%5i|%5i|%8s|%8x|\n", obj->getName(), obj->x, obj->y, obj->z, obj->frame, objType[obj->type], obj->isVisible() );
|
||||
DebugPrintf("|%-20s|%5i|%5i|%5i|%7i|%5i|%8s|%8x|\n", obj->getName(), obj->x, obj->y, obj->z, obj->layer, obj->frame, objType[obj->type], obj->isVisible() );
|
||||
}
|
||||
|
||||
DebugPrintf("+--------------------+-----+-----+-----+-----+--------+--------+\n");
|
||||
DebugPrintf("+--------------------+-----+-----+-----+-------+-----+--------+--------+\n");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -330,8 +330,17 @@ void Parallaction_ns::drawAnimations() {
|
|||
|
||||
if (anim->_flags & kFlagsNoMasked)
|
||||
layer = LAYER_FOREGROUND;
|
||||
else
|
||||
layer = _gfx->_backgroundInfo->getLayer(anim->getY() + anim->height());
|
||||
else {
|
||||
if (getGameType() == GType_Nippon) {
|
||||
// Layer in NS depends on where the animation is on the screen, for each animation.
|
||||
layer = _gfx->_backgroundInfo->getLayer(anim->getFrameY() + anim->height());
|
||||
} else {
|
||||
// Layer in BRA is calculated from Z value. For characters it is the same as NS,
|
||||
// but other animations can have Z set from scripts independently from their
|
||||
// position on the screen.
|
||||
layer = _gfx->_backgroundInfo->getLayer(anim->getZ());
|
||||
}
|
||||
}
|
||||
|
||||
if (obj) {
|
||||
_gfx->showGfxObj(obj, true);
|
||||
|
@ -401,7 +410,7 @@ void ProgramExec::runScripts(ProgramList::iterator first, ProgramList::iterator
|
|||
AnimationPtr a = (*it)->_anim;
|
||||
|
||||
if (a->_flags & kFlagsCharacter)
|
||||
a->setZ(a->getY() + a->height());
|
||||
a->setZ(a->getFrameY() + a->height());
|
||||
|
||||
if ((a->_flags & kFlagsActing) == 0)
|
||||
continue;
|
||||
|
@ -409,7 +418,7 @@ void ProgramExec::runScripts(ProgramList::iterator first, ProgramList::iterator
|
|||
runScript(*it, a);
|
||||
|
||||
if (a->_flags & kFlagsCharacter)
|
||||
a->setZ(a->getY() + a->height());
|
||||
a->setZ(a->getFrameY() + a->height());
|
||||
}
|
||||
|
||||
_modCounter++;
|
||||
|
@ -671,7 +680,7 @@ ZonePtr Parallaction::hitZone(uint32 type, uint16 x, uint16 y) {
|
|||
if (z->_flags & kFlagsRemove) continue;
|
||||
|
||||
Common::Rect r;
|
||||
z->getRect(r);
|
||||
z->getBox(r);
|
||||
r.right++; // adjust border because Common::Rect doesn't include bottom-right edge
|
||||
r.bottom++;
|
||||
|
||||
|
@ -701,13 +710,13 @@ ZonePtr Parallaction::hitZone(uint32 type, uint16 x, uint16 y) {
|
|||
|
||||
if (z->getX() != -1)
|
||||
continue;
|
||||
if (_si < _char._ani->getX())
|
||||
if (_si < _char._ani->getFrameX())
|
||||
continue;
|
||||
if (_si > (_char._ani->getX() + _char._ani->width()))
|
||||
if (_si > (_char._ani->getFrameX() + _char._ani->width()))
|
||||
continue;
|
||||
if (_di < _char._ani->getY())
|
||||
if (_di < _char._ani->getFrameY())
|
||||
continue;
|
||||
if (_di > (_char._ani->getY() + _char._ani->height()))
|
||||
if (_di > (_char._ani->getFrameY() + _char._ani->height()))
|
||||
continue;
|
||||
|
||||
}
|
||||
|
@ -729,8 +738,8 @@ ZonePtr Parallaction::hitZone(uint32 type, uint16 x, uint16 y) {
|
|||
AnimationPtr a = *ait;
|
||||
|
||||
_a = (a->_flags & kFlagsActive) ? 1 : 0; // _a: active Animation
|
||||
_e = ((_si >= a->getX() + a->width()) || (_si <= a->getX())) ? 0 : 1; // _e: horizontal range
|
||||
_f = ((_di >= a->getY() + a->height()) || (_di <= a->getY())) ? 0 : 1; // _f: vertical range
|
||||
_e = ((_si >= a->getFrameX() + a->width()) || (_si <= a->getFrameX())) ? 0 : 1; // _e: horizontal range
|
||||
_f = ((_di >= a->getFrameY() + a->height()) || (_di <= a->getFrameY())) ? 0 : 1; // _f: vertical range
|
||||
|
||||
_b = ((type != 0) || (a->_type == kZoneYou)) ? 0 : 1; // _b: (no type specified) AND (Animation is not the character)
|
||||
_c = (a->_type & 0xFFFF0000) ? 0 : 1; // _c: Animation is not an object
|
||||
|
|
|
@ -377,6 +377,12 @@ void Gfx::beginFrame() {
|
|||
*data++ = _backgroundInfo->mask.getValue(x, y);
|
||||
}
|
||||
}
|
||||
#if 1
|
||||
Common::DumpFile dump;
|
||||
dump.open("maskdump.bin");
|
||||
dump.write(_bitmapMask.pixels, _bitmapMask.w * _bitmapMask.h);
|
||||
dump.close();
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,6 +71,20 @@ uint16 Animation::height() const {
|
|||
return r.height();
|
||||
}
|
||||
|
||||
int16 Animation::getFrameX() const {
|
||||
if (!gfxobj) return _left;
|
||||
Common::Rect r;
|
||||
gfxobj->getRect(_frame, r);
|
||||
return r.left + _left;
|
||||
}
|
||||
|
||||
int16 Animation::getFrameY() const {
|
||||
if (!gfxobj) return _top;
|
||||
Common::Rect r;
|
||||
gfxobj->getRect(_frame, r);
|
||||
return r.top + _top;
|
||||
}
|
||||
|
||||
uint16 Animation::getFrameNum() const {
|
||||
if (!gfxobj) return 0;
|
||||
return gfxobj->getNum();
|
||||
|
@ -198,13 +212,6 @@ Zone::~Zone() {
|
|||
free(_linkedName);
|
||||
}
|
||||
|
||||
void Zone::getRect(Common::Rect& r) const {
|
||||
r.left = _left;
|
||||
r.right = _right;
|
||||
r.top = _top;
|
||||
r.bottom = _bottom;
|
||||
}
|
||||
|
||||
void Zone::translate(int16 x, int16 y) {
|
||||
_left += x;
|
||||
_right += x;
|
||||
|
|
|
@ -322,7 +322,6 @@ public:
|
|||
Zone();
|
||||
virtual ~Zone();
|
||||
|
||||
void getRect(Common::Rect& r) const;
|
||||
void translate(int16 x, int16 y);
|
||||
virtual uint16 width() const;
|
||||
virtual uint16 height() const;
|
||||
|
@ -334,6 +333,14 @@ public:
|
|||
_bottom = bottom;
|
||||
}
|
||||
|
||||
void getBox(Common::Rect& r) {
|
||||
r.left = getX();
|
||||
r.right = getX() + width();
|
||||
r.top = getY();
|
||||
r.bottom = getY() + height();
|
||||
}
|
||||
|
||||
|
||||
// getters/setters
|
||||
virtual int16 getX() { return _left; }
|
||||
virtual void setX(int16 value) { _left = value; }
|
||||
|
@ -513,6 +520,9 @@ public:
|
|||
|
||||
void validateScriptVars();
|
||||
|
||||
int16 getFrameX() const;
|
||||
int16 getFrameY() const;
|
||||
|
||||
// getters/setters used by scripts
|
||||
int16 getX() { return _left; }
|
||||
void setX(int16 value) { _left = value; }
|
||||
|
|
|
@ -352,7 +352,7 @@ void Parallaction::runGame() {
|
|||
|
||||
if (_input->_inputMode == Input::kInputModeGame) {
|
||||
_programExec->runScripts(_location._programs.begin(), _location._programs.end());
|
||||
_char._ani->setZ(_char._ani->height() + _char._ani->getY());
|
||||
_char._ani->setZ(_char._ani->height() + _char._ani->getFrameY());
|
||||
if (_char._ani->gfxobj) {
|
||||
_char._ani->gfxobj->z = _char._ani->getZ();
|
||||
}
|
||||
|
|
|
@ -466,9 +466,10 @@ DECLARE_LOCATION_PARSER(mask) {
|
|||
debugC(7, kDebugParser, "LOCATION_PARSER(mask) ");
|
||||
|
||||
ctxt.maskName = strdup(_tokens[1]);
|
||||
ctxt.info->layers[0] = atoi(_tokens[2]);
|
||||
ctxt.info->layers[1] = atoi(_tokens[3]);
|
||||
ctxt.info->layers[2] = atoi(_tokens[4]);
|
||||
ctxt.info->layers[0] = 0;
|
||||
ctxt.info->layers[1] = atoi(_tokens[2]);
|
||||
ctxt.info->layers[2] = atoi(_tokens[3]);
|
||||
ctxt.info->layers[3] = atoi(_tokens[4]);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue