- Added support for text colorization in SBarInfo.

SVN r3624 (trunk)
This commit is contained in:
Braden Obrzut 2012-05-05 23:01:16 +00:00
parent af43ef8983
commit 432aa7e6bb

View file

@ -1333,7 +1333,7 @@ public:
} }
} }
void DrawString(FFont *font, const char* str, SBarInfoCoordinate x, SBarInfoCoordinate y, int xOffset, int yOffset, int alpha, bool fullScreenOffsets, EColorRange translation, int spacing=0, bool drawshadow=false, int shadowX=2, int shadowY=2) const void DrawString(FFont *font, const char* cstring, SBarInfoCoordinate x, SBarInfoCoordinate y, int xOffset, int yOffset, int alpha, bool fullScreenOffsets, EColorRange translation, int spacing=0, bool drawshadow=false, int shadowX=2, int shadowY=2) const
{ {
x += spacing; x += spacing;
double ax = *x; double ax = *x;
@ -1342,6 +1342,10 @@ public:
double xScale = 1.0; double xScale = 1.0;
double yScale = 1.0; double yScale = 1.0;
const BYTE* str = (const BYTE*) cstring;
const EColorRange boldTranslation = EColorRange(translation ? translation - 1 : NumTextColors - 1);
FRemapTable *remap = font->GetColorTranslation(translation);
if(fullScreenOffsets) if(fullScreenOffsets)
{ {
if(hud_scale) if(hud_scale)
@ -1362,6 +1366,14 @@ public:
str++; str++;
continue; continue;
} }
else if(*str == TEXTCOLOR_ESCAPE)
{
EColorRange newColor = V_ParseFontColor(++str, translation, boldTranslation);
if(newColor != CR_UNDEFINED)
remap = font->GetColorTranslation(newColor);
continue;
}
int width; int width;
if(script->spacingCharacter == '\0') //No monospace? if(script->spacingCharacter == '\0') //No monospace?
width = font->GetCharWidth((unsigned char) *str); width = font->GetCharWidth((unsigned char) *str);
@ -1444,7 +1456,7 @@ public:
screen->DrawTexture(character, rx, ry, screen->DrawTexture(character, rx, ry,
DTA_DestWidthF, rw, DTA_DestWidthF, rw,
DTA_DestHeightF, rh, DTA_DestHeightF, rh,
DTA_Translation, font->GetColorTranslation(translation), DTA_Translation, remap,
DTA_Alpha, alpha, DTA_Alpha, alpha,
TAG_DONE); TAG_DONE);
if(script->spacingCharacter == '\0') if(script->spacingCharacter == '\0')