SVN r446 (trunk)

This commit is contained in:
Randy Heit 2007-01-09 04:40:58 +00:00
commit 82ba0fb189
11 changed files with 298 additions and 107 deletions

View file

@ -55,6 +55,8 @@
// MACROS ------------------------------------------------------------------
#define DEFAULT_LOG_COLOR PalEntry(223,223,223)
// TYPES -------------------------------------------------------------------
// This structure is used by BuildTranslations() to hold color information.
@ -121,6 +123,7 @@ struct TempColorInfo
{
FName Name;
unsigned int ParmInfo;
PalEntry LogColor;
};
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
@ -162,6 +165,7 @@ static const BYTE myislower[256] =
static TArray<TranslationParm> TranslationParms[2];
static TArray<TranslationMap> TranslationLookup;
static TArray<PalEntry> TranslationColors;
// CODE --------------------------------------------------------------------
@ -1598,6 +1602,7 @@ void V_InitFontColors ()
int c, parmchoice;
TempParmInfo info;
TempColorInfo cinfo;
PalEntry logcolor;
unsigned int i, j;
int k, index;
@ -1610,6 +1615,8 @@ void V_InitFontColors ()
{
names.Clear();
logcolor = DEFAULT_LOG_COLOR;
// Everything until the '{' is considered a valid name for the
// color range.
names.Push (sc_String);
@ -1641,6 +1648,11 @@ void V_InitFontColors ()
info.ParmLen[0] = info.StartParm[1] - info.StartParm[0];
tparm.RangeEnd = tparm.RangeStart = -1;
}
else if (SC_Compare ("Flat:"))
{
SC_MustGetString();
logcolor = V_GetColor (NULL, sc_String);
}
else
{
// Get first color
@ -1731,12 +1743,14 @@ void V_InitFontColors ()
if (colorinfo[j].Name == names[i])
{
colorinfo[j].ParmInfo = cinfo.ParmInfo;
colorinfo[j].LogColor = logcolor;
break;
}
}
if (j == colorinfo.Size())
{
cinfo.Name = names[i];
cinfo.LogColor = logcolor;
colorinfo.Push (cinfo);
}
}
@ -1761,6 +1775,7 @@ void V_InitFontColors ()
TranslationParms[k].Push (parms[pinfo->StartParm[k] + j]);
}
}
TranslationColors.Push (colorinfo[i].LogColor);
pinfo->Index = index++;
}
tmap.Number = pinfo->Index;
@ -1820,6 +1835,77 @@ EColorRange V_FindFontColor (FName name)
return CR_UNTRANSLATED;
}
//==========================================================================
//
// V_LogColorFromColorRange
//
// Returns the color to use for text in the startup/error log window.
//
//==========================================================================
PalEntry V_LogColorFromColorRange (EColorRange range)
{
if (range < 0 || range >= TranslationColors.Size())
{ // Return default color
return DEFAULT_LOG_COLOR;
}
return TranslationColors[range];
}
//==========================================================================
//
// V_ParseFontColor
//
// Given a pointer to a color identifier (presumably just after a color
// escape character), return the color it identifies and advances
// color_value to just past it.
//
//==========================================================================
EColorRange V_ParseFontColor (const BYTE *&color_value, int normalcolor, int boldcolor)
{
const BYTE *ch = color_value;
int newcolor = *ch++;
if (newcolor == '-') // Normal
{
newcolor = normalcolor;
}
else if (newcolor == '+') // Bold
{
newcolor = boldcolor;
}
else if (newcolor == '[') // Named
{
const BYTE *namestart = ch;
while (*ch != ']' && *ch != '\0')
{
ch++;
}
FName rangename((const char *)namestart, int(ch - namestart), true);
if (*ch != '\0')
{
ch++;
}
newcolor = V_FindFontColor (rangename);
}
else if (newcolor >= 'A' && newcolor < NUM_TEXT_COLORS + 'A') // Standard, uppercase
{
newcolor -= 'A';
}
else if (newcolor >= 'a' && newcolor < NUM_TEXT_COLORS + 'a') // Standard, lowercase
{
newcolor -= 'a';
}
else // Incomplete!
{
color_value = ch - (*ch == '\0');
return CR_UNDEFINED;
}
color_value = ch;
return EColorRange(newcolor);
}
//==========================================================================
//
// V_InitFonts