Display Name work

This commit is contained in:
Siana Gearz
2010-12-12 21:58:19 +01:00
parent a8ce4df93c
commit 9983d0b803
29 changed files with 525 additions and 134 deletions

View File

@@ -65,6 +65,7 @@ const F32 SPRING_STRENGTH = 0.7f;
const F32 RESTORATION_SPRING_TIME_CONSTANT = 0.1f;
const F32 HORIZONTAL_PADDING = 15.f;
const F32 VERTICAL_PADDING = 12.f;
const F32 LINE_PADDING = 3.f; // aka "leading"
const F32 BUFFER_SIZE = 2.f;
const F32 MIN_EDGE_OVERLAP = 3.f;
F32 HUD_TEXT_MAX_WIDTH = 190.f;
@@ -499,7 +500,7 @@ void LLHUDText::renderText(BOOL for_select)
for(std::vector<LLHUDTextSegment>::iterator segment_iter = mLabelSegments.begin();
segment_iter != mLabelSegments.end(); ++segment_iter )
{
const LLFontGL* fontp = (segment_iter->mStyle == LLFontGL::BOLD) ? mBoldFontp : mFontp;
const LLFontGL* fontp = segment_iter->mFont;
y_offset -= fontp->getLineHeight();
F32 x_offset;
@@ -610,13 +611,13 @@ void LLHUDText::clearString()
}
void LLHUDText::addLine(const std::string &str, const LLColor4& color, const LLFontGL::StyleFlags style)
void LLHUDText::addLine(const std::string &str, const LLColor4& color, const LLFontGL::StyleFlags style, const LLFontGL* font)
{
addLine(utf8str_to_wstring(str), color, style);
addLine(utf8str_to_wstring(str), color, style, font);
}
void LLHUDText::addLine(const LLWString &wstr, const LLColor4& color, const LLFontGL::StyleFlags style)
void LLHUDText::addLine(const LLWString &wstr, const LLColor4& color, const LLFontGL::StyleFlags style, const LLFontGL* font)
{
if (gNoRender)
{
@@ -624,6 +625,10 @@ void LLHUDText::addLine(const LLWString &wstr, const LLColor4& color, const LLFo
}
if (!wstr.empty())
{
if (!font)
{
font = mFontp;
}
LLWString wline(wstr);
typedef boost::tokenizer<boost::char_separator<llwchar>, LLWString::const_iterator, LLWString > tokenizer;
LLWString seps(utf8str_to_wstring("\r\n"));
@@ -638,7 +643,7 @@ void LLHUDText::addLine(const LLWString &wstr, const LLColor4& color, const LLFo
do
{
S32 segment_length = mFontp->maxDrawableChars(iter->substr(line_length).c_str(), mUseBubble ? HUD_TEXT_MAX_WIDTH : HUD_TEXT_MAX_WIDTH_NO_BUBBLE, wline.length(), TRUE);
mTextSegments.push_back(LLHUDTextSegment(iter->substr(line_length, segment_length), style, color));
mTextSegments.push_back(LLHUDTextSegment(iter->substr(line_length, segment_length), style, color, font));
line_length += segment_length;
}
while (line_length != iter->size());
@@ -652,9 +657,15 @@ void LLHUDText::setLabel(const std::string &label)
setLabel(utf8str_to_wstring(label));
}
void LLHUDText::setLabel(const LLWString &wlabel)
{
mLabelSegments.clear();
addLabel(wlabel);
}
void LLHUDText::addLabel(const LLWString &wlabel)
{
if (!wlabel.empty())
{
@@ -674,7 +685,7 @@ void LLHUDText::setLabel(const LLWString &wlabel)
do
{
S32 segment_length = mFontp->maxDrawableChars(iter->substr(line_length).c_str(), mUseBubble ? HUD_TEXT_MAX_WIDTH : HUD_TEXT_MAX_WIDTH_NO_BUBBLE, wstr.length(), TRUE);
mLabelSegments.push_back(LLHUDTextSegment(iter->substr(line_length, segment_length), LLFontGL::NORMAL, mColor));
mLabelSegments.push_back(LLHUDTextSegment(iter->substr(line_length, segment_length), LLFontGL::NORMAL, mColor, mFontp));
line_length += segment_length;
}
while (line_length != iter->size());
@@ -709,6 +720,16 @@ void LLHUDText::setColor(const LLColor4 &color)
}
}
void LLHUDText::setAlpha(F32 alpha)
{
mColor.mV[VALPHA] = alpha;
for (std::vector<LLHUDTextSegment>::iterator segment_iter = mTextSegments.begin();
segment_iter != mTextSegments.end(); ++segment_iter )
{
segment_iter->mColor.mV[VALPHA] = alpha;
}
}
void LLHUDText::setUsePixelSize(const BOOL use_pixel_size)
{
@@ -720,22 +741,23 @@ void LLHUDText::setDoFade(const BOOL do_fade)
mDoFade = do_fade;
}
// <edit>
std::string LLHUDText::getStringUTF8()
{
std::string out("");
int t = mTextSegments.size();
int i = 0;
for (std::vector<LLHUDTextSegment>::iterator segment_iter = mTextSegments.begin();
segment_iter != mTextSegments.end(); ++segment_iter )
{
out.append(wstring_to_utf8str((*segment_iter).getText()));
i++;
if(i < t) out.append("\n");
}
return out;
}
// </edit>
// <edit>
std::string LLHUDText::getStringUTF8()
{
std::string out("");
int t = mTextSegments.size();
int i = 0;
for (std::vector<LLHUDTextSegment>::iterator segment_iter = mTextSegments.begin();
segment_iter != mTextSegments.end(); ++segment_iter )
{
out.append(wstring_to_utf8str((*segment_iter).getText()));
i++;
if(i < t) out.append("\n");
}
return out;
}
// </edit>
void LLHUDText::updateVisibility()
{
if (mSourceObject)
@@ -896,12 +918,10 @@ LLVector2 LLHUDText::updateScreenPos(LLVector2 &offset)
void LLHUDText::updateSize()
{
F32 height = 0.f;
F32 width = 0.f;
S32 max_lines = getMaxLines();
S32 lines = (max_lines < 0) ? (S32)mTextSegments.size() : llmin((S32)mTextSegments.size(), max_lines);
F32 height = (F32)mFontp->getLineHeight() * (lines + mLabelSegments.size());
S32 start_segment;
if (max_lines < 0) start_segment = 0;
@@ -910,13 +930,16 @@ void LLHUDText::updateSize()
std::vector<LLHUDTextSegment>::iterator iter = mTextSegments.begin() + start_segment;
while (iter != mTextSegments.end())
{
width = llmax(width, llmin(iter->getWidth(mFontp), HUD_TEXT_MAX_WIDTH));
const LLFontGL* fontp = iter->mFont;
height += fontp->getLineHeight();
width = llmax(width, llmin(iter->getWidth(fontp), HUD_TEXT_MAX_WIDTH));
++iter;
}
iter = mLabelSegments.begin();
while (iter != mLabelSegments.end())
{
height += mFontp->getLineHeight();
width = llmax(width, llmin(iter->getWidth(mFontp), HUD_TEXT_MAX_WIDTH));
++iter;
}