* * rct2: 0x006EBC41 */
| 354 | * rct2: 0x006EBC41 |
| 355 | */ |
| 356 | static void WidgetTextCentred(RenderTarget& rt, WindowBase& w, WidgetIndex widgetIndex) |
| 357 | { |
| 358 | // Get the widget |
| 359 | const auto& widget = w.widgets[widgetIndex]; |
| 360 | |
| 361 | if (widget.text == kStringIdNone) |
| 362 | return; |
| 363 | |
| 364 | auto colour = w.colours[widget.colour]; |
| 365 | colour.flags.set(ColourFlag::translucent, false); |
| 366 | if (widgetIsDisabled(w, widgetIndex)) |
| 367 | colour.flags.set(ColourFlag::inset, true); |
| 368 | |
| 369 | // Resolve the absolute ltrb |
| 370 | auto topLeft = w.windowPos + ScreenCoordsXY{ widget.left, 0 }; |
| 371 | int32_t r = w.windowPos.x + widget.right; |
| 372 | |
| 373 | if (widget.type == WidgetType::button || widget.type == WidgetType::tableHeader) |
| 374 | { |
| 375 | // Optical alignment for dropdown glyph |
| 376 | if (widget.text == STR_DROPDOWN_GLYPH) |
| 377 | topLeft.y += widget.top + (widget.height() / 2) - 5; |
| 378 | else |
| 379 | topLeft.y += widget.textTop(); |
| 380 | } |
| 381 | else |
| 382 | { |
| 383 | topLeft.y += widget.top; |
| 384 | } |
| 385 | |
| 386 | auto stringId = widget.text; |
| 387 | auto ft = Formatter(); |
| 388 | if (widget.flags.has(WidgetFlag::textIsString)) |
| 389 | { |
| 390 | stringId = STR_STRING; |
| 391 | ft.Add<utf8*>(widget.string); |
| 392 | } |
| 393 | |
| 394 | ScreenCoordsXY coords = { (topLeft.x + r + 1) / 2 - 1, topLeft.y }; |
| 395 | if (widget.type == WidgetType::labelCentred) |
| 396 | { |
| 397 | drawTextWrapped(rt, coords, widget.width() - 3, stringId, ft, { colour, TextAlignment::centre }); |
| 398 | } |
| 399 | else |
| 400 | { |
| 401 | drawTextEllipsised(rt, coords, widget.width() - 3, stringId, ft, { colour, TextAlignment::centre }); |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | /** |
| 406 | * |
no test coverage detected