MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / WidgetText

Function WidgetText

src/openrct2-ui/interface/Widget.cpp:409–451  ·  view source on GitHub ↗

* * rct2: 0x006EBD52 */

Source from the content-addressed store, hash-verified

407 * rct2: 0x006EBD52
408 */
409 static void WidgetText(RenderTarget& rt, WindowBase& w, WidgetIndex widgetIndex)
410 {
411 // Get the widget
412 const auto& widget = w.widgets[widgetIndex];
413
414 if (widget.text == kStringIdNone || widget.content == kWidgetContentEmpty)
415 return;
416
417 auto colour = w.colours[widget.colour];
418 if (widgetIsDisabled(w, widgetIndex))
419 colour.flags.set(ColourFlag::inset, true);
420
421 // Resolve the absolute ltrb
422 int32_t l = w.windowPos.x + widget.left;
423 int32_t r = w.windowPos.x + widget.right;
424 int32_t t;
425
426 if (widget.type == WidgetType::button || widget.type == WidgetType::dropdownMenu || widget.type == WidgetType::spinner
427 || widget.type == WidgetType::tableHeader)
428 {
429 t = w.windowPos.y + widget.textTop();
430 }
431 else
432 t = w.windowPos.y + widget.top;
433
434 auto stringId = widget.text;
435 auto ft = Formatter();
436 if (widget.flags.has(WidgetFlag::textIsString))
437 {
438 stringId = STR_STRING;
439 ft.Add<utf8*>(widget.string);
440 }
441
442 ScreenCoordsXY coords = { l + 1, t };
443 if (widget.type == WidgetType::labelCentred)
444 {
445 drawTextWrapped(rt, coords, r - l, stringId, ft, { colour, TextAlignment::centre });
446 }
447 else
448 {
449 drawTextEllipsised(rt, coords, r - l, stringId, ft, colour);
450 }
451 }
452
453 /**
454 *

Callers 3

widgetDrawFunction · 0.85
WidgetTextButtonFunction · 0.85
WidgetTextInsetFunction · 0.85

Calls 7

widgetIsDisabledFunction · 0.85
drawTextWrappedFunction · 0.85
drawTextEllipsisedFunction · 0.85
textTopMethod · 0.80
FormatterClass · 0.70
setMethod · 0.65
hasMethod · 0.65

Tested by

no test coverage detected