From 9ed02ae0c658f7feff64e5cf7f0f181e99aac908 Mon Sep 17 00:00:00 2001 From: Vladimir Menshakov Date: Sun, 7 Feb 2010 17:14:32 +0000 Subject: process object callback both on left and right click. skip r-click callback for banknote. svn-id: r47970 --- engines/teenagent/inventory.cpp | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'engines') diff --git a/engines/teenagent/inventory.cpp b/engines/teenagent/inventory.cpp index 9455a97500..b7bfc579e8 100644 --- a/engines/teenagent/inventory.cpp +++ b/engines/teenagent/inventory.cpp @@ -119,6 +119,20 @@ void Inventory::add(byte item) { error("no room for item %u", item); } +bool Inventory::tryObjectCallback(InventoryObject *obj) { + byte id = obj->id; + uint i = 0; + for (byte *table = Resources::instance()->dseg.ptr(0xBB6F + 3); table[0] != 0 && i < 7; table += 3, ++i) { + if (table[0] == id) { + resetSelectedObject(); + activate(false); + if (_engine->processCallback(READ_LE_UINT16(table + 1))) + return true; + } + } + return false; +} + bool Inventory::processEvent(const Common::Event &event) { Resources *res = Resources::instance(); @@ -162,6 +176,8 @@ bool Inventory::processEvent(const Common::Event &event) { debug(0, "lclick on %u:%s", hovered_obj->id, hovered_obj->name.c_str()); if (selected_obj == NULL) { + if (tryObjectCallback(hovered_obj)) + return true; //activate(false); int w = res->font7.render(NULL, 0, 0, hovered_obj->description, 0xd1); _engine->scene->displayMessage(hovered_obj->description, 0xd1, Common::Point((320 - w) / 2, 162)); @@ -205,18 +221,9 @@ bool Inventory::processEvent(const Common::Event &event) { return false; if (hovered_obj != NULL) { - byte id = hovered_obj->id; - debug(0, "rclick object %u", id); - uint i = 0; - for (byte *table = res->dseg.ptr(0xBB6F + 3); //original offset + 3 bytes. - table[0] != 0 && i < 7; table += 3, ++i) { - if (table[0] == id) { - resetSelectedObject(); - activate(false); - if (_engine->processCallback(READ_LE_UINT16(table + 1))) - return true; - } - } + debug(0, "rclick object %u:%s", hovered_obj->id, hovered_obj->name.c_str()); + if (hovered_obj->id != 51 && tryObjectCallback(hovered_obj)) //do not process callback for banknote on r-click + return true; } selected_obj = hovered_obj; -- cgit v1.2.3