summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorTony J. White <tjw@tjw.org>2009-12-09 04:21:06 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:17:23 +0000
commit29fd44bde9c343e1ef72498a1372243831eb290e (patch)
tree8afa434c85b5000ebc4d89bea60f792de2deaca7 /src/ui
parentc30d1b0c4fdd96979b616b67eda9d96aae37209a (diff)
* add warnings for Menus_ReplaceActive() when there is a menu item mismatch
between the active menu and the new one. * maintain the proper cursor state on menu items in Menus_ReplaceActive()
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/ui_shared.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/ui/ui_shared.c b/src/ui/ui_shared.c
index 9b878b0d..f24e91eb 100644
--- a/src/ui/ui_shared.c
+++ b/src/ui/ui_shared.c
@@ -77,6 +77,7 @@ int openMenuCount = 0;
#define DOUBLE_CLICK_DELAY 300
static int lastListBoxClickTime = 0;
+itemDataType_t Item_DataType( itemDef_t *item );
void Item_RunScript( itemDef_t *item, const char *s );
void Item_SetupKeywordHash( void );
static ID_INLINE qboolean Item_IsEditField( itemDef_t *item );
@@ -3865,12 +3866,21 @@ qboolean Menus_ReplaceActive( menuDef_t *menu )
return qfalse;
if( menu->itemCount != active->itemCount )
+ {
+ Com_Printf( S_COLOR_YELLOW
+ "WARNING: Menus_ReplaceActive: expecting %i menu items, found %i\n",
+ menu->itemCount, active->itemCount);
return qfalse;
+ }
for( i = 0; i < menu->itemCount; i++ )
{
if( menu->items[ i ]->type != active->items[ i ]->type )
+ {
+ Com_Printf( S_COLOR_YELLOW
+ "WARNING: Menus_ReplaceActive: type mismatch on item %i\n", i + 1 );
return qfalse;
+ }
}
active->window.flags &= ~( WINDOW_FADINGOUT | WINDOW_VISIBLE );
@@ -3884,6 +3894,27 @@ qboolean Menus_ReplaceActive( menuDef_t *menu )
Item_RunScript( &item, menu->onOpen );
}
+ // set the cursor position on the new menu to match the active one
+ for( i = 0; i < menu->itemCount; i++ )
+ {
+ menu->items[ i ]->cursorPos = active->items[ i ]->cursorPos;
+ menu->items[ i ]->feederID = active->items[ i ]->feederID;
+ switch( Item_DataType( menu->items[ i ] ) )
+ {
+ case TYPE_LIST:
+ menu->items[ i ]->typeData.list->startPos =
+ active->items[ i ]->typeData.list->startPos;
+ menu->items[ i ]->typeData.list->cursorPos =
+ active->items[ i ]->typeData.list->cursorPos;
+ break;
+ case TYPE_COMBO:
+ menu->items[ i ]->typeData.cycle->cursorPos =
+ active->items[ i ]->typeData.cycle->cursorPos;
+ break;
+ default:
+ break;
+ }
+ }
return qtrue;
}