Skip to content

Commit

Permalink
Engine: in create_textual_image() moved text color set out of a loop
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-mogilko committed Jan 11, 2025
1 parent 478eabc commit 2df3cb9
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions Engine/ac/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,24 +261,32 @@ Bitmap *create_textual_image(const char *text, DisplayTextStyle style, color_t t
&ttxleft, &ttxtop, &adjustedXX, &adjustedYY, &wii, &text_color, 0, usingGui);
}

for (size_t ee = 0; ee<Lines.Count(); ee++)
// Assign final text color, either use passed parameter, or TextWindow property
if (style == kDisplayTextStyle_TextWindow)
{
int ttyp = ttxtop + ee * disp.Linespacing;
if ((usingGui >= 0) &&
((game.options[OPT_SPEECHTYPE] >= 2) || (isThought)))
text_color = text_window_ds->GetCompatibleColor(guis[usingGui].FgColor);
else
text_color = text_window_ds->GetCompatibleColor(text_color);
}
else
{
text_color = text_window_ds->GetCompatibleColor(text_color);
}

// Print the lines of text
for (size_t i = 0; i < Lines.Count(); ++i)
{
int ttyp = ttxtop + i * disp.Linespacing;
// if it's inside a text box then don't centre the text
if (style == kDisplayTextStyle_TextWindow)
{
if ((usingGui >= 0) &&
((game.options[OPT_SPEECHTYPE] >= 2) || (isThought)))
text_color = text_window_ds->GetCompatibleColor(guis[usingGui].FgColor);
else
text_color = text_window_ds->GetCompatibleColor(text_color);

wouttext_aligned(text_window_ds, ttxleft, ttyp, oriwid, usingfont, text_color, Lines[ee].GetCStr(), play.text_align);
wouttext_aligned(text_window_ds, ttxleft, ttyp, oriwid, usingfont, text_color, Lines[i].GetCStr(), play.text_align);
}
else
{
text_color = text_window_ds->GetCompatibleColor(text_color);
wouttext_aligned(text_window_ds, ttxleft, ttyp, wii, usingfont, text_color, Lines[ee].GetCStr(), play.speech_text_align);
wouttext_aligned(text_window_ds, ttxleft, ttyp, wii, usingfont, text_color, Lines[i].GetCStr(), play.speech_text_align);
}
}
}
Expand All @@ -291,8 +299,8 @@ Bitmap *create_textual_image(const char *text, DisplayTextStyle style, color_t t

adjust_y_coordinate_for_text(&yoffs, usingfont);

for (size_t ee = 0; ee<Lines.Count(); ee++)
wouttext_aligned(text_window_ds, xoffs, yoffs + ee * disp.Linespacing, oriwid, usingfont, text_color, Lines[ee].GetCStr(), play.text_align);
for (size_t i = 0; i < Lines.Count(); ++i)
wouttext_aligned(text_window_ds, xoffs, yoffs + i * disp.Linespacing, oriwid, usingfont, text_color, Lines[i].GetCStr(), play.text_align);
}
return text_window_ds;
}
Expand Down

0 comments on commit 2df3cb9

Please sign in to comment.