summaryrefslogtreecommitdiff
path: root/src/ui/ui_shared.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/ui_shared.c')
-rw-r--r--src/ui/ui_shared.c83
1 files changed, 83 insertions, 0 deletions
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},