summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2023-01-10 22:06:39 +0200
committerAndrey Kleshchev <andreykproductengine@lindenlab.com>2023-01-10 22:09:47 +0200
commita66ea0a9089f9525a9e92ae3e7ebed412ffd53e1 (patch)
tree9e36e28a0c41b4dafd62764c5eb2f9606b3317c2
parent7196c8c2edeeb01ef4ffb839f7731a99df888bd1 (diff)
SL-12437 Long avatar names should stay as one string
-rw-r--r--indra/newview/llhudnametag.cpp18
-rw-r--r--indra/newview/llhudnametag.h13
-rw-r--r--indra/newview/llvoavatar.cpp5
3 files changed, 25 insertions, 11 deletions
diff --git a/indra/newview/llhudnametag.cpp b/indra/newview/llhudnametag.cpp
index 952fbf8e4b..ab6a64157c 100644
--- a/indra/newview/llhudnametag.cpp
+++ b/indra/newview/llhudnametag.cpp
@@ -56,7 +56,6 @@ 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 F32 HUD_TEXT_MAX_WIDTH = 190.f;
const S32 NUM_OVERLAP_ITERATIONS = 10;
const F32 POSITION_DAMPING_TC = 0.2f;
const F32 MAX_STABLE_CAMERA_VELOCITY = 0.1f;
@@ -67,6 +66,8 @@ const F32 LOD_2_SCREEN_COVERAGE = 0.40f;
std::set<LLPointer<LLHUDNameTag> > LLHUDNameTag::sTextObjects;
std::vector<LLPointer<LLHUDNameTag> > LLHUDNameTag::sVisibleTextObjects;
BOOL LLHUDNameTag::sDisplayText = TRUE ;
+const F32 LLHUDNameTag::NAMETAG_MAX_WIDTH = 298.f;
+const F32 LLHUDNameTag::HUD_TEXT_MAX_WIDTH = 190.f;
bool llhudnametag_further_away::operator()(const LLPointer<LLHUDNameTag>& lhs, const LLPointer<LLHUDNameTag>& rhs) const
{
@@ -414,7 +415,8 @@ void LLHUDNameTag::addLine(const std::string &text_utf8,
const LLColor4& color,
const LLFontGL::StyleFlags style,
const LLFontGL* font,
- const bool use_ellipses)
+ const bool use_ellipses,
+ F32 max_pixels)
{
LLWString wline = utf8str_to_wstring(text_utf8);
if (!wline.empty())
@@ -431,7 +433,7 @@ void LLHUDNameTag::addLine(const std::string &text_utf8,
tokenizer tokens(wline, sep);
tokenizer::iterator iter = tokens.begin();
- const F32 max_pixels = HUD_TEXT_MAX_WIDTH;
+ max_pixels = llmin(max_pixels, NAMETAG_MAX_WIDTH);
while (iter != tokens.end())
{
U32 line_length = 0;
@@ -488,7 +490,7 @@ void LLHUDNameTag::setLabel(const std::string &label_utf8)
addLabel(label_utf8);
}
-void LLHUDNameTag::addLabel(const std::string& label_utf8)
+void LLHUDNameTag::addLabel(const std::string& label_utf8, F32 max_pixels)
{
LLWString wstr = utf8string_to_wstring(label_utf8);
if (!wstr.empty())
@@ -502,13 +504,15 @@ void LLHUDNameTag::addLabel(const std::string& label_utf8)
tokenizer tokens(wstr, sep);
tokenizer::iterator iter = tokens.begin();
+ max_pixels = llmin(max_pixels, NAMETAG_MAX_WIDTH);
+
while (iter != tokens.end())
{
U32 line_length = 0;
do
{
S32 segment_length = mFontp->maxDrawableChars(iter->substr(line_length).c_str(),
- HUD_TEXT_MAX_WIDTH, wstr.length(), LLFontGL::WORD_BOUNDARY_IF_POSSIBLE);
+ max_pixels, wstr.length(), LLFontGL::WORD_BOUNDARY_IF_POSSIBLE);
LLHUDTextSegment segment(iter->substr(line_length, segment_length), LLFontGL::NORMAL, mColor, mFontp);
mLabelSegments.push_back(segment);
line_length += segment_length;
@@ -695,7 +699,7 @@ void LLHUDNameTag::updateSize()
const LLFontGL* fontp = iter->mFont;
height += fontp->getLineHeight();
height += LINE_PADDING;
- width = llmax(width, llmin(iter->getWidth(fontp), HUD_TEXT_MAX_WIDTH));
+ width = llmax(width, llmin(iter->getWidth(fontp), NAMETAG_MAX_WIDTH));
++iter;
}
@@ -709,7 +713,7 @@ void LLHUDNameTag::updateSize()
while (iter != mLabelSegments.end())
{
height += mFontp->getLineHeight();
- width = llmax(width, llmin(iter->getWidth(mFontp), HUD_TEXT_MAX_WIDTH));
+ width = llmax(width, llmin(iter->getWidth(mFontp), NAMETAG_MAX_WIDTH));
++iter;
}
diff --git a/indra/newview/llhudnametag.h b/indra/newview/llhudnametag.h
index 7577dd5de6..361e4d4f4b 100644
--- a/indra/newview/llhudnametag.h
+++ b/indra/newview/llhudnametag.h
@@ -85,6 +85,9 @@ public:
ALIGN_VERT_CENTER
} EVertAlignment;
+ static const F32 NAMETAG_MAX_WIDTH; // 298px, made to fit 31 M's
+ static const F32 HUD_TEXT_MAX_WIDTH; // 190px
+
public:
// Set entire string, eliminating existing lines
void setString(const std::string& text_utf8);
@@ -92,11 +95,17 @@ public:
void clearString();
// Add text a line at a time, allowing custom formatting
- void addLine(const std::string &text_utf8, const LLColor4& color, const LLFontGL::StyleFlags style = LLFontGL::NORMAL, const LLFontGL* font = NULL, const bool use_ellipses = false);
+ void addLine(
+ const std::string &text_utf8,
+ const LLColor4& color,
+ const LLFontGL::StyleFlags style = LLFontGL::NORMAL,
+ const LLFontGL* font = NULL,
+ const bool use_ellipses = false,
+ F32 max_pixels = HUD_TEXT_MAX_WIDTH);
// For bubble chat, set the part above the chat text
void setLabel(const std::string& label_utf8);
- void addLabel(const std::string& label_utf8);
+ void addLabel(const std::string& label_utf8, F32 max_pixels = HUD_TEXT_MAX_WIDTH);
// Sets the default font for lines with no font specified
void setFont(const LLFontGL* font);
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 42550ed48d..0dd4ce78ab 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -3528,14 +3528,15 @@ void LLVOAvatar::idleUpdateNameTagText(bool new_name)
void LLVOAvatar::addNameTagLine(const std::string& line, const LLColor4& color, S32 style, const LLFontGL* font, const bool use_ellipses)
{
+ // extra width (NAMETAG_MAX_WIDTH) is for names only, not for chat
llassert(mNameText);
if (mVisibleChat)
{
- mNameText->addLabel(line);
+ mNameText->addLabel(line, LLHUDNameTag::NAMETAG_MAX_WIDTH);
}
else
{
- mNameText->addLine(line, color, (LLFontGL::StyleFlags)style, font, use_ellipses);
+ mNameText->addLine(line, color, (LLFontGL::StyleFlags)style, font, use_ellipses, LLHUDNameTag::NAMETAG_MAX_WIDTH);
}
mNameIsSet |= !line.empty();
}