This method is the same as gfx_draw_string_left_wrapped. But this adjusts the initial Y coordinate depending of the number of lines.
| 288 | // This method is the same as gfx_draw_string_left_wrapped. |
| 289 | // But this adjusts the initial Y coordinate depending of the number of lines. |
| 290 | static int32_t ChatHistoryDrawString(RenderTarget& rt, const char* text, const ScreenCoordsXY& screenCoords, int32_t width) |
| 291 | { |
| 292 | int32_t numLines; |
| 293 | u8string wrappedString; |
| 294 | wrapString(FormatString("{OUTLINE}{WHITE}{STRING}", text), width, FontStyle::medium, &wrappedString, &numLines); |
| 295 | auto lineHeight = FontGetLineHeight(FontStyle::medium); |
| 296 | |
| 297 | int32_t expectedY = screenCoords.y - (numLines * lineHeight); |
| 298 | if (expectedY < 50) |
| 299 | { |
| 300 | return (numLines * lineHeight); // Skip drawing, return total height. |
| 301 | } |
| 302 | |
| 303 | const utf8* bufferPtr = wrappedString.data(); |
| 304 | int32_t lineY = screenCoords.y; |
| 305 | for (int32_t line = 0; line <= numLines; ++line) |
| 306 | { |
| 307 | drawText(rt, { screenCoords.x, lineY - (numLines * lineHeight) }, bufferPtr, { OpenRCT2::Drawing::kColourNull }); |
| 308 | bufferPtr = GetStringEnd(bufferPtr) + 1; |
| 309 | lineY += lineHeight; |
| 310 | } |
| 311 | return lineY - screenCoords.y; |
| 312 | } |
| 313 | |
| 314 | // Wrap string without drawing, useful to get the height of a wrapped string. |
| 315 | // Almost the same as gfx_draw_string_left_wrapped |
no test coverage detected