mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
- Utils patch (by tazpn)
o Expand length of gMoneyStatsDesc buffer for Italian and Dutch builds o Move EnumToString to text utils from keymap o Add ParseCommandLine utility function for parsing command line strings git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5138 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+2
-42
@@ -4,19 +4,9 @@
|
||||
#include "KeyMap.h"
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include "text.h"
|
||||
|
||||
// Enumeration support
|
||||
typedef struct EnumLookupType {
|
||||
int value;
|
||||
const STR name;
|
||||
} EnumLookupType;
|
||||
|
||||
static const STR EnumToString(int value, const EnumLookupType *table);
|
||||
static int StringToEnum(const STR value, const EnumLookupType *table);
|
||||
static int EnumToIndex(int value, const EnumLookupType *table);
|
||||
static inline STR Trim(STR&p);
|
||||
|
||||
static EnumLookupType gKeyTable[] =
|
||||
static Str8EnumLookupType gKeyTable[] =
|
||||
{
|
||||
{VK_LBUTTON, "LBUTTON"},
|
||||
{VK_RBUTTON, "RBUTTON"},
|
||||
@@ -237,36 +227,6 @@ static EnumLookupType gKeyTable[] =
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Enumeration Support
|
||||
const STR EnumToString(int value, const EnumLookupType *table) {
|
||||
for (const EnumLookupType *itr = table; itr->name != NULL; ++itr) {
|
||||
if (itr->value == value) return itr->name;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int StringToEnum(const STR value, const EnumLookupType *table) {
|
||||
if (NULL == value || 0 == *value)
|
||||
return 0;
|
||||
|
||||
for (const EnumLookupType *itr = table; itr->name != NULL; ++itr) {
|
||||
if (0 == _stricmp(value, itr->name))
|
||||
return itr->value;
|
||||
}
|
||||
STR end = NULL;
|
||||
return (int)strtol(value, &end, 0);
|
||||
}
|
||||
|
||||
int EnumToIndex(int value, const EnumLookupType *table) {
|
||||
int i = 0;
|
||||
for (const EnumLookupType *itr = table; itr->name != NULL; ++itr, ++i) {
|
||||
if (itr->value == value) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline STR Trim(STR &p) {
|
||||
while(isspace(*p)) *p++ = 0;
|
||||
TCHAR *e = p + strlen(p) - 1;
|
||||
|
||||
Reference in New Issue
Block a user