Fixed action lists to sort correctly for non-English languages
svn-id: r29144
This commit is contained in:
parent
23c38f0b62
commit
cb2f6ce092
3 changed files with 24 additions and 17 deletions
|
@ -381,12 +381,18 @@ uint16 PopupMenu::ShowItems(Action contextAction, uint16 roomNumber) {
|
||||||
return result;
|
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) {
|
Action PopupMenu::Show(uint32 actionMask) {
|
||||||
StringList &stringList = Resources::getReference().stringList();
|
StringList &stringList = Resources::getReference().stringList();
|
||||||
int numEntries = 0;
|
int numEntries = 0;
|
||||||
uint32 v = actionMask;
|
uint32 v = actionMask;
|
||||||
int index;
|
int index;
|
||||||
const Action *currentAction;
|
int currentAction;
|
||||||
uint16 resultIndex;
|
uint16 resultIndex;
|
||||||
Action resultAction;
|
Action resultAction;
|
||||||
|
|
||||||
|
@ -395,26 +401,33 @@ Action PopupMenu::Show(uint32 actionMask) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const char **strList = (const char **) Memory::alloc(sizeof(char *) * numEntries);
|
const char **strList = (const char **) Memory::alloc(sizeof(char *) * numEntries);
|
||||||
Action *actionSet = (Action *) Memory::alloc(sizeof(Action) * numEntries);
|
|
||||||
|
|
||||||
int strIndex = 0;
|
int strIndex = 0;
|
||||||
for (currentAction = &sortedActions[0]; *currentAction != NONE; ++currentAction) {
|
for (currentAction = 0; currentAction < (int)EXAMINE; ++currentAction) {
|
||||||
if ((actionMask & (1 << (*currentAction - 1))) != 0) {
|
if ((actionMask & (1 << currentAction)) != 0) {
|
||||||
strList[strIndex] = stringList.getString(*currentAction);
|
strList[strIndex] = stringList.getString(currentAction);
|
||||||
actionSet[strIndex] = *currentAction;
|
|
||||||
++strIndex;
|
++strIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sort the list
|
||||||
|
qsort(strList, numEntries, sizeof(const char *), (CompareMethod) entryCompare);
|
||||||
|
|
||||||
|
// Show the entries
|
||||||
resultIndex = Show(numEntries, strList);
|
resultIndex = Show(numEntries, strList);
|
||||||
|
|
||||||
if (resultIndex == 0xffff)
|
resultAction = NONE;
|
||||||
resultAction = NONE;
|
if (resultIndex != 0xffff) {
|
||||||
else
|
// Scan through the list of actions to find the selected entry
|
||||||
resultAction = actionSet[resultIndex];
|
for (currentAction = 0; currentAction < (int)EXAMINE; ++currentAction) {
|
||||||
|
if (strList[resultIndex] == stringList.getString(currentAction)) {
|
||||||
|
resultAction = (Action) (currentAction + 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Memory::dealloc(strList);
|
Memory::dealloc(strList);
|
||||||
Memory::dealloc(actionSet);
|
|
||||||
return resultAction;
|
return resultAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,10 +30,6 @@
|
||||||
|
|
||||||
namespace Lure {
|
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,
|
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,
|
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};
|
0, 1, 1, 1, 1, 0, 0, 2, 1, 1, 0, 0, 1, 1, 2, 2, 5, 2, 2, 1};
|
||||||
|
|
|
@ -34,8 +34,6 @@ namespace Lure {
|
||||||
|
|
||||||
using namespace Common;
|
using namespace Common;
|
||||||
|
|
||||||
extern const Action sortedActions[];
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
/* Structure definitions */
|
/* Structure definitions */
|
||||||
/* */
|
/* */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue