- fixed line color handling in V_BreakLines.

This cannot use the last color found while reading ahead - it must pick the last color of the string part that just got broken out into its own line when starting the next one.
This commit is contained in:
Christoph Oelckers 2021-08-11 16:01:40 +02:00
parent 139f501ec5
commit ccf46281df

View file

@ -88,7 +88,7 @@ TArray<FBrokenLines> V_BreakLines (FFont *font, int maxwidth, const uint8_t *str
{
if (*string == '[')
{
const uint8_t *start = string;
const uint8_t* start = string;
while (*string != ']' && *string != '\0')
{
string++;
@ -97,11 +97,6 @@ TArray<FBrokenLines> V_BreakLines (FFont *font, int maxwidth, const uint8_t *str
{
string++;
}
lastcolor = FString((const char *)start, string - start);
}
else
{
lastcolor = *string++;
}
}
continue;
@ -130,6 +125,33 @@ TArray<FBrokenLines> V_BreakLines (FFont *font, int maxwidth, const uint8_t *str
}
auto index = Lines.Reserve(1);
for (const uint8_t* pos = start; pos < space; pos++)
{
if (*pos == TEXTCOLOR_ESCAPE)
{
pos++;
if (*pos)
{
if (*pos == '[')
{
const uint8_t* cstart = pos;
while (*pos != ']' && *pos != '\0')
{
pos++;
}
if (*pos != '\0')
{
pos++;
}
lastcolor = FString((const char*)cstart, pos - start);
}
else
{
lastcolor = *pos++;
}
}
}
}
breakit (&Lines[index], font, start, space, linecolor);
if (c == '\n' && !preservecolor)
{