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

Method FormatTextForTooltip

src/openrct2-ui/windows/Tooltip.cpp:141–156  ·  view source on GitHub ↗

Returns the width of the new tooltip text

Source from the content-addressed store, hash-verified

139 private:
140 // Returns the width of the new tooltip text
141 int32_t FormatTextForTooltip(const StringWithArgs& message)
142 {
143 const u8string tempString = FormatStringIDLegacy(message.str, message.args.Data());
144
145 StringWithArgs formattedMessage{ STR_STRING_TOOLTIP, Formatter() };
146 formattedMessage.args.Add<const char*>(tempString.c_str());
147 const u8string tooltipTextUnwrapped = FormatStringIDLegacy(formattedMessage.str, formattedMessage.args.Data());
148
149 auto textWidth = getStringWidthNewlined(tooltipTextUnwrapped, FontStyle::small);
150 textWidth = std::min(textWidth, 196);
151
152 int32_t numLines;
153 textWidth = wrapString(tooltipTextUnwrapped, textWidth + 1, FontStyle::small, &_tooltipText, &numLines);
154 _tooltipNumLines = numLines;
155 return textWidth;
156 }
157 };
158
159 void WindowTooltipReset(const ScreenCoordsXY& screenCoords)

Callers

nothing calls this directly

Calls 5

FormatStringIDLegacyFunction · 0.85
getStringWidthNewlinedFunction · 0.85
wrapStringFunction · 0.85
DataMethod · 0.80
FormatterClass · 0.70

Tested by

no test coverage detected