aboutsummaryrefslogtreecommitdiff
path: root/engines/lure/menu.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2007-09-30 12:35:37 +0000
committerPaul Gilbert2007-09-30 12:35:37 +0000
commitcb2f6ce0928f013087ef130ad9f7abcb19e15d8a (patch)
tree6a4401c245a6920f233bd441f002971616314c56 /engines/lure/menu.cpp
parent23c38f0b6222aec6ff3c79b145f555d4239e84be (diff)
downloadscummvm-rg350-cb2f6ce0928f013087ef130ad9f7abcb19e15d8a.tar.gz
scummvm-rg350-cb2f6ce0928f013087ef130ad9f7abcb19e15d8a.tar.bz2
scummvm-rg350-cb2f6ce0928f013087ef130ad9f7abcb19e15d8a.zip
Fixed action lists to sort correctly for non-English languages
svn-id: r29144
Diffstat (limited to 'engines/lure/menu.cpp')
-rw-r--r--engines/lure/menu.cpp35
1 files changed, 24 insertions, 11 deletions
diff --git a/engines/lure/menu.cpp b/engines/lure/menu.cpp
index 1a03118476..77705d22d4 100644
--- a/engines/lure/menu.cpp
+++ b/engines/lure/menu.cpp
@@ -381,12 +381,18 @@ uint16 PopupMenu::ShowItems(Action contextAction, uint16 roomNumber) {
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 @@ Action PopupMenu::Show(uint32 actionMask) {
}
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;
}