summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/ui_main.c20
-rw-r--r--src/ui/ui_shared.c83
-rw-r--r--src/ui/ui_shared.h3
3 files changed, 106 insertions, 0 deletions
diff --git a/src/ui/ui_main.c b/src/ui/ui_main.c
index a1423e86..46961723 100644
--- a/src/ui/ui_main.c
+++ b/src/ui/ui_main.c
@@ -3058,6 +3058,26 @@ static void UI_RunMenuScript( char **args )
else
trap_Cmd_ExecuteText( EXEC_APPEND, va( "say \"%s\"\n", buffer ) );
}
+ else if( Q_stricmp( name, "SayKeydown" ) == 0 )
+ {
+ if( ui_chatCommands.integer )
+ {
+ char buffer[ MAX_CVAR_VALUE_STRING ];
+ trap_Cvar_VariableStringBuffer( "ui_sayBuffer", buffer, sizeof( buffer ) );
+
+ if( buffer[ 0 ] == '/' || buffer[ 0 ] == '\\' )
+ {
+ Menus_ReplaceActiveByName( "say_command" );
+ }
+ else
+ {
+ if( !uiInfo.chatTeam )
+ Menus_ReplaceActiveByName( "say" );
+ else
+ Menus_ReplaceActiveByName( "say_team" );
+ }
+ }
+ }
else if( Q_stricmp( name, "playMovie" ) == 0 )
{
if( uiInfo.previewMovie >= 0 )
diff --git a/src/ui/ui_shared.c b/src/ui/ui_shared.c
index 0a416282..fcf359f1 100644
--- a/src/ui/ui_shared.c
+++ b/src/ui/ui_shared.c
@@ -3927,6 +3927,55 @@ void Menus_Activate( menuDef_t *menu )
}
}
+qboolean Menus_ReplaceActive( menuDef_t *menu )
+{
+ int i;
+ menuDef_t *active;
+
+ if( openMenuCount < 1 )
+ return qfalse;
+
+ active = menuStack[ openMenuCount - 1];
+
+ if( !( active->window.flags & WINDOW_HASFOCUS ) ||
+ !( active->window.flags & WINDOW_VISIBLE ) )
+ {
+ return qfalse;
+ }
+
+ if( menu == active )
+ return qfalse;
+
+ if( menu->itemCount != active->itemCount )
+ return qfalse;
+
+ for( i = 0; i < menu->itemCount; i++ )
+ {
+ if( menu->items[ i ]->type != active->items[ i ]->type )
+ return qfalse;
+ }
+
+ active->window.flags &= ~( WINDOW_FADINGOUT | WINDOW_VISIBLE );
+ menu->window.flags |= ( WINDOW_HASFOCUS | WINDOW_VISIBLE );
+
+ menuStack[ openMenuCount - 1 ] = menu;
+ if( menu->onOpen )
+ {
+ itemDef_t item;
+ item.parent = menu;
+ Item_RunScript( &item, menu->onOpen );
+ }
+
+ for( i = 0; i < menu->itemCount; i++ )
+ {
+ menu->items[ i ]->cursorPos = active->items[ i ]->cursorPos;
+ menu->items[ i ]->typeData.list->startPos = active->items[ i ]->typeData.list->startPos;
+ menu->items[ i ]->feederID = active->items[ i ]->feederID;
+ menu->items[ i ]->typeData.combo->cursorPos = active->items[ i ]->typeData.combo->cursorPos;
+ }
+ return qtrue;
+}
+
int Display_VisibleMenuCount( void )
{
int i, count;
@@ -4015,6 +4064,10 @@ void Menu_HandleKey( menuDef_t *menu, int key, qboolean down )
inHandler = qfalse;
return;
}
+ else
+ {
+ Item_RunScript( g_editItem, g_editItem->onCharEntry );
+ }
}
if( menu == NULL )
@@ -6159,6 +6212,26 @@ menuDef_t *Menus_ActivateByName( const char *p )
return m;
}
+menuDef_t *Menus_ReplaceActiveByName( const char *p )
+{
+ int i;
+ menuDef_t *m = NULL;
+
+ // Activate one menu
+
+ for( i = 0; i < menuCount; i++ )
+ {
+ if( Q_stricmp( Menus[i].window.name, p ) == 0 )
+ {
+ m = &Menus[i];
+ if(! Menus_ReplaceActive( m ) )
+ return NULL;
+ break;
+ }
+ }
+ return m;
+}
+
void Item_Init( itemDef_t *item )
{
@@ -6944,6 +7017,15 @@ qboolean ItemParse_onTextEntry( itemDef_t *item, int handle )
return qtrue;
}
+
+qboolean ItemParse_onCharEntry( itemDef_t *item, int handle )
+{
+ if( !PC_Script_Parse( handle, &item->onCharEntry ) )
+ return qfalse;
+
+ return qtrue;
+}
+
qboolean ItemParse_action( itemDef_t *item, int handle )
{
if( !PC_Script_Parse( handle, &item->action ) )
@@ -7245,6 +7327,7 @@ keywordHash_t itemParseKeywords[] = {
{"mouseEnterText", ItemParse_mouseEnterText, TYPE_ANY},
{"mouseExitText", ItemParse_mouseExitText, TYPE_ANY},
{"onTextEntry", ItemParse_onTextEntry, TYPE_ANY},
+ {"onCharEntry", ItemParse_onCharEntry, TYPE_ANY},
{"action", ItemParse_action, TYPE_ANY},
{"cvar", ItemParse_cvar, TYPE_ANY},
{"maxChars", ItemParse_maxChars, TYPE_EDIT},
diff --git a/src/ui/ui_shared.h b/src/ui/ui_shared.h
index d96eabf1..462a4bb4 100644
--- a/src/ui/ui_shared.h
+++ b/src/ui/ui_shared.h
@@ -284,6 +284,7 @@ typedef struct itemDef_s
const char *onFocus; // select script
const char *leaveFocus; // select script
const char *onTextEntry; // called when text entered
+ const char *onCharEntry; // 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
@@ -476,9 +477,11 @@ int Menu_Count( void );
void Menu_New( int handle );
void Menu_PaintAll( void );
menuDef_t *Menus_ActivateByName( const char *p );
+menuDef_t *Menus_ReplaceActiveByName( const char *p );
void Menu_Reset( void );
qboolean Menus_AnyFullScreenVisible( void );
void Menus_Activate( menuDef_t *menu );
+qboolean Menus_ReplaceActive( menuDef_t *menu );
displayContextDef_t *Display_GetContext( void );
void *Display_CaptureItem( int x, int y );