summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2007-11-02 20:42:47 +0000
committerTim Angus <tim@ngus.net>2007-11-02 20:42:47 +0000
commit3289f089c3b6f6196fe9508e7d3d48b32a42d10d (patch)
tree00284abb075f2df331988b7398dbc82cf54352d8 /src/ui
parent580693963c553ca1b63fb62f70e3f048a3666991 (diff)
* s/ui_loading/ui_hideCursor/
* Hide cursor when using edit fields and binding keys * Remove client side chat handling, moving it to UI module * Remove target and last attacker message modes * Add ui_developer cvar * Fix edit field bug where cvar changes under it * Add onTextEntry UI script event * Give the user some feedback when binding keys * Stop doing a UI refresh when primed (and remove cgame ui_loading sets) * Move cg_drawSnapshot to bottom of the screen
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/ui_atoms.c28
-rw-r--r--src/ui/ui_local.h5
-rw-r--r--src/ui/ui_main.c21
-rw-r--r--src/ui/ui_shared.c74
-rw-r--r--src/ui/ui_shared.h1
5 files changed, 98 insertions, 31 deletions
diff --git a/src/ui/ui_atoms.c b/src/ui/ui_atoms.c
index 64efa914..d2bb6b26 100644
--- a/src/ui/ui_atoms.c
+++ b/src/ui/ui_atoms.c
@@ -52,8 +52,6 @@ void QDECL Com_Printf( const char *msg, ... ) {
trap_Print( va("%s", text) );
}
-qboolean newUI = qfalse;
-
/*
=================
@@ -298,6 +296,8 @@ static void UI_CalcPostGameStats( void ) {
/*
=================
UI_ConsoleCommand
+
+FIXME: lookup table
=================
*/
qboolean UI_ConsoleCommand( int realTime )
@@ -353,6 +353,30 @@ qboolean UI_ConsoleCommand( int realTime )
return qtrue;
}
+ if ( Q_strncmp( cmd, "messagemode", 11 ) == 0 ) {
+ trap_Cvar_Set( "ui_sayBuffer", "" );
+
+ switch( cmd[ 11 ] )
+ {
+ default:
+ case '\0':
+ // Global
+ uiInfo.chatTeam = qfalse;
+ uiInfo.chatTargetClientNum = -1;
+ break;
+
+ case '2':
+ // Team
+ uiInfo.chatTeam = qtrue;
+ uiInfo.chatTargetClientNum = -1;
+ break;
+ }
+
+ trap_Key_SetCatcher( KEYCATCH_UI );
+ Menus_ActivateByName( "say" );
+ return qtrue;
+ }
+
if( Q_stricmp ( cmd, "menu" ) == 0 )
{
arg1 = UI_Argv( 1 );
diff --git a/src/ui/ui_local.h b/src/ui/ui_local.h
index 5f5ea862..450a4e44 100644
--- a/src/ui/ui_local.h
+++ b/src/ui/ui_local.h
@@ -128,6 +128,8 @@ extern vmCvar_t ui_scoreTime;
extern vmCvar_t ui_smallFont;
extern vmCvar_t ui_bigFont;
extern vmCvar_t ui_serverStatusTimeOut;
+extern vmCvar_t ui_textWrapCache;
+extern vmCvar_t ui_developer;
@@ -896,6 +898,9 @@ typedef struct {
int effectsColor;
qboolean inGameLoad;
+
+ qboolean chatTeam;
+ int chatTargetClientNum;
} uiInfo_t;
extern uiInfo_t uiInfo;
diff --git a/src/ui/ui_main.c b/src/ui/ui_main.c
index edecd280..39e6c1b5 100644
--- a/src/ui/ui_main.c
+++ b/src/ui/ui_main.c
@@ -29,9 +29,6 @@ USER INTERFACE MAIN
=======================================================================
*/
-// use this to get a demo build without an explicit demo build, i.e. to get the demo ui files to build
-//#define PRE_RELEASE_TADEMO
-
#include "ui_local.h"
uiInfo_t uiInfo;
@@ -681,7 +678,7 @@ void _UI_Refresh( int realtime )
UI_SetColor( NULL );
// don't draw the cursor whilst loading
- if( Menu_Count( ) > 0 && !trap_Cvar_VariableValue( "ui_loading" ) )
+ if( Menu_Count( ) > 0 && !trap_Cvar_VariableValue( "ui_hideCursor" ) )
UI_DrawHandlePic( uiInfo.uiDC.cursorx-16, uiInfo.uiDC.cursory-16, 32, 32, uiInfo.uiDC.Assets.cursor);
#ifndef NDEBUG
@@ -3518,6 +3515,7 @@ static void UI_Update(const char *name) {
}
}
+//FIXME: lookup table
static void UI_RunMenuScript(char **args) {
const char *name, *name2;
char buff[1024];
@@ -3727,6 +3725,18 @@ static void UI_RunMenuScript(char **args) {
trap_Cmd_ExecuteText( EXEC_APPEND, command );
}
}
+ else if( Q_stricmp( name, "Say" ) == 0 )
+ {
+ char buffer[ MAX_CVAR_VALUE_STRING ];
+ trap_Cvar_VariableStringBuffer( "ui_sayBuffer", buffer, sizeof( buffer ) );
+
+ if( uiInfo.chatTargetClientNum != -1 )
+ trap_Cmd_ExecuteText( EXEC_APPEND, va( "tell %i \"%s\"\n", uiInfo.chatTargetClientNum, buffer ) );
+ else if( uiInfo.chatTeam )
+ trap_Cmd_ExecuteText( EXEC_APPEND, va( "say_team \"%s\"\n", buffer ) );
+ else
+ trap_Cmd_ExecuteText( EXEC_APPEND, va( "say \"%s\"\n", buffer ) );
+ }
else if (Q_stricmp(name, "playMovie") == 0) {
if (uiInfo.previewMovie >= 0) {
trap_CIN_StopCinematic(uiInfo.previewMovie);
@@ -5365,7 +5375,6 @@ void _UI_SetActiveMenu( uiMenuCommand_t menu ) {
}
Menus_CloseAll();
Menus_ActivateByName("main");
- trap_Cvar_Set( "ui_loading", "0" );
trap_Cvar_VariableStringBuffer("com_errorMessage", buf, sizeof(buf));
if (strlen(buf)) {
if (!ui_singlePlayerActive.integer) {
@@ -5801,6 +5810,7 @@ vmCvar_t ui_realCaptureLimit;
vmCvar_t ui_realWarmUp;
vmCvar_t ui_serverStatusTimeOut;
vmCvar_t ui_textWrapCache;
+vmCvar_t ui_developer;
vmCvar_t ui_winner;
@@ -5928,6 +5938,7 @@ static cvarTable_t cvarTable[] = {
{ &ui_realCaptureLimit, "capturelimit", "8", CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_NORESTART},
{ &ui_serverStatusTimeOut, "ui_serverStatusTimeOut", "7000", CVAR_ARCHIVE},
{ &ui_textWrapCache, "ui_textWrapCache", "1", CVAR_ARCHIVE },
+ { &ui_developer, "ui_developer", "0", CVAR_ARCHIVE | CVAR_CHEAT },
};
static int cvarTableSize = sizeof(cvarTable) / sizeof(cvarTable[0]);
diff --git a/src/ui/ui_shared.c b/src/ui/ui_shared.c
index 3224b697..ec6a07eb 100644
--- a/src/ui/ui_shared.c
+++ b/src/ui/ui_shared.c
@@ -64,8 +64,6 @@ int menuCount = 0; // how many
menuDef_t *menuStack[MAX_OPEN_MENUS];
int openMenuCount = 0;
-static qboolean debugMode = qfalse;
-
#define DOUBLE_CLICK_DELAY 300
static int lastListBoxClickTime = 0;
@@ -895,7 +893,7 @@ static void Window_Paint(Window *w, float fadeAmount, float fadeClamp, float fad
rectDef_t fillRect = w->rect;
- if (debugMode) {
+ if ( DC->getCVarValue( "ui_developer" ) ) {
color[0] = color[1] = color[2] = color[3] = 1;
DC->drawRect(w->rect.x, w->rect.y, w->rect.w, w->rect.h, 1, color);
}
@@ -1467,12 +1465,19 @@ void Script_SetFocus(itemDef_t *item, char **args) {
if (String_Parse(args, &name)) {
focusItem = Menu_FindItemByName(item->parent, name);
- if (focusItem && !(focusItem->window.flags & WINDOW_DECORATION) && !(focusItem->window.flags & WINDOW_HASFOCUS)) {
+ if (focusItem && !(focusItem->window.flags & WINDOW_DECORATION)) {
Menu_ClearFocus(item->parent);
focusItem->window.flags |= WINDOW_HASFOCUS;
if (focusItem->onFocus) {
Item_RunScript(focusItem, focusItem->onFocus);
}
+
+ // Edit fields get activated too
+ if ( focusItem->type == ITEM_TYPE_EDITFIELD || focusItem->type == ITEM_TYPE_NUMERICFIELD) {
+ g_editingField = qtrue;
+ g_editItem = focusItem;
+ }
+
if (DC->Assets.itemFocusSound) {
DC->startLocalSound( DC->Assets.itemFocusSound, CHAN_LOCAL_SOUND );
}
@@ -2400,6 +2405,9 @@ qboolean Item_TextField_HandleKey(itemDef_t *item, int key)
DC->getCVarString( item->cvar, buff, sizeof( buff ) );
len = strlen( buff );
+ if( len < item->cursorPos )
+ item->cursorPos = len;
+
if( editPtr->maxChars && len > editPtr->maxChars )
len = editPtr->maxChars;
@@ -2988,11 +2996,13 @@ void Menu_HandleKey(menuDef_t *menu, int key, qboolean down) {
if (g_editingField && down) {
if (!Item_TextField_HandleKey(g_editItem, key)) {
g_editingField = qfalse;
+ Item_RunScript( g_editItem, g_editItem->onTextEntry );
g_editItem = NULL;
inHandler = qfalse;
return;
} else if (key == K_MOUSE1 || key == K_MOUSE2 || key == K_MOUSE3) {
g_editingField = qfalse;
+ Item_RunScript( g_editItem, g_editItem->onTextEntry );
g_editItem = NULL;
Display_MouseMove(NULL, DC->cursorx, DC->cursory);
} else if (key == K_TAB || key == K_UPARROW || key == K_DOWNARROW) {
@@ -3040,12 +3050,6 @@ void Menu_HandleKey(menuDef_t *menu, int key, qboolean down) {
// default handling
switch ( key ) {
- case K_F11:
- if (DC->getCVarValue("developer")) {
- debugMode ^= 1;
- }
- break;
-
case K_F12:
if (DC->getCVarValue("developer")) {
DC->executeText(EXEC_APPEND, "screenshot\n");
@@ -3552,7 +3556,7 @@ void Item_Text_Wrapped_Paint( itemDef_t *item )
lineItem.window.border = item->window.border;
lineItem.window.borderSize = item->window.borderSize;
- if( debugMode )
+ if( DC->getCVarValue( "ui_developer" ) )
{
vec4_t color;
color[ 0 ] = color[ 2 ] = color[ 3 ] = 1.0f;
@@ -3949,7 +3953,7 @@ void Controls_SetConfig(qboolean restart)
//if ( s_controls.invertmouse.curvalue )
// DC->setCVar("m_pitch", va("%f),-fabs( DC->getCVarValue( "m_pitch" ) ) );
//else
- // trap_Cvar_SetValue( "m_pitch", fabs( trap_Cvar_VariableValue( "m_pitch" ) ) );
+ // trap_Cvar_SetValue( "m_pitch", fabs( DC->getCVarValue( "m_pitch" ) ) );
//trap_Cvar_SetValue( "m_filter", s_controls.smoothmouse.curvalue );
//trap_Cvar_SetValue( "cl_run", s_controls.alwaysrun.curvalue );
@@ -4080,26 +4084,34 @@ void Item_Bind_Paint(itemDef_t *item) {
if (item->window.flags & WINDOW_HASFOCUS) {
if (g_bindItem == item) {
- lowLight[0] = 0.8f * 1.0f;
- lowLight[1] = 0.8f * 0.0f;
- lowLight[2] = 0.8f * 0.0f;
- lowLight[3] = 0.8f * 1.0f;
- } else {
lowLight[0] = 0.8f * parent->focusColor[0];
lowLight[1] = 0.8f * parent->focusColor[1];
lowLight[2] = 0.8f * parent->focusColor[2];
lowLight[3] = 0.8f * parent->focusColor[3];
- }
- memcpy(newColor, &parent->focusColor, sizeof(vec4_t));
+ LerpColor( parent->focusColor, lowLight, newColor,
+ 0.5 + 0.5 * sin( DC->realTime / PULSE_DIVISOR ) );
+ } else {
+ memcpy(&newColor, &parent->focusColor, sizeof(vec4_t));
+ }
} else {
memcpy(&newColor, &item->window.foreColor, sizeof(vec4_t));
}
if (item->text) {
Item_Text_Paint(item);
- BindingFromName(item->cvar);
- DC->drawText(item->textRect.x + item->textRect.w + ITEM_VALUE_OFFSET, item->textRect.y, item->textscale, newColor, g_nameBind1, 0, maxChars, item->textStyle);
+
+ if( g_bindItem == item && g_waitingForKey )
+ {
+ DC->drawText( item->textRect.x + item->textRect.w + ITEM_VALUE_OFFSET, item->textRect.y,
+ item->textscale, newColor, "Press key", 0, maxChars, item->textStyle);
+ }
+ else
+ {
+ BindingFromName(item->cvar);
+ DC->drawText( item->textRect.x + item->textRect.w + ITEM_VALUE_OFFSET, item->textRect.y,
+ item->textscale, newColor, g_nameBind1, 0, maxChars, item->textStyle);
+ }
} else {
DC->drawText(item->textRect.x, item->textRect.y, item->textscale, newColor, (value != 0) ? "FIXME" : "FIXME", 0, maxChars, item->textStyle);
}
@@ -4710,7 +4722,7 @@ void Item_Paint(itemDef_t *item) {
Window_Paint(&item->window, parent->fadeAmount , parent->fadeClamp, parent->fadeCycle);
- if (debugMode) {
+ if (DC->getCVarValue( "ui_developer" )) {
vec4_t color;
rectDef_t *r = Item_CorrectedTextRect(item);
color[1] = color[3] = 1;
@@ -4982,7 +4994,7 @@ void Menu_Paint(menuDef_t *menu, qboolean forcePaint) {
Item_Paint(menu->items[i]);
}
- if (debugMode) {
+ if (DC->getCVarValue( "ui_developer" )) {
vec4_t color;
color[0] = color[2] = color[3] = 1;
color[1] = 0;
@@ -5547,6 +5559,13 @@ qboolean ItemParse_mouseExitText( itemDef_t *item, int handle ) {
return qtrue;
}
+qboolean ItemParse_onTextEntry( itemDef_t *item, int handle ) {
+ if (!PC_Script_Parse(handle, &item->onTextEntry)) {
+ return qfalse;
+ }
+ return qtrue;
+}
+
qboolean ItemParse_action( itemDef_t *item, int handle ) {
if (!PC_Script_Parse(handle, &item->action)) {
return qfalse;
@@ -5853,6 +5872,7 @@ keywordHash_t itemParseKeywords[] = {
{"mouseExit", ItemParse_mouseExit, NULL},
{"mouseEnterText", ItemParse_mouseEnterText, NULL},
{"mouseExitText", ItemParse_mouseExitText, NULL},
+ {"onTextEntry", ItemParse_onTextEntry, NULL},
{"action", ItemParse_action, NULL},
{"special", ItemParse_special, NULL},
{"cvar", ItemParse_cvar, NULL},
@@ -6357,6 +6377,12 @@ int Menu_Count( void ) {
void Menu_PaintAll( void ) {
int i;
+
+ if( g_editingField || g_waitingForKey )
+ DC->setCVar( "ui_hideCursor", "1" );
+ else
+ DC->setCVar( "ui_hideCursor", "0" );
+
if ( captureFunc != voidFunction ) {
if( captureFuncExpiry > 0 && DC->realTime > captureFuncExpiry ) {
UI_RemoveCaptureFunc( );
@@ -6369,7 +6395,7 @@ void Menu_PaintAll( void ) {
Menu_Paint(&Menus[i], qfalse);
}
- if (debugMode) {
+ if (DC->getCVarValue( "ui_developer" )) {
vec4_t v = {1, 1, 1, 1};
DC->drawText(5, 25, .5, v, va("fps: %f", DC->FPS), 0, 0, 0);
}
diff --git a/src/ui/ui_shared.h b/src/ui/ui_shared.h
index 28b24482..504d0ddf 100644
--- a/src/ui/ui_shared.h
+++ b/src/ui/ui_shared.h
@@ -242,6 +242,7 @@ typedef struct itemDef_s {
const char *action; // select script
const char *onFocus; // select script
const char *leaveFocus; // select script
+ const char *onTextEntry; // called when text entered
const char *cvar; // associated cvar
const char *cvarTest; // associated cvar for enable actions
const char *enableCvar; // enable, disable, show, or hide based on value, this can contain a list