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

Function drawStringCentredRaw

src/OpenLoco/src/Graphics/TextRenderer.cpp:748–778  ·  view source on GitHub ↗

0x00494E33 al: colour bx: string id bp: width cx: x dx: y esi: args edi: rt

Source from the content-addressed store, hash-verified

746 // esi: args
747 // edi: rt
748 static Ui::Point drawStringCentredRaw(
749 TextDrawingState& drawState,
750 DrawingContext& ctx,
751 const RenderTarget& rt,
752 Ui::Point origin,
753 uint16_t linebreakCount,
754 AdvancedColour colour,
755 const char* wrappedStr)
756 {
757 // Setup the text colours (FIXME: This should be a separate function)
758 char empty[1] = "";
759 drawString(drawState, ctx, rt, origin, colour, empty);
760
761 const char* ptr = wrappedStr;
762 auto basePoint = origin;
763
764 for (auto i = 0; i < linebreakCount + 1 && ptr != nullptr; ++i)
765 {
766 uint16_t lineWidth = getStringWidth(drawState.font, ptr);
767
768 auto point = basePoint;
769 point.x -= lineWidth / 2;
770
771 drawString(drawState, ctx, rt, point, AdvancedColour::FE(), const_cast<char*>(ptr));
772
773 ptr = advanceToNextLineWrapped(ptr);
774 basePoint.y += getLineHeight(drawState.font);
775 }
776
777 return basePoint;
778 }
779
780 static void drawStringYOffsets(
781 TextDrawingState& drawState,

Callers 1

drawStringCentredRawMethod · 0.85

Calls 4

drawStringFunction · 0.85
getStringWidthFunction · 0.85
advanceToNextLineWrappedFunction · 0.85
getLineHeightFunction · 0.85

Tested by

no test coverage detected