[Scummvm-cvs-logs] SF.net SVN: scummvm: [23631] scummvm/trunk/engines/lure
dreammaster at users.sourceforge.net
dreammaster at users.sourceforge.net
Sun Jul 30 14:13:32 CEST 2006
Revision: 23631
Author: dreammaster
Date: 2006-07-30 05:13:26 -0700 (Sun, 30 Jul 2006)
ViewCVS: http://svn.sourceforge.net/scummvm/?rev=23631&view=rev
Log Message:
-----------
Added a popup menu method for listing the items presented in response to an ASK action
Modified Paths:
--------------
scummvm/trunk/engines/lure/menu.cpp
scummvm/trunk/engines/lure/menu.h
Modified: scummvm/trunk/engines/lure/menu.cpp
===================================================================
--- scummvm/trunk/engines/lure/menu.cpp 2006-07-30 12:12:18 UTC (rev 23630)
+++ scummvm/trunk/engines/lure/menu.cpp 2006-07-30 12:13:26 UTC (rev 23631)
@@ -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 @@
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;
Modified: scummvm/trunk/engines/lure/menu.h
===================================================================
--- scummvm/trunk/engines/lure/menu.h 2006-07-30 12:12:18 UTC (rev 23630)
+++ scummvm/trunk/engines/lure/menu.h 2006-07-30 12:13:26 UTC (rev 23631)
@@ -81,6 +81,7 @@
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
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list