0x004CCAB2
| 408 | |
| 409 | // 0x004CCAB2 |
| 410 | static void showText(int16_t x, int16_t y, int16_t width, int16_t height, uint8_t itemHeight, AdvancedColour colour, size_t count, uint8_t flags) |
| 411 | { |
| 412 | _dropdownColumnCount = 1; |
| 413 | _dropdownItemWidth = 0; |
| 414 | _dropdownItemHeight = 10; |
| 415 | |
| 416 | if (flags & (1 << 6)) |
| 417 | { |
| 418 | _dropdownItemHeight = itemHeight; |
| 419 | } |
| 420 | |
| 421 | flags &= ~(1 << 6); |
| 422 | |
| 423 | uint16_t maxStringWidth = 0; |
| 424 | for (uint8_t itemCount = 0; itemCount < count; itemCount++) |
| 425 | { |
| 426 | auto args = FormatArguments(); |
| 427 | |
| 428 | dropdownFormatArgsToFormatArgs(itemCount, args); |
| 429 | |
| 430 | StringManager::formatString(_byte_112CC04, _dropdownItemFormats[itemCount], args); |
| 431 | |
| 432 | auto stringWidth = Gfx::TextRenderer::getMaxStringWidth(Gfx::Font::medium_bold, _byte_112CC04); |
| 433 | |
| 434 | maxStringWidth = std::max(maxStringWidth, stringWidth); |
| 435 | } |
| 436 | |
| 437 | maxStringWidth += 3; |
| 438 | _dropdownItemWidth = maxStringWidth; |
| 439 | _dropdownItemCount = static_cast<uint16_t>(count); |
| 440 | _dropdownRowCount = static_cast<uint32_t>(count); |
| 441 | uint16_t dropdownHeight = _dropdownItemHeight * static_cast<uint16_t>(count) + 3; |
| 442 | widgets[0].bottom = dropdownHeight; |
| 443 | dropdownHeight++; |
| 444 | |
| 445 | Ui::Size size = { static_cast<int32_t>(_dropdownItemWidth), dropdownHeight }; |
| 446 | Ui::Point origin = { x, y }; |
| 447 | origin.y += height; |
| 448 | |
| 449 | if ((size.height + origin.y) > Ui::height() || origin.y < 0) |
| 450 | { |
| 451 | origin.y -= (height + size.height); |
| 452 | auto dropdownBottom = origin.y; |
| 453 | |
| 454 | if (origin.y >= 0) |
| 455 | { |
| 456 | dropdownBottom = origin.y + size.height; |
| 457 | } |
| 458 | |
| 459 | if (origin.y < 0 || dropdownBottom > Ui::height()) |
| 460 | { |
| 461 | origin.x += width; |
| 462 | origin.x += maxStringWidth; |
| 463 | |
| 464 | if (origin.x > Ui::width()) |
| 465 | { |
| 466 | origin.x = x; |
| 467 | origin.x -= (maxStringWidth + 4); |
no test coverage detected