From 2de3e96dfb1f87885262bd89cb35ef70ce5a9325 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Fri, 11 Apr 2025 16:22:08 +0200 Subject: [PATCH] Let checkbox widgets respect widget width for their labels --- distribution/changelog.txt | 1 + src/openrct2-ui/interface/Widget.cpp | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 97a6c69717..5fdc9b0ca5 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -7,6 +7,7 @@ - Fix: [#21919] Non-recolourable cars still show colour picker. - Fix: [#23108] Missing pieces on Hypercoaster and Hyper-Twister, even with the ‘all drawable track pieces’ cheat enabled. - Fix: [#24013] Failure to load a scenario preview image (minimap) could lead to an uncaught exception error message. +- Fix: [#24121] Checkbox labels run beyond the edge of the window if they’re too long to fit. - Fix: [#24142] [Plugin] Track origin is miscalculated on downward slopes. - Fix: [#24220] Narrow station platforms have missing sides on certain rotations. diff --git a/src/openrct2-ui/interface/Widget.cpp b/src/openrct2-ui/interface/Widget.cpp index bdc0442523..d3523eda5a 100644 --- a/src/openrct2-ui/interface/Widget.cpp +++ b/src/openrct2-ui/interface/Widget.cpp @@ -653,8 +653,16 @@ namespace OpenRCT2::Ui if (widget.text == kStringIdNone) return; - auto [stringId, formatArgs] = WidgetGetStringidAndArgs(widget); - GfxDrawStringLeftCentred(dpi, stringId, formatArgs, colour, { midLeft + ScreenCoordsXY{ 14, 0 } }); + auto stringId = widget.text; + auto ft = Formatter::Common(); + if (widget.flags & WIDGET_FLAGS::TEXT_IS_STRING) + { + stringId = STR_STRING; + ft.Add(widget.string); + } + + DrawTextEllipsised( + dpi, w.windowPos + ScreenCoordsXY{ widget.left + 14, widget.textTop() }, widget.width() - 14, stringId, ft, colour); } /**