diff options
author | Florian Kagerer | 2008-03-15 00:16:11 +0000 |
---|---|---|
committer | Florian Kagerer | 2008-03-15 00:16:11 +0000 |
commit | 9cedcd059b6e9f0e3ec768b1c159cc1d8eaacf75 (patch) | |
tree | b0aa0d53b99c01ee761ce6139b535027a25bb3d0 /engines/kyra/animator_v2.cpp | |
parent | 6547ef6e129fb42c75c20f24e1f24dff1458f727 (diff) | |
download | scummvm-rg350-9cedcd059b6e9f0e3ec768b1c159cc1d8eaacf75.tar.gz scummvm-rg350-9cedcd059b6e9f0e3ec768b1c159cc1d8eaacf75.tar.bz2 scummvm-rg350-9cedcd059b6e9f0e3ec768b1c159cc1d8eaacf75.zip |
animations for inventory items and mouse pointers
svn-id: r31122
Diffstat (limited to 'engines/kyra/animator_v2.cpp')
-rw-r--r-- | engines/kyra/animator_v2.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/engines/kyra/animator_v2.cpp b/engines/kyra/animator_v2.cpp index 9bd9b76dfc..ceb9a80215 100644 --- a/engines/kyra/animator_v2.cpp +++ b/engines/kyra/animator_v2.cpp @@ -26,6 +26,8 @@ #include "kyra/kyra_v2.h" #include "kyra/wsamovie.h" +#include "common/endian.h" + namespace Kyra { void KyraEngine_v2::clearAnimObjects() { @@ -191,6 +193,66 @@ void KyraEngine_v2::refreshAnimObjectsIfNeed() { } } +void KyraEngine_v2::updateItemAnimations() { + bool nextFrame = false; + + if (_itemAnimData[0].itemIndex == -1 || _holdItemAnims) + return; + + ItemAnimData *s = &_itemAnimData[_nextAnimItem++]; + + if (s->itemIndex == -1) { + _nextAnimItem = 0; + return; + } + + uint32 ctime = _system->getMillis(); + if (ctime < s->nextFrame) + return; + + uint16 shpIdx = READ_LE_UINT16(s->frames + (s->curFrame << 2)) + 64; + if ((s->itemIndex == _handItemSet || s->itemIndex == _itemInHand) && (!_mouseState && _screen->isMouseVisible())) { + nextFrame = true; + _screen->setMouseCursor(8, 15, getShapePtr(shpIdx)); + } + + for (int i = 0; i < 10; i++) { + if (s->itemIndex == _mainCharacter.inventory[i]) { + nextFrame = true; + _screen->drawShape(2, _defaultShapeTable[240 + i], 304, 184, 0, 0); + _screen->drawShape(2, getShapePtr(shpIdx), 304, 184, 0, 0); + _screen->copyRegion(304, 184, _inventoryX[i], _inventoryY[i], 16, 16, 2, 0); + } + } + + _screen->updateScreen(); + + for (int i = 11; i < 40; i++) { + AnimObj *animObject = &_animObjects[i]; + if (animObject->shapeIndex2 == s->itemIndex + 64) { + if (s->itemIndex == 121) { + int f = findItem(_mainCharacter.sceneId, 121); + int nx = _itemList[f].x - 4; + if (nx > 12) { + if (lineIsPassable(nx, _itemList[f].y)) { + animObject->xPos2 -= 4; + _itemList[f].x -= 4; + } + } + } + animObject->shapePtr = _defaultShapeTable[shpIdx]; + animObject->shapeIndex1 = shpIdx; + animObject->needRefresh = 1; + nextFrame = true; + } + } + + if (nextFrame) { + s->nextFrame = _system->getMillis() + READ_LE_UINT16(s->frames + (s->curFrame << 2) + 2) * _tickLength; + s->curFrame = ++s->curFrame % s->numFrames; + } +} + void KyraEngine_v2::flagAnimObjsForRefresh() { for (AnimObj *curEntry = _animList; curEntry; curEntry = curEntry->nextObject) curEntry->needRefresh = 1; |