diff options
Diffstat (limited to 'engines/teenagent')
-rw-r--r-- | engines/teenagent/animation.cpp | 4 | ||||
-rw-r--r-- | engines/teenagent/animation.h | 3 | ||||
-rw-r--r-- | engines/teenagent/inventory.cpp | 14 |
3 files changed, 18 insertions, 3 deletions
diff --git a/engines/teenagent/animation.cpp b/engines/teenagent/animation.cpp index 248e312231..b2c0d804b6 100644 --- a/engines/teenagent/animation.cpp +++ b/engines/teenagent/animation.cpp @@ -30,6 +30,10 @@ namespace TeenAgent { Animation::Animation() : id(0), x(0), y(0), loop(true), data(0), data_size(0), frames_count(0), frames(0), index(0) { } +Surface * Animation::firstFrame() const { + return frames != NULL? frames: NULL; +} + Surface * Animation::currentFrame(int dt) { if (frames == NULL || frames_count == 0) return NULL; diff --git a/engines/teenagent/animation.h b/engines/teenagent/animation.h index 784ce3b15a..4538bdbb7e 100644 --- a/engines/teenagent/animation.h +++ b/engines/teenagent/animation.h @@ -41,7 +41,10 @@ public: void load(Common::SeekableReadStream * s, Type type = TypeLan); void free(); + Surface * firstFrame() const; Surface * currentFrame(int dt = 1); + uint16 currentIndex() const { return index; } + ~Animation(); bool empty() const { return frames == NULL; } diff --git a/engines/teenagent/inventory.cpp b/engines/teenagent/inventory.cpp index bdf99bd971..ccb182e8b0 100644 --- a/engines/teenagent/inventory.cpp +++ b/engines/teenagent/inventory.cpp @@ -237,9 +237,17 @@ void Inventory::Item::render(Inventory * inventory, InventoryObject *obj, Graphi inventory->items->seek(inventory->offset[obj->id - 1]); animation.load(inventory->items, Animation::TypeInventory); } - Surface * s = animation.currentFrame(); - if (s != NULL) - s->render(dst, rect.left + 1, rect.top + 1); + if (hovered) { + Surface * s = animation.currentFrame(); + if (animation.currentIndex() == 0) + s = animation.currentFrame(); + if (s != NULL) + s->render(dst, rect.left + 1, rect.top + 1); + } else { + Surface * s = animation.firstFrame(); + if (s != NULL) + s->render(dst, rect.left + 1, rect.top + 1); + } } else { if (surface.empty()) { debug(0, "loading item %d from offset %x", obj->id, inventory->offset[obj->id - 1]); |