From c4094de4dff6cd04a16d5f0f46140d083b0efe1c Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Sun, 10 Mar 2024 00:59:40 -0500
Subject: [PATCH] Make nametag padding settings

---
 indra/newview/llhudnametag.cpp | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/indra/newview/llhudnametag.cpp b/indra/newview/llhudnametag.cpp
index cfbdfecc9ab..20e53138431 100644
--- a/indra/newview/llhudnametag.cpp
+++ b/indra/newview/llhudnametag.cpp
@@ -52,9 +52,6 @@
 
 
 const F32 SPRING_STRENGTH = 0.7f;
-const F32 HORIZONTAL_PADDING = 16.f;
-const F32 VERTICAL_PADDING = 12.f;
-const F32 LINE_PADDING = 3.f;			// aka "leading"
 const F32 BUFFER_SIZE = 2.f;
 const S32 NUM_OVERLAP_ITERATIONS = 10;
 const F32 POSITION_DAMPING_TC = 0.2f;
@@ -280,6 +277,10 @@ void LLHUDNameTag::renderText(BOOL for_select)
 
 	mOffsetY = lltrunc(mHeight * ((mVertAlignment == ALIGN_VERT_CENTER) ? 0.5f : 1.f));
 
+	static LLCachedControl<F32> name_tag_hpad(gSavedSettings, "NameTagHPad", 16.f);
+	static LLCachedControl<F32> name_tag_vpad(gSavedSettings, "NameTagVPad", 12.f);
+	static LLCachedControl<F32> name_tag_linepad(gSavedSettings, "NameTagLinePad", 3.f); // aka "leading"
+
 	// *TODO: make this a per-text setting
 	static const LLUIColor nametag_bg_color = LLUIColorTable::instance().getColor("NameTagBackground");
 	LLColor4 bg_color = nametag_bg_color;
@@ -315,7 +316,7 @@ void LLHUDNameTag::renderText(BOOL for_select)
 	if (mLabelSegments.size())
 	{
 		LLRect label_top_rect = screen_rect;
-		const S32 label_height = ll_round((mFontp->getLineHeight() * (F32)mLabelSegments.size() + (VERTICAL_PADDING / 3.f)));
+		const S32 label_height = ll_round((mFontp->getLineHeight() * (F32)mLabelSegments.size() + (name_tag_vpad / 3.f)));
 		label_top_rect.mBottom = label_top_rect.mTop - label_height;
 		LLColor4 label_top_color = text_color;
 		label_top_color.mV[VALPHA] = chat_bubble_opacity_cc * alpha_factor;
@@ -341,7 +342,7 @@ void LLHUDNameTag::renderText(BOOL for_select)
 			}
 			else // ALIGN_LEFT
 			{
-				x_offset = -0.5f * mWidth + (HORIZONTAL_PADDING / 2.f);
+				x_offset = -0.5f * mWidth + (name_tag_hpad / 2.f);
 			}
 
 			LLColor4 label_color(0.f, 0.f, 0.f, 1.f);
@@ -370,7 +371,7 @@ void LLHUDNameTag::renderText(BOOL for_select)
 		{
 			const LLFontGL* fontp = segment_iter->mFont;
 			y_offset -= fontp->getLineHeight();
-			y_offset -= LINE_PADDING;
+			y_offset -= name_tag_linepad;
 
 			U8 style = segment_iter->mStyle;
 			LLFontGL::ShadowType shadow = LLFontGL::DROP_SHADOW;
@@ -382,7 +383,7 @@ void LLHUDNameTag::renderText(BOOL for_select)
 			}
 			else // ALIGN_LEFT
 			{
-				x_offset = -0.5f * mWidth + (HORIZONTAL_PADDING / 2.f);
+				x_offset = -0.5f * mWidth + (name_tag_hpad / 2.f);
 
 				// *HACK
 				x_offset += 1;
@@ -689,6 +690,10 @@ LLVector2 LLHUDNameTag::updateScreenPos(LLVector2 &offset)
 
 void LLHUDNameTag::updateSize()
 {
+	static LLCachedControl<F32> name_tag_hpad(gSavedSettings, "NameTagHPad", 16.f);
+	static LLCachedControl<F32> name_tag_vpad(gSavedSettings, "NameTagVPad", 12.f);
+	static LLCachedControl<F32> name_tag_linepad(gSavedSettings, "NameTagLinePad", 3.f); // aka "leading"
+
 	F32 height = 0.f;
 	F32 width = 0.f;
 
@@ -705,7 +710,7 @@ void LLHUDNameTag::updateSize()
 	{
 		const LLFontGL* fontp = iter->mFont;
 		height += fontp->getLineHeight();
-		height += LINE_PADDING;
+		height += name_tag_linepad;
 		width = llmax(width, llmin(iter->getWidth(fontp), NAMETAG_MAX_WIDTH));
 		++iter;
 	}
@@ -713,7 +718,7 @@ void LLHUDNameTag::updateSize()
 	// Don't want line spacing under the last line
 	if (height > 0.f)
 	{
-		height -= LINE_PADDING;
+		height -= name_tag_linepad;
 	}
 
 	iter = mLabelSegments.begin();
@@ -729,8 +734,8 @@ void LLHUDNameTag::updateSize()
 		return;
 	}
 
-	width += HORIZONTAL_PADDING;
-	height += VERTICAL_PADDING;
+	width += name_tag_hpad;
+	height += name_tag_vpad;
 
 	// *TODO: Could do a timer-based resize here
 	//mWidth = llmax(width, lerp(mWidth, (F32)width, u));
-- 
GitLab