MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / drawStringCentred

Function drawStringCentred

src/OpenLoco/src/Graphics/TextRenderer.cpp:626–649  ·  view source on GitHub ↗

0x00494DE8 al: colour bx: string id cx: x dx: y esi: args edi: rt

Source from the content-addressed store, hash-verified

624 // esi: args
625 // edi: rt
626 static Ui::Point drawStringCentred(
627 TextDrawingState& drawState,
628 DrawingContext& ctx,
629 const RenderTarget& rt,
630 Ui::Point origin,
631 AdvancedColour colour,
632 StringId stringId,
633 FormatArgumentsView args)
634 {
635 char buffer[512];
636 StringManager::formatString(buffer, std::size(buffer), stringId, args);
637
638 uint16_t width = getStringWidth(drawState.font, buffer);
639
640 auto point = origin;
641 point.x = origin.x - (width / 2);
642
643 if (point.x < 0)
644 {
645 return origin;
646 }
647
648 return drawString(drawState, ctx, rt, point, colour, buffer);
649 }
650
651 // 0x00494C36
652 // al: colour

Callers 1

drawStringCentredMethod · 0.85

Calls 3

formatStringFunction · 0.85
getStringWidthFunction · 0.85
drawStringFunction · 0.85

Tested by

no test coverage detected