mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 23:01:50 +00:00
- 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:
parent
139f501ec5
commit
ccf46281df
1 changed files with 28 additions and 6 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue