1
0
Fork 0

Compare commits

...

3 Commits

Author SHA1 Message Date
Peter Nelson 240c0f48c3
Merge 81d7d86091 into 03672ed8eb 2025-07-18 11:04:57 +00:00
Jonathan G Rennison 03672ed8eb
Fix: EngineImageType mismatch between sizing and drawing in preview window (#14455) 2025-07-18 07:02:46 -04:00
Peter Nelson 81d7d86091
Fix f6e78a480d: Truncation ellipsis always drawn in black.
Truncation ellipsis is now a layouted line, so we can no longer rely on implicitly using the last set colour.
2025-07-15 22:27:52 +01:00
2 changed files with 12 additions and 6 deletions

View File

@ -84,7 +84,7 @@ struct EnginePreviewWindow : Window {
/* Get size of engine sprite, on loan from depot_gui.cpp */
EngineID engine = static_cast<EngineID>(this->window_number);
EngineImageType image_type = EIT_PURCHASE;
EngineImageType image_type = EIT_PREVIEW;
uint x, y;
int x_offs, y_offs;

View File

@ -579,7 +579,7 @@ static int DrawLayoutLine(const ParagraphLayouter::Line &line, int y, int left,
const uint shadow_offset = ScaleGUITrad(1);
auto draw_line = [&](const ParagraphLayouter::Line &line, bool do_shadow, int left, int min_x, int max_x, bool truncation) {
auto draw_line = [&](const ParagraphLayouter::Line &line, bool do_shadow, int left, int min_x, int max_x, bool truncation, TextColour &last_colour) {
const DrawPixelInfo *dpi = _cur_dpi;
int dpi_left = dpi->left;
int dpi_right = dpi->left + dpi->width - 1;
@ -592,10 +592,15 @@ static int DrawLayoutLine(const ParagraphLayouter::Line &line, int y, int left,
FontCache *fc = f->fc;
TextColour colour = f->colour;
if (colour == TC_INVALID || HasFlag(default_colour, TC_FORCED)) colour = default_colour;
if (colour == TC_INVALID || HasFlag(last_colour, TC_FORCED)) {
colour = last_colour;
} else {
/* Update the last colour for the truncation ellipsis. */
last_colour = colour;
}
bool colour_has_shadow = (colour & TC_NO_SHADE) == 0 && colour != TC_BLACK;
SetColourRemap(do_shadow ? TC_BLACK : colour); // the last run also sets the colour for the truncation dots
if (do_shadow && (!fc->GetDrawGlyphShadow() || !colour_has_shadow)) continue;
SetColourRemap(do_shadow ? TC_BLACK : colour);
for (int i = 0; i < run.GetGlyphCount(); i++) {
GlyphID glyph = glyphs[i];
@ -623,11 +628,12 @@ static int DrawLayoutLine(const ParagraphLayouter::Line &line, int y, int left,
/* Draw shadow, then foreground */
for (bool do_shadow : {true, false}) {
draw_line(line, do_shadow, left - offset_x, min_x, max_x, truncation);
TextColour last_colour = default_colour;
draw_line(line, do_shadow, left - offset_x, min_x, max_x, truncation, last_colour);
if (truncation) {
int x = (_current_text_dir == TD_RTL) ? left : (right - truncation_width);
draw_line(*truncation_layout->front(), do_shadow, x, INT32_MIN, INT32_MAX, false);
draw_line(*truncation_layout->front(), do_shadow, x, INT32_MIN, INT32_MAX, false, last_colour);
}
}