diff options
author | Paul Gilbert | 2006-07-30 12:13:26 +0000 |
---|---|---|
committer | Paul Gilbert | 2006-07-30 12:13:26 +0000 |
commit | 0849e46541895e9f7e4fe597f2dd3dcf931ef479 (patch) | |
tree | 65ab468f5102b329995d1953464e170b2d5f6f50 /engines | |
parent | 6fa9819377b2f71ea1e7594f5b028b7577df7b70 (diff) | |
download | scummvm-rg350-0849e46541895e9f7e4fe597f2dd3dcf931ef479.tar.gz scummvm-rg350-0849e46541895e9f7e4fe597f2dd3dcf931ef479.tar.bz2 scummvm-rg350-0849e46541895e9f7e4fe597f2dd3dcf931ef479.zip |
Added a popup menu method for listing the items presented in response to an ASK action
svn-id: r23631
Diffstat (limited to 'engines')
-rw-r--r-- | engines/lure/menu.cpp | 78 | ||||
-rw-r--r-- | engines/lure/menu.h | 1 |
2 files changed, 79 insertions, 0 deletions
diff --git a/engines/lure/menu.cpp b/engines/lure/menu.cpp index 15d87c1871..eb9c1f591b 100644 --- a/engines/lure/menu.cpp +++ b/engines/lure/menu.cpp @@ -28,6 +28,8 @@ #include "lure/res_struct.h" #include "lure/res.h" #include "lure/strings.h" +#include "lure/room.h" +#include "lure/events.h" namespace Lure { @@ -264,6 +266,82 @@ uint16 PopupMenu::ShowInventory() { return result; } +#define MAX_NUM_DISPLAY_ITEMS 20 + +uint16 PopupMenu::ShowItems(Action contextAction) { + Resources &res = Resources::getReference(); + ValueTableData &fields = res.fieldList(); + HotspotDataList &hotspots = res.hotspotData(); + StringData &strings = StringData::getReference(); + Room &room = Room::getReference(); + Screen &screen = Screen::getReference(); + Mouse &mouse = Mouse::getReference(); + HotspotDataList::iterator i; + uint16 hotspotIds[MAX_NUM_DISPLAY_ITEMS]; + uint16 nameIds[MAX_NUM_DISPLAY_ITEMS]; + char *hotspotNames[MAX_NUM_DISPLAY_ITEMS]; + int numItems = 0; + int itemCtr; + Hotspot *player = res.getActiveHotspot(PLAYER_ID); + + // TODO: Looping through room list as well + + for (i = hotspots.begin(); i != hotspots.end(); ++i) { + HotspotData *hotspot = *i; + + if ((hotspot->headerFlags != 15) && + ((hotspot->headerFlags & fields.hdrFlagMask()) == 0)) + continue; + + if (((hotspot->flags & 0x20) != 0) || ((hotspot->flags & 0x80) == 0)) + // Skip the current hotspot + continue; + + // Following checks are done for room list - still need to include check against [3350h] + if (((hotspot->flags & 0x10) != 0) && (hotspot->roomNumber != player->roomNumber())) + continue; + + if ((hotspot->actions & contextAction) == 0) + // If hotspot does not allow action, then skip it + continue; + + if ((hotspot->nameId == 0x17A) || (hotspot->nameId == 0x147)) + // Special hotspot names to skip + continue; + + // Check if the hotspot's name is already used in an already set item + itemCtr = 0; + while ((itemCtr < numItems) && (nameIds[itemCtr] != hotspot->nameId)) + ++itemCtr; + if (itemCtr != numItems) + // Item's name is already present - skip hotspot + continue; + + // Add hotspot to list of entries to display + if (numItems == MAX_NUM_DISPLAY_ITEMS) error("Out of space in ask list"); + hotspotIds[numItems] = hotspot->hotspotId; + nameIds[numItems] = hotspot->nameId; + strings.getString(hotspot->nameId, hotspotNames[numItems]); + ++numItems; + } + + if (numItems == 0) + // No items, so add a 'nothing' to the statusLine + strcat(Room::getReference().statusLine(), "(nothing)"); + + room.update(); + screen.update(); + mouse.waitForRelease(); + + if (numItems == 0) + // Return flag for no items to ask for + return 0xfffe; + + uint16 result = Show(numItems, (const char **) hotspotNames); + if (result != 0xffff) result = hotspotIds[result]; + return result; +} + Action PopupMenu::Show(uint32 actionMask) { int numEntries = 0; uint32 v = actionMask; diff --git a/engines/lure/menu.h b/engines/lure/menu.h index 8fa792f67c..64dbbd88a5 100644 --- a/engines/lure/menu.h +++ b/engines/lure/menu.h @@ -81,6 +81,7 @@ public: static Action Show(int numEntries, Action *actions); static uint16 Show(int numEntries, const char *actions[]); static uint16 ShowInventory(); + static uint16 ShowItems(Action contextAction); }; } // End of namespace Lure |