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

Function show

src/OpenLoco/src/Ui/Dropdown.cpp:509–583  ·  view source on GitHub ↗

* 0x004CC807 * * @param x * @param y * @param width * @param height * @param colour * @param count * @param itemHeight * @param flags * Custom Dropdown height if flags & (1<<6) is true */

Source from the content-addressed store, hash-verified

507 * Custom Dropdown height if flags & (1<<6) is true
508 */
509 void show(int16_t x, int16_t y, int16_t width, int16_t height, AdvancedColour colour, size_t count, uint8_t itemHeight, uint8_t flags)
510 {
511 assert(count < std::numeric_limits<uint8_t>::max());
512
513 common::setColourAndInputFlags(colour, flags);
514
515 WindowManager::close(WindowType::dropdown, 0);
516 _dropdownFlags = Flags::none;
517
518 _dropdownColumnCount = 1;
519 _dropdownItemWidth = 0;
520 _dropdownItemWidth = width;
521 _dropdownItemHeight = 10;
522
523 if (flags & (1 << 6))
524 {
525 _dropdownItemHeight = itemHeight;
526 }
527
528 flags &= ~(1 << 6);
529
530 _dropdownItemCount = static_cast<uint16_t>(count);
531 _dropdownRowCount = 0;
532 _dropdownRowCount = static_cast<uint32_t>(count);
533
534 int16_t dropdownHeight = (static_cast<int16_t>(count) * _dropdownItemHeight) + 3;
535 common::widgets[0].bottom = dropdownHeight;
536 dropdownHeight++;
537 Ui::Size size = { width, height };
538 Ui::Point origin = { x, y };
539 origin.y += height;
540
541 size.height = dropdownHeight;
542 if ((size.height + origin.y) > Ui::height() || origin.y < 0)
543 {
544 origin.y -= (height + dropdownHeight);
545 auto dropdownBottom = origin.y;
546
547 if (origin.y >= 0)
548 {
549 dropdownBottom = origin.y + dropdownHeight;
550 }
551
552 if (origin.y < 0 || dropdownBottom > Ui::height())
553 {
554 origin.x += width + 3;
555 origin.y = 0;
556 }
557 }
558
559 size.width = width + 3;
560 common::widgets[0].right = size.width;
561 size.width++;
562
563 if (origin.x < 0)
564 {
565 origin.x = 0;
566 }

Callers 15

populateTownSizeSelectFunction · 0.85
onMouseDownFunction · 0.85
scrollMouseDownFunction · 0.85
onMouseDownFunction · 0.85
screenModeMouseDownFunction · 0.85
frameLimitMouseDownFunction · 0.85
vehicleZoomMouseDownFunction · 0.85
audioDeviceMouseDownFunction · 0.85
languageMouseDownFunction · 0.85

Calls 5

setColourAndInputFlagsFunction · 0.85
heightFunction · 0.85
widthFunction · 0.85
closeFunction · 0.70
openFunction · 0.70

Tested by

no test coverage detected