diff options
author | Vladimir Menshakov | 2010-03-21 07:49:53 +0000 |
---|---|---|
committer | Vladimir Menshakov | 2010-03-21 07:49:53 +0000 |
commit | 338532ec3c1eff284f5b8876b1058531b2af46c5 (patch) | |
tree | 6bdb8e0c405463f88b8394d7fd510c50a34630a1 /engines | |
parent | 76ef5d4aea87d07ccf1fd4fbba33af2aae9c42e8 (diff) | |
download | scummvm-rg350-338532ec3c1eff284f5b8876b1058531b2af46c5.tar.gz scummvm-rg350-338532ec3c1eff284f5b8876b1058531b2af46c5.tar.bz2 scummvm-rg350-338532ec3c1eff284f5b8876b1058531b2af46c5.zip |
preload inventory graphics on load
svn-id: r48350
Diffstat (limited to 'engines')
-rw-r--r-- | engines/teenagent/inventory.cpp | 41 | ||||
-rw-r--r-- | engines/teenagent/inventory.h | 5 | ||||
-rw-r--r-- | engines/teenagent/teenagent.cpp | 2 |
3 files changed, 30 insertions, 18 deletions
diff --git a/engines/teenagent/inventory.cpp b/engines/teenagent/inventory.cpp index 193c413367..24297912ca 100644 --- a/engines/teenagent/inventory.cpp +++ b/engines/teenagent/inventory.cpp @@ -117,9 +117,13 @@ void Inventory::clear() { } } -void Inventory::flush() { - for (int i = 0; i < 24; ++i) +void Inventory::reload() { + for (int i = 0; i < 24; ++i) { graphics[i].free(); + uint item = inventory[i]; + if (item != 0) + graphics[i].load(this, item); + } } void Inventory::add(byte item) { @@ -285,17 +289,31 @@ void Inventory::Item::backgroundEffect(Graphics::Surface *s) { } } -void Inventory::Item::render(Inventory *inventory, InventoryObject *obj, Graphics::Surface *dst, int delta) { - Resources *res = Resources::instance(); - - backgroundEffect(dst); - rect.render(dst, hovered ? 233 : 234); +void Inventory::Item::load(Inventory *inventory, uint item_id) { + InventoryObject *obj = &inventory->objects[item_id]; if (obj->animated) { if (animation.empty()) { debug(0, "loading item %d from offset %x", obj->id, inventory->offset[obj->id - 1]); Common::MemoryReadStream s(inventory->items + inventory->offset[obj->id - 1], inventory->offset[obj->id] - inventory->offset[obj->id - 1]); animation.load(&s, Animation::kTypeInventory); } + } else { + if (surface.empty()) { + debug(0, "loading item %d from offset %x", obj->id, inventory->offset[obj->id - 1]); + Common::MemoryReadStream s(inventory->items + inventory->offset[obj->id - 1], inventory->offset[obj->id] - inventory->offset[obj->id - 1]); + surface.load(&s, Surface::kTypeOns); + } + } +} + +void Inventory::Item::render(Inventory *inventory, uint item_id, Graphics::Surface *dst, int delta) { + InventoryObject *obj = &inventory->objects[item_id]; + Resources *res = Resources::instance(); + + backgroundEffect(dst); + rect.render(dst, hovered ? 233 : 234); + load(inventory, item_id); + if (obj->animated) { if (hovered) { Surface *s = animation.currentFrame(delta); if (animation.currentIndex() == 0) @@ -308,11 +326,6 @@ void Inventory::Item::render(Inventory *inventory, InventoryObject *obj, Graphic 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]); - Common::MemoryReadStream s(inventory->items + inventory->offset[obj->id - 1], inventory->offset[obj->id] - inventory->offset[obj->id - 1]); - surface.load(&s, Surface::kTypeOns); - } surface.render(dst, rect.left + 1, rect.top + 1); } @@ -344,9 +357,7 @@ void Inventory::render(Graphics::Surface *surface, int delta) { continue; //debug(0, "%d,%d -> %u", x0, y0, item); - - InventoryObject *obj = &objects[item]; - graphics[idx].render(this, obj, surface, delta); + graphics[idx].render(this, item, surface, delta); } } } diff --git a/engines/teenagent/inventory.h b/engines/teenagent/inventory.h index bce27c0cce..571c9cf6d7 100644 --- a/engines/teenagent/inventory.h +++ b/engines/teenagent/inventory.h @@ -42,7 +42,7 @@ public: void render(Graphics::Surface *surface, int delta); void clear(); - void flush(); + void reload(); void add(byte item); bool has(byte item) const; void remove(byte item); @@ -71,8 +71,9 @@ private: Item() : hovered(false) {} void free(); + void load(Inventory *inventory, uint item_id); void backgroundEffect(Graphics::Surface *s); - void render(Inventory *inventory, InventoryObject *obj, Graphics::Surface *surface, int delta); + void render(Inventory *inventory, uint item_id, Graphics::Surface *surface, int delta); } graphics[24]; bool _active; diff --git a/engines/teenagent/teenagent.cpp b/engines/teenagent/teenagent.cpp index 657d76ef7c..3b67bbfba6 100644 --- a/engines/teenagent/teenagent.cpp +++ b/engines/teenagent/teenagent.cpp @@ -211,7 +211,7 @@ Common::Error TeenAgentEngine::loadGameState(int slot) { scene->clear(); inventory->activate(false); - inventory->flush(); + inventory->reload(); setMusic(Resources::instance()->dseg.get_byte(0xDB90)); |