| 198 | } |
| 199 | |
| 200 | void onDraw(RenderTarget& rt) override |
| 201 | { |
| 202 | drawWidgets(rt); |
| 203 | |
| 204 | auto screenCoords = windowPos + ScreenCoordsXY{ kWindowSize.width / 2, widgets[WIDX_TITLE].bottom + 13 }; |
| 205 | |
| 206 | int32_t no_lines = 0; |
| 207 | |
| 208 | if (_descriptionStringId == kStringIdNone) |
| 209 | { |
| 210 | drawTextWrapped(rt, screenCoords, kWindowSize.width, _description, { colours[1], TextAlignment::centre }); |
| 211 | } |
| 212 | else |
| 213 | { |
| 214 | drawTextWrapped( |
| 215 | rt, screenCoords, kWindowSize.width, _descriptionStringId, _descriptionArgs, |
| 216 | { colours[1], TextAlignment::centre }); |
| 217 | } |
| 218 | |
| 219 | screenCoords.y += 25; |
| 220 | |
| 221 | // String length needs to add 12 either side of box |
| 222 | // +13 for cursor when max length. |
| 223 | u8string wrappedString; |
| 224 | wrapString( |
| 225 | u8string_view{ _buffer.data(), _buffer.size() }, kWindowSize.width - (24 + 13), FontStyle::medium, |
| 226 | &wrappedString, &no_lines); |
| 227 | |
| 228 | Rectangle::fillInset( |
| 229 | rt, |
| 230 | { { windowPos.x + 10, screenCoords.y }, |
| 231 | { windowPos.x + kWindowSize.width - 10, screenCoords.y + 10 * (no_lines + 1) + 3 } }, |
| 232 | colours[1], Rectangle::BorderStyle::inset, Rectangle::FillBrightness::light, |
| 233 | Rectangle::FillMode::dontLightenWhenInset); |
| 234 | |
| 235 | screenCoords.y += 1; |
| 236 | |
| 237 | const utf8* wrapPointer = wrappedString.data(); |
| 238 | size_t char_count = 0; |
| 239 | uint8_t cur_drawn = 0; |
| 240 | |
| 241 | auto* textInput = GetTextboxSession(); |
| 242 | int32_t cursorX = 0; |
| 243 | int32_t cursorY = 0; |
| 244 | for (int32_t line = 0; line <= no_lines; line++) |
| 245 | { |
| 246 | screenCoords.x = windowPos.x + 12; |
| 247 | drawText( |
| 248 | rt, screenCoords, wrapPointer, |
| 249 | { colours[1], FontStyle::medium, { TextPaintFlag::noFormatting }, TextAlignment::left }); |
| 250 | |
| 251 | size_t string_length = GetStringSize(wrapPointer) - 1; |
| 252 | if (!cur_drawn && (textInput->SelectionStart <= char_count + string_length)) |
| 253 | { |
| 254 | // Make a view of the string for measuring the width. |
| 255 | cursorX = windowPos.x + 13 |
| 256 | + getStringWidth( |
| 257 | u8string_view{ wrapPointer, textInput->SelectionStart - char_count }, FontStyle::medium, |
nothing calls this directly
no test coverage detected