1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-18 01:42:38 +01:00

Codechange: Remove initial colour from layouter cache. (#12728)

Initial colour is now always TC_INVALID, which is substituted with the desired colour when drawing the layout line.

This allows strings which differ only by initial colour to use the same layout cache entry, increasing the efficacy of the cache.
This commit is contained in:
Peter Nelson
2024-05-28 19:33:44 +01:00
committed by GitHub
parent 605dff4920
commit 3d4b98845a
4 changed files with 16 additions and 15 deletions

View File

@@ -331,7 +331,7 @@ void TextfileWindow::CheckHyperlinkClick(Point pt)
/* Build line layout to figure out character position that was clicked. */
uint window_width = IsWidgetLowered(WID_TF_WRAPTEXT) ? this->GetWidget<NWidgetCore>(WID_TF_BACKGROUND)->current_x - WidgetDimensions::scaled.frametext.Horizontal() : INT_MAX;
Layouter layout(this->lines[line_index].text, window_width, this->lines[line_index].colour, FS_MONO);
Layouter layout(this->lines[line_index].text, window_width, FS_MONO);
assert(subline < layout.size());
ptrdiff_t char_index = layout.GetCharAtPosition(pt.x - WidgetDimensions::scaled.frametext.left, subline);
if (char_index < 0) return;