Added optional classic console draw mode (renders the background as single block instead of separate blocks for each paragraph)

master
Ansariel 2012-01-08 01:40:34 +01:00
parent 60512bd2ae
commit 585c3ced7b
5 changed files with 145 additions and 42 deletions

View File

@ -202,56 +202,124 @@ void LLConsole::draw()
color.mV[VALPHA] *= console_opacity;
F32 line_height = mFont->getLineHeight();
BOOL classic_draw_mode = LLUI::sSettingGroups["config"]->getBOOL("FSConsoleClassicDrawMode");
for(paragraph_it = mParagraphs.rbegin(); paragraph_it != mParagraphs.rend(); paragraph_it++)
// Ansariel: Classic draw mode for console (Single block over all lines and with width of the longest line)
if (classic_draw_mode)
{
S32 target_height = llfloor( (*paragraph_it).mLines.size() * line_height + padding_vertical);
S32 target_width = llfloor( (*paragraph_it).mMaxWidth + padding_horizontal);
static const F32 padding_vert = 5;
S32 total_width = 0;
S32 total_height = 0;
F32 y_pos_paragraph = y_pos;
y_pos += ((*paragraph_it).mLines.size()) * line_height;
imagep->drawSolid(-14, (S32)(y_pos + line_height - target_height), target_width, target_height, color);
F32 y_off=0;
F32 alpha;
if ((mLinePersistTime > 0.f) && ((*paragraph_it).mAddTime < fade_time))
for (paragraph_it = mParagraphs.rbegin(); paragraph_it != mParagraphs.rend(); paragraph_it++)
{
alpha = ((*paragraph_it).mAddTime - skip_time)/(mLinePersistTime - mFadeTime);
}
else
{
alpha = 1.0f;
total_height += llfloor( (*paragraph_it).mLines.size() * line_height + padding_vert);
S32 target_width = llfloor( (*paragraph_it).mMaxWidth + padding_horizontal);
total_width = llmax(total_width, target_width);
y_pos_paragraph += ((*paragraph_it).mLines.size()) * line_height + padding_vert;
}
imagep->drawSolid(-14, (S32)(y_pos + line_height / 2), total_width, total_height + (line_height - padding_vert) / 2, color);
if( alpha > 0.f )
for (paragraph_it = mParagraphs.rbegin(); paragraph_it != mParagraphs.rend(); paragraph_it++)
{
for (lines_t::iterator line_it=(*paragraph_it).mLines.begin();
line_it != (*paragraph_it).mLines.end();
line_it ++)
F32 y_off=0;
F32 alpha;
S32 target_width = llfloor( (*paragraph_it).mMaxWidth + padding_horizontal);
y_pos += ((*paragraph_it).mLines.size()) * line_height;
if ((mLinePersistTime > 0.f) && ((*paragraph_it).mAddTime < fade_time))
{
for (line_color_segments_t::iterator seg_it = (*line_it).mLineColorSegments.begin();
seg_it != (*line_it).mLineColorSegments.end();
seg_it++)
{
mFont->render((*seg_it).mText, 0, (*seg_it).mXPosition - 8, y_pos - y_off,
LLColor4(
(*seg_it).mColor.mV[VRED],
(*seg_it).mColor.mV[VGREEN],
(*seg_it).mColor.mV[VBLUE],
(*seg_it).mColor.mV[VALPHA]*alpha),
LLFontGL::LEFT,
LLFontGL::BASELINE,
(*line_it).mStyleFlags, // Ansariel: Custom style flags for the font
LLFontGL::DROP_SHADOW,
S32_MAX,
target_width
);
}
y_off += line_height;
alpha = ((*paragraph_it).mAddTime - skip_time)/(mLinePersistTime - mFadeTime);
}
else
{
alpha = 1.0f;
}
if( alpha > 0.f )
{
for (lines_t::iterator line_it=(*paragraph_it).mLines.begin();
line_it != (*paragraph_it).mLines.end();
line_it ++)
{
for (line_color_segments_t::iterator seg_it = (*line_it).mLineColorSegments.begin();
seg_it != (*line_it).mLineColorSegments.end();
seg_it++)
{
mFont->render((*seg_it).mText, 0, (*seg_it).mXPosition - 8, y_pos - y_off,
LLColor4(
(*seg_it).mColor.mV[VRED],
(*seg_it).mColor.mV[VGREEN],
(*seg_it).mColor.mV[VBLUE],
(*seg_it).mColor.mV[VALPHA]*alpha),
LLFontGL::LEFT,
LLFontGL::BASELINE,
(*line_it).mStyleFlags, // Ansariel: Custom style flags for the font
LLFontGL::DROP_SHADOW,
S32_MAX,
target_width
);
}
y_off += line_height;
}
}
y_pos += padding_vert;
}
}
else
{
for(paragraph_it = mParagraphs.rbegin(); paragraph_it != mParagraphs.rend(); paragraph_it++)
{
S32 target_height = llfloor( (*paragraph_it).mLines.size() * line_height + padding_vertical);
S32 target_width = llfloor( (*paragraph_it).mMaxWidth + padding_horizontal);
y_pos += ((*paragraph_it).mLines.size()) * line_height;
imagep->drawSolid(-14, (S32)(y_pos + line_height - target_height), target_width, target_height, color);
F32 y_off=0;
F32 alpha;
if ((mLinePersistTime > 0.f) && ((*paragraph_it).mAddTime < fade_time))
{
alpha = ((*paragraph_it).mAddTime - skip_time)/(mLinePersistTime - mFadeTime);
}
else
{
alpha = 1.0f;
}
if( alpha > 0.f )
{
for (lines_t::iterator line_it=(*paragraph_it).mLines.begin();
line_it != (*paragraph_it).mLines.end();
line_it ++)
{
for (line_color_segments_t::iterator seg_it = (*line_it).mLineColorSegments.begin();
seg_it != (*line_it).mLineColorSegments.end();
seg_it++)
{
mFont->render((*seg_it).mText, 0, (*seg_it).mXPosition - 8, y_pos - y_off,
LLColor4(
(*seg_it).mColor.mV[VRED],
(*seg_it).mColor.mV[VGREEN],
(*seg_it).mColor.mV[VBLUE],
(*seg_it).mColor.mV[VALPHA]*alpha),
LLFontGL::LEFT,
LLFontGL::BASELINE,
(*line_it).mStyleFlags, // Ansariel: Custom style flags for the font
LLFontGL::DROP_SHADOW,
S32_MAX,
target_width
);
}
y_off += line_height;
}
}
y_pos += padding_vertical;
}
y_pos += padding_vertical;
}
}

View File

@ -16946,5 +16946,16 @@ Change of this parameter will affect the layout of buttons in notification toast
<key>Value</key>
<integer>1</integer>
</map>
<key>FSConsoleClassicDrawMode</key>
<map>
<key>Comment</key>
<string>Enables classic console draw mode (single background block over all lines with width of the longest line)</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>0</integer>
</map>
</map>
</llsd>

View File

@ -250,5 +250,17 @@
<key>Value</key>
<integer>1</integer>
</map>
<key>FSConsoleClassicDrawMode</key>
<map>
<key>Comment</key>
<string>Enables classic console draw mode (single background block over all lines with width of the longest line)</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>1</integer>
</map>
</map>
</llsd>

View File

@ -128,6 +128,7 @@
<text name="console_enhancements">
Konsole:
</text>
<check_box name="FSConsoleClassicDrawMode" label="Klassischen Anzeigemodus für Konsole verwenden" tool_tip="Im klassischen Anzeigemodus wird der Hintergrund der Konsole als einzelner Block über alle Zeilen und mit der Breite der längsten Zeile dargestellt."/>
<check_box name="ChatFullWidth" label="Bildschirmbreite für Konsole verwenden" width="240"/>
<text name="requires_restart_label2">
(Erfordert Neustart)

View File

@ -493,7 +493,7 @@
label="Auto-close ((OOC)) parentheses"
layout="topleft"
top_pad="0"
left="30"
left="30"
height="18"
width="400" />
@ -501,7 +501,7 @@
<check_box
layout="topleft"
follows="left|top"
top_pad="5"
top_pad="0"
left="30"
width="250"
height="18"
@ -666,6 +666,17 @@
width="400">
Console:
</text>
<check_box
layout="topleft"
follows="left|top"
top_pad="0"
left="30"
width="200"
height="18"
name="FSConsoleClassicDrawMode"
control_name="FSConsoleClassicDrawMode"
label="Use classic draw mode for console"
tool_tip="Classic draw mode renders the console background as single block over all lines with width of the longest line."/>
<check_box
layout="topleft"
follows="left|top"