mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-13 07:57:52 +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 == '[')
|
if (*string == '[')
|
||||||
{
|
{
|
||||||
const uint8_t *start = string;
|
const uint8_t* start = string;
|
||||||
while (*string != ']' && *string != '\0')
|
while (*string != ']' && *string != '\0')
|
||||||
{
|
{
|
||||||
string++;
|
string++;
|
||||||
|
@ -97,11 +97,6 @@ TArray<FBrokenLines> V_BreakLines (FFont *font, int maxwidth, const uint8_t *str
|
||||||
{
|
{
|
||||||
string++;
|
string++;
|
||||||
}
|
}
|
||||||
lastcolor = FString((const char *)start, string - start);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lastcolor = *string++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -130,6 +125,33 @@ TArray<FBrokenLines> V_BreakLines (FFont *font, int maxwidth, const uint8_t *str
|
||||||
}
|
}
|
||||||
|
|
||||||
auto index = Lines.Reserve(1);
|
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);
|
breakit (&Lines[index], font, start, space, linecolor);
|
||||||
if (c == '\n' && !preservecolor)
|
if (c == '\n' && !preservecolor)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue