[Scummvm-cvs-logs] SF.net SVN: scummvm: [29144] scummvm/trunk/engines/lure
dreammaster at users.sourceforge.net
dreammaster at users.sourceforge.net
Sun Sep 30 14:35:40 CEST 2007
Revision: 29144
http://scummvm.svn.sourceforge.net/scummvm/?rev=29144&view=rev
Author: dreammaster
Date: 2007-09-30 05:35:37 -0700 (Sun, 30 Sep 2007)
Log Message:
-----------
Fixed action lists to sort correctly for non-English languages
Modified Paths:
--------------
scummvm/trunk/engines/lure/menu.cpp
scummvm/trunk/engines/lure/res_struct.cpp
scummvm/trunk/engines/lure/res_struct.h
Modified: scummvm/trunk/engines/lure/menu.cpp
===================================================================
--- scummvm/trunk/engines/lure/menu.cpp 2007-09-30 12:13:30 UTC (rev 29143)
+++ scummvm/trunk/engines/lure/menu.cpp 2007-09-30 12:35:37 UTC (rev 29144)
@@ -381,12 +381,18 @@
return result;
}
+static int entryCompare(const char **p1, const char **p2) {
+ return strcmp(*p1, *p2);
+}
+
+typedef int (*CompareMethod)(const void*, const void*);
+
Action PopupMenu::Show(uint32 actionMask) {
StringList &stringList = Resources::getReference().stringList();
int numEntries = 0;
uint32 v = actionMask;
int index;
- const Action *currentAction;
+ int currentAction;
uint16 resultIndex;
Action resultAction;
@@ -395,26 +401,33 @@
}
const char **strList = (const char **) Memory::alloc(sizeof(char *) * numEntries);
- Action *actionSet = (Action *) Memory::alloc(sizeof(Action) * numEntries);
int strIndex = 0;
- for (currentAction = &sortedActions[0]; *currentAction != NONE; ++currentAction) {
- if ((actionMask & (1 << (*currentAction - 1))) != 0) {
- strList[strIndex] = stringList.getString(*currentAction);
- actionSet[strIndex] = *currentAction;
+ for (currentAction = 0; currentAction < (int)EXAMINE; ++currentAction) {
+ if ((actionMask & (1 << currentAction)) != 0) {
+ strList[strIndex] = stringList.getString(currentAction);
++strIndex;
}
}
+ // Sort the list
+ qsort(strList, numEntries, sizeof(const char *), (CompareMethod) entryCompare);
+
+ // Show the entries
resultIndex = Show(numEntries, strList);
- if (resultIndex == 0xffff)
- resultAction = NONE;
- else
- resultAction = actionSet[resultIndex];
+ resultAction = NONE;
+ if (resultIndex != 0xffff) {
+ // Scan through the list of actions to find the selected entry
+ for (currentAction = 0; currentAction < (int)EXAMINE; ++currentAction) {
+ if (strList[resultIndex] == stringList.getString(currentAction)) {
+ resultAction = (Action) (currentAction + 1);
+ break;
+ }
+ }
+ }
Memory::dealloc(strList);
- Memory::dealloc(actionSet);
return resultAction;
}
Modified: scummvm/trunk/engines/lure/res_struct.cpp
===================================================================
--- scummvm/trunk/engines/lure/res_struct.cpp 2007-09-30 12:13:30 UTC (rev 29143)
+++ scummvm/trunk/engines/lure/res_struct.cpp 2007-09-30 12:35:37 UTC (rev 29144)
@@ -30,10 +30,6 @@
namespace Lure {
-extern const Action sortedActions[] = {ASK, BRIBE, BUY, CLOSE, DRINK, EXAMINE, GET, GIVE,
- GO_TO, LOCK, LOOK, LOOK_AT, LOOK_THROUGH, OPEN, OPERATE, PULL, PUSH, RETURN,
- STATUS, TALK_TO, TELL, UNLOCK, USE, NONE};
-
extern const int actionNumParams[NPC_JUMP_ADDRESS+1] = {0,
1, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 2, 0, 1,
0, 1, 1, 1, 1, 0, 0, 2, 1, 1, 0, 0, 1, 1, 2, 2, 5, 2, 2, 1};
Modified: scummvm/trunk/engines/lure/res_struct.h
===================================================================
--- scummvm/trunk/engines/lure/res_struct.h 2007-09-30 12:13:30 UTC (rev 29143)
+++ scummvm/trunk/engines/lure/res_struct.h 2007-09-30 12:35:37 UTC (rev 29144)
@@ -34,8 +34,6 @@
using namespace Common;
-extern const Action sortedActions[];
-
/*-------------------------------------------------------------------------*/
/* Structure definitions */
/* */
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