New uiScript "replace weapons/items/ammo" (experimental).

This commit is contained in:
Andrei Drexler 2009-06-30 22:29:03 +00:00
parent c02e381f75
commit b50af1df78

View file

@ -4923,26 +4923,17 @@ static qboolean UI_SelectedPlayer_HandleKey(int flags, float *special, int key)
return qfalse;
}
//Makro - replacement type
static qboolean UI_ReplacementType_HandleKey(int flags, float *special, int key)
static void UI_SelectReplacementType(int index)
{
if (key == K_MOUSE1 || key == K_MOUSE2 || key == K_ENTER || key == K_KP_ENTER || key == K_LEFTARROW
|| key == K_RIGHTARROW) {
int index = uiInfo.replacements.TypeIndex;
if (key == K_MOUSE2 || key == K_LEFTARROW) {
index--;
} else {
index++;
}
if (index >= replacementTypeCount) {
index = 0;
} else if (index < 0) {
index = replacementTypeCount - 1;
}
uiInfo.replacements.TypeIndex = index;
uiInfo.replacements.SubtypeIndex = 0;
switch (index)
{
case 0:
@ -4960,6 +4951,24 @@ static qboolean UI_ReplacementType_HandleKey(int flags, float *special, int key)
default:
break;
}
}
//Makro - replacement type
static qboolean UI_ReplacementType_HandleKey(int flags, float *special, int key)
{
if (key == K_MOUSE1 || key == K_MOUSE2 || key == K_ENTER || key == K_KP_ENTER || key == K_LEFTARROW
|| key == K_RIGHTARROW) {
int index = uiInfo.replacements.TypeIndex;
if (key == K_MOUSE2 || key == K_LEFTARROW) {
index--;
} else {
index++;
}
UI_SelectReplacementType(index);
}
return qfalse;
}
@ -5683,6 +5692,9 @@ static void UI_Update(const char *name)
}
}
// FIXME: Makro - this is a monster of a function
// Not exactly efficient with all this strcmp's in it, either...
static void UI_RunMenuScript(char **args)
{
const char *name, *name2;
@ -6380,6 +6392,20 @@ static void UI_RunMenuScript(char **args)
//Makro - select replacement
} else if (Q_stricmp(name, "selectReplacement") == 0) {
UI_SelectReplacement();
// Makro - select replacement type (weapons/items/ammo)
} else if (Q_stricmp(name, "replace") == 0) {
if (String_Parse(args, &name2))
{
int i;
for (i=0; i<replacementTypeCount; ++i)
{
if (Q_stricmp(name2, replacementTypes[i].displayName) == 0)
{
UI_SelectReplacementType(i);
break;
}
}
}
} else if (Q_stricmp(name, "update") == 0) {
if (String_Parse(args, &name2)) {
UI_Update(name2);