[openjk] 121/130: Shared: Implement menu hacks to workaround buggy menus

Simon McVittie smcv at debian.org
Fri Oct 28 11:09:27 UTC 2016


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian/master
in repository openjk.

commit 93bffc438c501c386b889c755ab6beb29bdd4000
Author: Ensiform <ensiform at gmail.com>
Date:   Tue Oct 25 14:00:27 2016 -0500

    Shared: Implement menu hacks to workaround buggy menus
    
    All: Disable the EAX options on Non Windows 32-bit platforms.
    All: Fix Sound Quality missing the "Very High" (s_khz 44) option.
    SP: Fix subtitle missing "All voiceovers" (g_subtitles 1) option.
    JK2SP: Fix anisotropic filtering being an ON/OFF switch instead of a
    slider for range value.
    MP: Extend favorite address IP field to IPv6 max length.
    MP: Extend player name fields to at least MAX_NAME_LENGTH (32).
---
 code/ui/ui_shared.cpp | 230 +++++++++++++++++++++++++++++++++++++++-----------
 code/ui/ui_shared.h   |   8 +-
 codemp/ui/ui_main.c   |   4 +-
 codemp/ui/ui_shared.c | 135 +++++++++++++++++++++--------
 codemp/ui/ui_shared.h |   8 +-
 5 files changed, 295 insertions(+), 90 deletions(-)

diff --git a/code/ui/ui_shared.cpp b/code/ui/ui_shared.cpp
index 5aa60c6..00614b1 100644
--- a/code/ui/ui_shared.cpp
+++ b/code/ui/ui_shared.cpp
@@ -1027,25 +1027,131 @@ qboolean MenuParse_fadeCycle( itemDef_t *item)
 	return qtrue;
 }
 
+/*
+===============
+Item_ApplyHacks
+Hacks to fix issues with Team Arena menu scripts
+===============
+*/
+static void Item_ApplyHacks( itemDef_t *item ) {
+#if !defined(_WIN32) || ( defined(_WIN32) && defined(idx64) )
+	// Fix length of favorite address in createfavorite.menu
+	if ( item->type == ITEM_TYPE_MULTI && item->cvar && !Q_stricmp( item->cvar, "s_UseOpenAL" ) ) {
+		if( item->parent )
+		{
+			menuDef_t *parent = (menuDef_t *)item->parent;
+			VectorSet4( parent->disableColor, 0.5f, 0.5f, 0.5f, 1.0f );
+			item->disabled = qtrue;
+			// Just in case it had focus
+			item->window.flags &= ~WINDOW_MOUSEOVER;
+			Com_Printf( "Disabling eax field because current platform does not support EAX.\n");
+		}
+	}
+	
+	if ( item->type == ITEM_TYPE_TEXT && item->window.name && !Q_stricmp( item->window.name, "eax_icon") && item->cvarTest && !Q_stricmp( item->cvarTest, "s_UseOpenAL" ) && item->enableCvar && item->cvarFlags & CVAR_HIDE ) {
+		if( item->parent )
+		{
+			menuDef_t *parent = (menuDef_t *)item->parent;
+			VectorSet4( parent->disableColor, 0.5f, 0.5f, 0.5f, 1.0f );
+			item->disabled = item->disabledHidden = qtrue;
+			// Just in case it had focus
+			item->window.flags &= ~WINDOW_MOUSEOVER;
+			Com_Printf( "Hiding eax_icon object because current platform does not support EAX.\n");
+		}
+	}
+#endif
+
+	if ( item->type == ITEM_TYPE_MULTI && item->window.name && !Q_stricmp( item->window.name, "sound_quality") ) {
+		multiDef_t *multiPtr = (multiDef_t *)item->typeData;
+		int i;
+		qboolean found = qfalse;
+		for( i = 0; i < multiPtr->count; i++ )
+		{
+			if ( multiPtr->cvarValue[i] == 44 )
+			{
+				found = qtrue;
+				break;
+			}
+		}
+		if ( !found && multiPtr->count < MAX_MULTI_CVARS )
+		{
+#ifdef JK2_MODE
+			multiPtr->cvarList[multiPtr->count] = String_Alloc("@MENUS0_VERY_HIGH");
+#else
+			multiPtr->cvarList[multiPtr->count] = String_Alloc("@MENUS_VERY_HIGH");
+#endif
+			multiPtr->cvarValue[multiPtr->count] = 44;
+			multiPtr->count++;
+			Com_Printf( "Extended sound quality field to contain very high option.\n");
+		}
+	}
+	
+	if ( item->type == ITEM_TYPE_MULTI && item->window.name && !Q_stricmp( item->window.name, "voice") && item->cvar && !Q_stricmp( item->cvar, "g_subtitles" ) ) {
+		multiDef_t *multiPtr = (multiDef_t *)item->typeData;
+		int i;
+		qboolean found = qfalse;
+		for( i = 0; i < multiPtr->count; i++ )
+		{
+			if ( multiPtr->cvarValue[i] == 1 )
+			{
+				found = qtrue;
+				break;
+			}
+		}
+		if ( !found && multiPtr->count < MAX_MULTI_CVARS )
+		{
+#ifdef JK2_MODE
+			multiPtr->cvarList[multiPtr->count] = String_Alloc("@MENUS3_ALL_VOICEOVERS");
+#else
+			multiPtr->cvarList[multiPtr->count] = String_Alloc("@MENUS_ALL_VOICEOVERS");
+#endif
+			multiPtr->cvarValue[multiPtr->count] = 1;
+			multiPtr->count++;
+			Com_Printf( "Extended subtitles field to contain all voiceovers option.\n");
+		}
+	}
+
+#ifdef JK2_MODE
+	if ( item->type == ITEM_TYPE_MULTI && item->window.name && !Q_stricmp( item->window.name, "video_mode") && item->cvar && !Q_stricmp( item->cvar, "r_ext_texture_filter_anisotropic" ) ) {
+		{
+			memset(item->typeData, 0, sizeof(multiDef_t));
+		}
+		editFieldDef_t *editPtr = NULL;
+
+		item->cvarFlags = CVAR_DISABLE;
+		item->type = ITEM_TYPE_SLIDER;
+
+		Item_ValidateTypeData(item);
+
+		editPtr = (editFieldDef_t *)item->typeData;
+		editPtr->minVal = 0.5f;
+		editPtr->maxVal = cls.glconfig.maxTextureFilterAnisotropy;
+		editPtr->defVal = 1.0f;
+		Com_Printf( "Converted anisotropic filter field to slider.\n");
+	}
+#endif
+}
 
 /*
 ================
 MenuParse_itemDef
 ================
 */
-qboolean MenuParse_itemDef( itemDef_t *item)
+qboolean MenuParse_itemDef( itemDef_t *item )
 {
 	menuDef_t *menu = (menuDef_t*)item;
 	if (menu->itemCount < MAX_MENUITEMS)
 	{
-		menu->items[menu->itemCount] = (struct itemDef_s *) UI_Alloc(sizeof(itemDef_t));
-		Item_Init(menu->items[menu->itemCount]);
-		if (!Item_Parse(menu->items[menu->itemCount]))
+		itemDef_t *newItem = menu->items[menu->itemCount] = (struct itemDef_s *) UI_Alloc(sizeof(itemDef_t));
+		Item_Init(newItem);
+		if (!Item_Parse(newItem))
 		{
 			return qfalse;
 		}
-		Item_InitControls(menu->items[menu->itemCount]);
-		menu->items[menu->itemCount++]->parent = menu;
+		Item_InitControls( newItem );
+		newItem->parent = menu->items[menu->itemCount]->parent = menu;
+		menu->itemCount++;
+		Item_ApplyHacks( newItem );
 	}
 	else
 	{
@@ -1851,6 +1957,25 @@ void Menu_OrbitItemByName(menuDef_t *menu, const char *p, float x, float y, floa
 	}
 }
 
+void Menu_ItemDisable(menuDef_t *menu, const char *name, qboolean disableFlag)
+{
+	int	j,count;
+	itemDef_t *itemFound;
+
+	count = Menu_ItemsMatchingGroup(menu, name);
+	// Loop through all items that have this name
+	for (j = 0; j < count; j++)
+	{
+		itemFound = Menu_GetMatchingItemByNumber( menu, j, name);
+		if (itemFound != NULL)
+		{
+			itemFound->disabled = disableFlag;
+			// Just in case it had focus
+			itemFound->window.flags &= ~WINDOW_MOUSEOVER;
+		}
+	}
+}
+
 /*
 =================
 Rect_Parse
@@ -6156,6 +6281,11 @@ void Item_TextColor(itemDef_t *item, vec4_t *newColor)
 		memcpy(newColor, &item->window.foreColor, sizeof(vec4_t));
 	}
 
+	if (item->disabled)
+	{
+		memcpy(newColor, &parent->disableColor, sizeof(vec4_t));
+	}
+
 	// items can be enabled and disabled based on cvars
 	if (item->enableCvar && *item->enableCvar && item->cvarTest && *item->cvarTest)
 	{
@@ -7295,6 +7425,9 @@ void Item_OwnerDraw_Paint(itemDef_t *item)
 			LerpColor(item->window.foreColor,lowLight,color,0.5+0.5*sin((float)(DC->realTime / PULSE_DIVISOR)));
 		}
 
+		if ( item->disabled )
+			memcpy( color, parent->disableColor, sizeof( vec4_t ) );
+
 		if (item->cvarFlags & (CVAR_ENABLE | CVAR_DISABLE) && !Item_EnableShowViaCvar(item, CVAR_ENABLE))
 		{
 			memcpy(color, parent->disableColor, sizeof(vec4_t));
@@ -7316,25 +7449,11 @@ void Item_OwnerDraw_Paint(itemDef_t *item)
 
 void Item_YesNo_Paint(itemDef_t *item)
 {
-	vec4_t newColor, lowLight;
+	vec4_t color;
 	float value;
-	menuDef_t *parent = (menuDef_t*)item->parent;
 
 	value = (item->cvar) ? DC->getCVarValue(item->cvar) : 0;
 
-	if (item->window.flags & WINDOW_HASFOCUS)
-	{
-		lowLight[0] = 0.8 * parent->focusColor[0];
-		lowLight[1] = 0.8 * parent->focusColor[1];
-		lowLight[2] = 0.8 * parent->focusColor[2];
-		lowLight[3] = 0.8 * parent->focusColor[3];
-		LerpColor(parent->focusColor,lowLight,newColor,0.5+0.5*sin((float)(DC->realTime / PULSE_DIVISOR)));
-	}
-	else
-	{
-		memcpy(&newColor, &item->window.foreColor, sizeof(vec4_t));
-	}
-
 #ifdef JK2_MODE
 	const char *psYes = ui.SP_GetStringTextString( "MENUS0_YES" );
 	const char *psNo = ui.SP_GetStringTextString( "MENUS0_NO" );
@@ -7349,15 +7468,15 @@ void Item_YesNo_Paint(itemDef_t *item)
 	else
 		yesnovalue = (value != 0) ? psYes : psNo;
 
+	Item_TextColor(item, &color);
 	if (item->text)
 	{
 		Item_Text_Paint(item);
-		DC->drawText(item->textRect.x + item->textRect.w + 8, item->textRect.y, item->textscale, newColor, yesnovalue, 0, item->textStyle, item->font);
-
+		DC->drawText(item->textRect.x + item->textRect.w + 8, item->textRect.y, item->textscale, color, yesnovalue, 0, item->textStyle, item->font);
 	}
 	else
 	{
-		DC->drawText(item->textRect.x, item->textRect.y, item->textscale, newColor, yesnovalue , 0, item->textStyle, item->font);
+		DC->drawText(item->textRect.x, item->textRect.y, item->textscale, color, yesnovalue , 0, item->textStyle, item->font);
 	}
 
 }
@@ -7369,22 +7488,8 @@ Item_Multi_Paint
 */
 void Item_Multi_Paint(itemDef_t *item)
 {
-	vec4_t newColor, lowLight;
+	vec4_t color;
 	const char *text = "";
-	menuDef_t *parent = (menuDef_t*)item->parent;
-
-	if (item->window.flags & WINDOW_HASFOCUS)
-	{
-		lowLight[0] = 0.8 * parent->focusColor[0];
-		lowLight[1] = 0.8 * parent->focusColor[1];
-		lowLight[2] = 0.8 * parent->focusColor[2];
-		lowLight[3] = 0.8 * parent->focusColor[3];
-		LerpColor(parent->focusColor,lowLight,newColor,0.5+0.5*sin((float)(DC->realTime / PULSE_DIVISOR)));
-	}
-	else
-	{
-		memcpy(&newColor, &item->window.foreColor, sizeof(vec4_t));
-	}
 
 	text = Item_Multi_Setting(item);
 	if (*text == '@')	// string reference
@@ -7392,16 +7497,16 @@ void Item_Multi_Paint(itemDef_t *item)
 		text = SE_GetString( &text[1] );
 	}
 
-
+	Item_TextColor(item, &color);
 	if (item->text)
 	{
 		Item_Text_Paint(item);
-		DC->drawText(item->textRect.x + item->textRect.w + 8, item->textRect.y, item->textscale, newColor, text, 0, item->textStyle, item->font);
+		DC->drawText(item->textRect.x + item->textRect.w + 8, item->textRect.y, item->textscale, color, text, 0, item->textStyle, item->font);
 	}
 	else
 	{
 //JLF added xoffset
-		DC->drawText(item->textRect.x +item->xoffset, item->textRect.y, item->textscale, newColor, text, 0, item->textStyle, item->font);
+		DC->drawText(item->textRect.x +item->xoffset, item->textRect.y, item->textscale, color, text, 0, item->textStyle, item->font);
 	}
 }
 
@@ -8088,6 +8193,11 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
 		}
 	}
 
+	if (item->disabled && item->disabledHidden)
+	{
+		return qfalse;
+	}
+
 	if (item->cvarFlags & (CVAR_SHOW | CVAR_HIDE))
 	{
 		if (!Item_EnableShowViaCvar(item, CVAR_SHOW))
@@ -8337,10 +8447,9 @@ Window_Paint
 */
 void Window_Paint(Window *w, float fadeAmount, float fadeClamp, float fadeCycle)
 {
-  //float bordersize = 0;
-  vec4_t color;
-  rectDef_t fillRect = w->rect;
-
+	//float bordersize = 0;
+	vec4_t color;
+	rectDef_t fillRect = w->rect;
 
 	if (uis.debugMode)
 	{
@@ -8985,6 +9094,12 @@ void Item_MouseEnter(itemDef_t *item, float x, float y)
 //		r.y -= r.h;			// NOt sure why this is here, but I commented it out.
 		// in the text rect?
 
+		// items can be enabled and disabled
+		if (item->disabled)
+		{
+			return;
+		}
+
 		// items can be enabled and disabled based on cvars
 		if (item->cvarFlags & (CVAR_ENABLE | CVAR_DISABLE) && !Item_EnableShowViaCvar(item, CVAR_ENABLE))
 		{
@@ -9061,6 +9176,12 @@ qboolean Item_SetFocus(itemDef_t *item, float x, float y)
 	}
 	menuDef_t *parent = (menuDef_t*)item->parent;
 
+	// items can be enabled and disabled
+	if (item->disabled)
+	{
+		return qfalse;
+	}
+
 	// items can be enabled and disabled based on cvars
 	if (item->cvarFlags & (CVAR_ENABLE | CVAR_DISABLE) && !Item_EnableShowViaCvar(item, CVAR_ENABLE))
 	{
@@ -9234,6 +9355,11 @@ void Menu_HandleMouseMove(menuDef_t *menu, float x, float y)
 				continue;
 			}
 
+			if (menu->items[i]->disabled)
+			{
+				continue;
+			}
+
 			// items can be enabled and disabled based on cvars
 			if (menu->items[i]->cvarFlags & (CVAR_ENABLE | CVAR_DISABLE) && !Item_EnableShowViaCvar(menu->items[i], CVAR_ENABLE))
 			{
@@ -11096,12 +11222,22 @@ void Menu_HandleKey(menuDef_t *menu, int key, qboolean down)
 		}
 	}
 
+	// Ignore if disabled
+	if (item && item->disabled)
+	{
+		return;
+	}
+
 	if (item != NULL)
 	{
 		if (Item_HandleKey(item, key, down))
 //JLFLISTBOX
 		{
-			Item_Action(item);
+			// It is possible for an item to be disable after Item_HandleKey is run (like in Voice Chat)
+			if (!item->disabled)
+			{
+				Item_Action(item);
+			}
 			inHandler = qfalse;
 			return;
 		}
diff --git a/code/ui/ui_shared.h b/code/ui/ui_shared.h
index 53151f3..a661370 100644
--- a/code/ui/ui_shared.h
+++ b/code/ui/ui_shared.h
@@ -395,7 +395,8 @@ typedef struct itemDef_s {
 	int			font;						// FONT_SMALL,FONT_MEDIUM,FONT_LARGE
 	int			invertYesNo;
 	int			xoffset;
-
+	qboolean	disabled;					// Does this item ignore mouse and keyboard focus
+	qboolean	disabledHidden;				// hide the item when 'disabled' is true (for generic image items)
 } itemDef_t;
 
 typedef struct {
@@ -471,6 +472,11 @@ qboolean	Menus_AnyFullScreenVisible(void);
 void		Menus_CloseAll(void);
 int			Menu_Count(void);
 itemDef_t	*Menu_FindItemByName(menuDef_t *menu, const char *p);
+void Menu_ShowGroup (menuDef_t *menu, const char *itemName, qboolean showFlag);
+void Menu_ItemDisable(menuDef_t *menu, const char *name, qboolean disableFlag);
+int Menu_ItemsMatchingGroup(menuDef_t *menu, const char *name);
+itemDef_t *Menu_GetMatchingItemByNumber(menuDef_t *menu, int index, const char *name);
+
 void		Menu_HandleKey(menuDef_t *menu, int key, qboolean down);
 void		Menu_New(char *buffer);
 void		Menus_OpenByName(const char *p);
diff --git a/codemp/ui/ui_main.c b/codemp/ui/ui_main.c
index 40fa5de..ad767d8 100644
--- a/codemp/ui/ui_main.c
+++ b/codemp/ui/ui_main.c
@@ -6828,7 +6828,7 @@ static void UI_RunMenuScript(char **args)
 						Menu_SetItemBackground(menu, item->window.name, string2);
 
 						// Re-enable this button
-						Menu_ItemDisable(menu,(char *) item->window.name, qfalse);
+						Menu_ItemDisable(menu, item->window.name, qfalse);
 					}
 
 					// Set the new item to the given background
@@ -6845,7 +6845,7 @@ static void UI_RunMenuScript(char **args)
 								trap->Cvar_VariableStringBuffer( cvarLitArg, string, sizeof(string) );
 								Menu_SetItemBackground(menu, item->window.name, string);
 								// Disable button
-								Menu_ItemDisable(menu,(char *) item->window.name, qtrue);
+								Menu_ItemDisable(menu, item->window.name, qtrue);
 							}
 						}
 					}
diff --git a/codemp/ui/ui_shared.c b/codemp/ui/ui_shared.c
index 225c65c..b10c6fe 100644
--- a/codemp/ui/ui_shared.c
+++ b/codemp/ui/ui_shared.c
@@ -1317,7 +1317,7 @@ qboolean Script_SetItemRect(itemDef_t *item, char **args)
 	return qtrue;
 }
 
-void Menu_ShowGroup (menuDef_t *menu, char *groupName, qboolean showFlag)
+void Menu_ShowGroup (menuDef_t *menu, const char *groupName, qboolean showFlag)
 {
 	itemDef_t *item;
 	int count,j;
@@ -1710,7 +1710,7 @@ void Menu_OrbitItemByName(menuDef_t *menu, const char *p, float x, float y, floa
 	}
 }
 
-void Menu_ItemDisable(menuDef_t *menu, char *name,int disableFlag)
+void Menu_ItemDisable(menuDef_t *menu, const char *name, qboolean disableFlag)
 {
 	int	j,count;
 	itemDef_t *itemFound;
@@ -4691,8 +4691,6 @@ void Item_Text_Paint(itemDef_t *item) {
 	}
 }
 
-
-
 void Item_TextField_Paint(itemDef_t *item) {
 	char buff[1024];
 	vec4_t newColor, lowLight;
@@ -4736,23 +4734,12 @@ void Item_TextField_Paint(itemDef_t *item) {
 void Item_YesNo_Paint(itemDef_t *item) {
 	char	sYES[20];
 	char	sNO[20];
-	vec4_t newColor, lowLight;
+	vec4_t color;
 	float value;
-	menuDef_t *parent = (menuDef_t*)item->parent;
 	const char *yesnovalue;
 
 	value = (item->cvar) ? DC->getCVarValue(item->cvar) : 0;
 
-	if (item->window.flags & WINDOW_HASFOCUS) {
-		lowLight[0] = 0.8 * parent->focusColor[0];
-		lowLight[1] = 0.8 * parent->focusColor[1];
-		lowLight[2] = 0.8 * parent->focusColor[2];
-		lowLight[3] = 0.8 * parent->focusColor[3];
-		LerpColor(parent->focusColor,lowLight,newColor,0.5+0.5*sin((float)(DC->realTime / PULSE_DIVISOR)));
-	} else {
-		memcpy(&newColor, &item->window.foreColor, sizeof(vec4_t));
-	}
-
 	trap->SE_GetStringTextString("MENUS_YES",sYES, sizeof(sYES));
 	trap->SE_GetStringTextString("MENUS_NO", sNO,  sizeof(sNO));
 
@@ -4762,14 +4749,15 @@ void Item_YesNo_Paint(itemDef_t *item) {
 	else
 		yesnovalue = (value != 0) ? sYES : sNO;
 
+	Item_TextColor(item, &color);
 	if (item->text)
 	{
 		Item_Text_Paint(item);
-		DC->drawText(item->textRect.x + item->textRect.w + 8, item->textRect.y, item->textscale, newColor, yesnovalue, 0, 0, item->textStyle, item->iMenuFont);
+		DC->drawText(item->textRect.x + item->textRect.w + 8, item->textRect.y, item->textscale, color, yesnovalue, 0, 0, item->textStyle, item->iMenuFont);
 	}
 	else
 	{
-		DC->drawText(item->textRect.x, item->textRect.y, item->textscale, newColor, yesnovalue , 0, 0, item->textStyle, item->iMenuFont);
+		DC->drawText(item->textRect.x, item->textRect.y, item->textscale, color, yesnovalue , 0, 0, item->textStyle, item->iMenuFont);
 	}
 
 /* JLF ORIGINAL CODE
@@ -4785,21 +4773,10 @@ void Item_YesNo_Paint(itemDef_t *item) {
 }
 
 void Item_Multi_Paint(itemDef_t *item) {
-	vec4_t newColor, lowLight;
+	vec4_t color;
 	const char *text = "";
-	menuDef_t *parent = (menuDef_t*)item->parent;
 	char	temp[MAX_STRING_CHARS];
 
-	if (item->window.flags & WINDOW_HASFOCUS) {
-		lowLight[0] = 0.8 * parent->focusColor[0];
-		lowLight[1] = 0.8 * parent->focusColor[1];
-		lowLight[2] = 0.8 * parent->focusColor[2];
-		lowLight[3] = 0.8 * parent->focusColor[3];
-		LerpColor(parent->focusColor,lowLight,newColor,0.5+0.5*sin((float)(DC->realTime / PULSE_DIVISOR)));
-	} else {
-		memcpy(&newColor, &item->window.foreColor, sizeof(vec4_t));
-	}
-
 	text = Item_Multi_Setting(item);
 	if (*text == '@')	// string reference
 	{
@@ -4813,12 +4790,13 @@ void Item_Multi_Paint(itemDef_t *item) {
 		text = temp;
 	}
 
+	Item_TextColor(item, &color);
 	if (item->text) {
 		Item_Text_Paint(item);
-		DC->drawText(item->textRect.x + item->textRect.w + 8, item->textRect.y, item->textscale, newColor, text, 0, 0, item->textStyle,item->iMenuFont);
+		DC->drawText(item->textRect.x + item->textRect.w + 8, item->textRect.y, item->textscale, color, text, 0, 0, item->textStyle,item->iMenuFont);
 	} else {
 		//JLF added xoffset
-		DC->drawText(item->textRect.x+item->xoffset, item->textRect.y, item->textscale, newColor, text, 0, 0, item->textStyle,item->iMenuFont);
+		DC->drawText(item->textRect.x+item->xoffset, item->textRect.y, item->textscale, color, text, 0, 0, item->textStyle,item->iMenuFont);
 	}
 }
 
@@ -8460,6 +8438,86 @@ void Item_SetupKeywordHash(void) {
 
 /*
 ===============
+Item_ApplyHacks
+Hacks to fix issues with Team Arena menu scripts
+===============
+*/
+static void Item_ApplyHacks( itemDef_t *item ) {
+#if !defined(_WIN32) || ( defined(_WIN32) && defined(idx64) )
+	if ( item->type == ITEM_TYPE_MULTI && item->cvar && !Q_stricmp( item->cvar, "s_UseOpenAL" ) ) {
+		if( item->parent )
+		{
+			menuDef_t *parent = (menuDef_t *)item->parent;
+			VectorSet4( parent->disableColor, 0.5f, 0.5f, 0.5f, 1.0f );
+			item->disabled = qtrue;
+			// Just in case it had focus
+			item->window.flags &= ~WINDOW_MOUSEOVER;
+			Com_Printf( "Disabling eax field because current platform does not support EAX.\n");
+		}
+	}
+
+	if ( item->type == ITEM_TYPE_TEXT && item->window.name && !Q_stricmp( item->window.name, "eax_icon") && item->cvarTest && !Q_stricmp( item->cvarTest, "s_UseOpenAL" ) && item->enableCvar && item->cvarFlags & CVAR_HIDE ) {
+		if( item->parent )
+		{
+			menuDef_t *parent = (menuDef_t *)item->parent;
+			VectorSet4( parent->disableColor, 0.5f, 0.5f, 0.5f, 1.0f );
+			item->disabled = item->disabledHidden = qtrue;
+			// Just in case it had focus
+			item->window.flags &= ~WINDOW_MOUSEOVER;
+			Com_Printf( "Hiding eax_icon object because current platform does not support EAX.\n");
+		}
+	}
+#endif
+	
+	// Fix length of favorite address in createfavorite.menu
+	if ( item->type == ITEM_TYPE_EDITFIELD && item->cvar && !Q_stricmp( item->cvar, "ui_favoriteAddress" ) ) {
+		editFieldDef_t *editField = item->typeData.edit;
+
+		// enough to hold an IPv6 address plus null
+		if ( editField->maxChars < 48 ) {
+			Com_Printf( "Extended create favorite address edit field length to hold an IPv6 address\n" );
+			editField->maxChars = 48;
+		}
+	}
+
+	if ( item->type == ITEM_TYPE_EDITFIELD && item->cvar && ( !Q_stricmp( item->cvar, "ui_Name" ) || !Q_stricmp( item->cvar, "ui_findplayer" ) ) ) {
+		editFieldDef_t *editField = item->typeData.edit;
+
+		// enough to hold a full player name
+		if ( editField->maxChars < MAX_NAME_LENGTH ) {
+			if ( editField->maxPaintChars > editField->maxChars ) {
+				editField->maxPaintChars = editField->maxChars;
+			}
+
+			Com_Printf( "Extended player name field using cvar %s to %d characters\n", item->cvar, MAX_NAME_LENGTH );
+			editField->maxChars = MAX_NAME_LENGTH;
+		}
+	}
+
+	if ( item->type == ITEM_TYPE_MULTI && item->window.name && !Q_stricmp( item->window.name, "sound_quality") ) {
+		multiDef_t *multiPtr = item->typeData.multi;
+		int i;
+		qboolean found = qfalse;
+		for( i = 0; i < multiPtr->count; i++ )
+		{
+			if ( multiPtr->cvarValue[i] == 44 )
+			{
+				found = qtrue;
+				break;
+			}
+		}
+		if ( !found && multiPtr->count < MAX_MULTI_CVARS )
+		{
+			multiPtr->cvarList[multiPtr->count] = String_Alloc("@MENUS_VERY_HIGH");
+			multiPtr->cvarValue[multiPtr->count] = 44;
+			multiPtr->count++;
+			Com_Printf( "Extended sound quality field to contain very high setting.\n");
+		}
+	}
+}
+
+/*
+===============
 Item_Parse
 ===============
 */
@@ -9142,13 +9200,16 @@ qboolean MenuParse_fadeCycle( itemDef_t *item, int handle ) {
 qboolean MenuParse_itemDef( itemDef_t *item, int handle ) {
 	menuDef_t *menu = (menuDef_t*)item;
 	if (menu->itemCount < MAX_MENUITEMS) {
-		menu->items[menu->itemCount] = (itemDef_t *) UI_Alloc(sizeof(itemDef_t));
-		Item_Init(menu->items[menu->itemCount]);
-		if (!Item_Parse(handle, menu->items[menu->itemCount])) {
+		itemDef_t *newItem = menu->items[menu->itemCount] = (itemDef_t *) UI_Alloc(sizeof(itemDef_t));
+		Item_Init(newItem);
+		if (!Item_Parse(handle, newItem))
+		{
 			return qfalse;
 		}
-		Item_InitControls(menu->items[menu->itemCount]);
-		menu->items[menu->itemCount++]->parent = menu;
+		Item_InitControls( newItem );
+		newItem->parent = menu->items[menu->itemCount]->parent = menu;
+		menu->itemCount++;
+		Item_ApplyHacks( newItem );
 	}
 	return qtrue;
 }
diff --git a/codemp/ui/ui_shared.h b/codemp/ui/ui_shared.h
index 56a0ee7..dcaac98 100644
--- a/codemp/ui/ui_shared.h
+++ b/codemp/ui/ui_shared.h
@@ -199,7 +199,7 @@ typedef struct editFieldDef_s {
 	int paintOffset;		//
 } editFieldDef_t;
 
-#define MAX_MULTI_CVARS 32
+#define MAX_MULTI_CVARS 64//32
 
 typedef struct multiDef_s {
 	const char *cvarList[MAX_MULTI_CVARS];
@@ -313,6 +313,8 @@ typedef struct itemDef_s {
 	qboolean	disabled;					// Does this item ignore mouse and keyboard focus
 	int			invertYesNo;
 	int			xoffset;
+
+	qboolean disabledHidden;				// hide the item when 'disabled' is true (for generic image items)
 } itemDef_t;
 
 typedef struct menuDef_s {
@@ -520,8 +522,8 @@ void Menu_Reset(void);
 qboolean Menus_AnyFullScreenVisible( void );
 void  Menus_Activate(menuDef_t *menu);
 itemDef_t *Menu_FindItemByName(menuDef_t *menu, const char *p);
-void Menu_ShowGroup (menuDef_t *menu, char *itemName, qboolean showFlag);
-void Menu_ItemDisable(menuDef_t *menu, char *name,int disableFlag);
+void Menu_ShowGroup (menuDef_t *menu, const char *itemName, qboolean showFlag);
+void Menu_ItemDisable(menuDef_t *menu, const char *name, qboolean disableFlag);
 int Menu_ItemsMatchingGroup(menuDef_t *menu, const char *name);
 itemDef_t *Menu_GetMatchingItemByNumber(menuDef_t *menu, int index, const char *name);
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/openjk.git



More information about the Pkg-games-commits mailing list