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

Function showColour

src/OpenLoco/src/Ui/Dropdown.cpp:860–903  ·  view source on GitHub ↗

* 0x004CCF8C * window @ * widget @ * availableColours @ * dropdownColour @ * selectedColour @ */

Source from the content-addressed store, hash-verified

858 * selectedColour @<ah>
859 */
860 void showColour(const Window* window, const Widget* widget, uint32_t availableColours, Colour selectedColour, AdvancedColour dropdownColour)
861 {
862 uint8_t count = 0;
863 for (uint8_t i = 0; i < 32; i++)
864 {
865 if (availableColours & (1 << i))
866 {
867 count++;
868 }
869 }
870
871 const uint8_t columnCount = getItemsPerRow(count);
872 const uint8_t flags = 0x80;
873 const uint8_t itemWidth = 16;
874 const uint8_t itemHeight = 16;
875 const int16_t x = window->x + widget->left;
876 const int16_t y = window->y + widget->top;
877 const int16_t heightOffset = widget->height() + 1;
878
879 showImage(x, y, itemWidth, itemHeight, heightOffset, dropdownColour, columnCount, count, flags);
880
881 uint8_t currentIndex = 0;
882 for (uint8_t i = 0; i < 32; i++)
883 {
884 if (!(availableColours & (1 << i)))
885 {
886 continue;
887 }
888
889 const auto colour = static_cast<Colour>(i);
890 if (colour == selectedColour)
891 {
892 Dropdown::setHighlightedItem(currentIndex);
893 }
894
895 auto args = FormatArguments();
896 args.push(Gfx::recolour(ImageIds::colour_swatch_recolourable_raised, colour));
897 args.push<uint16_t>(i);
898
899 Dropdown::add(currentIndex, 0xFFFE, args);
900
901 currentIndex++;
902 }
903 }
904
905 // 0x004CF3CC
906 void forceCloseCompanySelect()

Callers 4

onMouseDownFunction · 0.85
onMouseDownFunction · 0.85
onMouseDownFunction · 0.85
onMouseDownFunction · 0.85

Calls 8

getItemsPerRowFunction · 0.85
showImageFunction · 0.85
setHighlightedItemFunction · 0.85
recolourFunction · 0.85
addFunction · 0.70
FormatArgumentsClass · 0.50
heightMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected