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

Function showText2

src/OpenLoco/src/Ui/Dropdown.cpp:778–845  ·  view source on GitHub ↗

* 0x004CCC7C * x @ * y @ * width @ * height @ * colour @ * count @ * flags @ */

Source from the content-addressed store, hash-verified

776 * flags @<bh>
777 */
778 void showText2(int16_t x, int16_t y, int16_t width, int16_t height, uint8_t itemHeight, AdvancedColour colour, size_t count, uint8_t flags)
779 {
780 assert(count < std::numeric_limits<uint8_t>::max());
781
782 common::setColourAndInputFlags(colour, flags);
783
784 WindowManager::close(WindowType::dropdown, 0);
785 _dropdownFlags = Flags::none;
786
787 _dropdownColumnCount = 1;
788 _dropdownItemWidth = width;
789 _dropdownItemHeight = 10;
790
791 if (flags & (1 << 6))
792 {
793 _dropdownItemHeight = itemHeight;
794 }
795
796 flags &= ~(1 << 6);
797
798 _dropdownItemCount = static_cast<uint16_t>(count);
799 _dropdownRowCount = static_cast<uint32_t>(count);
800 uint16_t dropdownHeight = static_cast<uint16_t>(count) * _dropdownItemHeight + 3;
801 common::widgets[0].bottom = dropdownHeight;
802 dropdownHeight++;
803
804 Ui::Size size = { static_cast<uint16_t>(width), static_cast<uint16_t>(height) };
805 Ui::Point origin = { x, y };
806 origin.y += height;
807
808 size.height = dropdownHeight;
809 if ((size.height + origin.y) > Ui::height() || origin.y < 0)
810 {
811 origin.y -= (height + dropdownHeight);
812 auto dropdownBottom = origin.y;
813
814 if (origin.y >= 0)
815 {
816 dropdownBottom = origin.y + dropdownHeight;
817 }
818
819 if (origin.y < 0 || dropdownBottom > Ui::height())
820 {
821 origin.x += width + 3;
822 origin.y = 0;
823 }
824 }
825
826 size.width = width + 3;
827 common::widgets[0].right = size.width;
828 size.width++;
829
830 if (origin.x < 0)
831 {
832 origin.x = 0;
833 }
834
835 origin.x += size.width;

Callers 1

resolutionMouseDownFunction · 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