* * rct2: 0x006EB2F9 */
| 537 | * rct2: 0x006EB2F9 |
| 538 | */ |
| 539 | static void WidgetCaptionDraw(RenderTarget& rt, WindowBase& w, WidgetIndex widgetIndex) |
| 540 | { |
| 541 | // Get the widget |
| 542 | const auto* widget = &w.widgets[widgetIndex]; |
| 543 | |
| 544 | // Resolve the absolute ltrb |
| 545 | auto topLeft = w.windowPos + ScreenCoordsXY{ widget->left, widget->top }; |
| 546 | auto bottomRight = w.windowPos + ScreenCoordsXY{ widget->right, widget->bottom }; |
| 547 | |
| 548 | auto colour = w.colours[widget->colour]; |
| 549 | |
| 550 | auto brightness = Rectangle::FillBrightness::light; |
| 551 | if (w.flags.has(WindowFlag::higherContrastOnPress)) |
| 552 | brightness = Rectangle::FillBrightness::dark; |
| 553 | |
| 554 | Rectangle::fillInset( |
| 555 | rt, { topLeft, bottomRight }, colour, Rectangle::BorderStyle::inset, brightness, |
| 556 | Rectangle::FillMode::dontLightenWhenInset); |
| 557 | |
| 558 | // Black caption bars look slightly green, this fixes that |
| 559 | if (colour.colour == Drawing::Colour::black) |
| 560 | Rectangle::fill( |
| 561 | rt, { { topLeft + ScreenCoordsXY{ 1, 1 } }, { bottomRight - ScreenCoordsXY{ 1, 1 } } }, |
| 562 | getColourMap(colour.colour).dark); |
| 563 | else |
| 564 | Rectangle::filter( |
| 565 | rt, { { topLeft + ScreenCoordsXY{ 1, 1 } }, { bottomRight - ScreenCoordsXY{ 1, 1 } } }, |
| 566 | FilterPaletteID::paletteDarken3); |
| 567 | |
| 568 | // Draw text |
| 569 | if (!widget->flags.has(WidgetFlag::textIsString) && widget->text == kStringIdNone) |
| 570 | return; |
| 571 | |
| 572 | topLeft = w.windowPos + ScreenCoordsXY{ widget->left + 2, widget->top + 1 }; |
| 573 | int32_t width = widget->width() - 5; |
| 574 | |
| 575 | if (static_cast<size_t>(widgetIndex + 1) < w.widgets.size() |
| 576 | && (w.widgets[widgetIndex + 1]).type == WidgetType::closeBox) |
| 577 | { |
| 578 | width -= kCloseButtonSize; |
| 579 | if (static_cast<size_t>(widgetIndex + 2) < w.widgets.size() |
| 580 | && (w.widgets[widgetIndex + 2]).type == WidgetType::closeBox) |
| 581 | width -= kCloseButtonSize; |
| 582 | } |
| 583 | topLeft.x += width / 2; |
| 584 | if (Config::Get().interface.windowButtonsOnTheLeft) |
| 585 | topLeft.x += kCloseButtonSize; |
| 586 | if (Config::Get().interface.enlargedUi) |
| 587 | topLeft.y += kTitleHeightLarge / 4; |
| 588 | |
| 589 | Formatter ft{}; |
| 590 | bool hasStringPtr = widget->flags.has(WidgetFlag::textIsString); |
| 591 | auto formatString = widget->text; |
| 592 | if (hasStringPtr) |
| 593 | { |
| 594 | formatString = STR_STRING; |
| 595 | ft.Add<const utf8*>(widget->string); |
| 596 | } |
no test coverage detected