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

Function showImage

src/OpenLoco/src/Ui/Dropdown.cpp:614–682  ·  view source on GitHub ↗

* 0x004CCDE7 * * @param x * @param y * @param width * @param height * @param heightOffset * @param colour * @param columnCount * @param count * @param flags */

Source from the content-addressed store, hash-verified

612 * @param flags
613 */
614 void showImage(int16_t x, int16_t y, int16_t width, int16_t height, int16_t heightOffset, AdvancedColour colour, uint8_t columnCount, uint8_t count, uint8_t flags)
615 {
616 assert(count < std::numeric_limits<uint8_t>::max());
617 assert(count < std::size(kAppropriateImageDropdownItemsPerRow));
618
619 common::setColourAndInputFlags(colour, flags);
620
621 WindowManager::close(WindowType::dropdown, 0);
622 _dropdownFlags = Flags::none;
623
624 WindowManager::close(WindowType::dropdown, 0);
625 _dropdownFlags = Flags::none;
626 _dropdownItemHeight = height;
627 _dropdownItemWidth = width;
628 _dropdownItemCount = count;
629 _dropdownColumnCount = columnCount;
630
631 _dropdownRowCount = _dropdownItemCount / _dropdownColumnCount + ((_dropdownItemCount % _dropdownColumnCount) ? 1 : 0);
632 uint16_t dropdownWidth = _dropdownItemWidth * _dropdownColumnCount + 3;
633 common::widgets[0].right = dropdownWidth;
634 uint16_t dropdownHeight = _dropdownItemHeight * _dropdownRowCount + 3;
635 common::widgets[0].bottom = dropdownHeight;
636 dropdownHeight++;
637
638 Ui::Size size = { dropdownWidth, dropdownHeight };
639 Ui::Point origin = { x, y };
640 origin.y += heightOffset;
641
642 size.height = dropdownHeight;
643 if ((size.height + origin.y) > Ui::height() || origin.y < 0)
644 {
645 origin.y -= (heightOffset + dropdownHeight);
646 auto dropdownBottom = origin.y;
647
648 if (origin.y >= 0)
649 {
650 dropdownBottom = origin.y + dropdownHeight;
651 }
652
653 if (origin.y < 0 || dropdownBottom > Ui::height())
654 {
655 origin.x += common::widgets[0].right;
656 origin.y = 0;
657 }
658 }
659
660 size.width = common::widgets[0].right + 1;
661
662 if (origin.x < 0)
663 {
664 origin.x = 0;
665 }
666
667 origin.x += size.width;
668
669 if (origin.x > Ui::width())
670 {
671 origin.x = Ui::width();

Callers 2

showColourFunction · 0.85
showDropdownFunction · 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