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

Method show

src/OpenLoco/src/Ui/Dropdown.cpp:1033–1075  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1031 }
1032
1033 void Builder::show()
1034 {
1035 if (_window == nullptr)
1036 {
1037 throw Exception::InvalidArgument("Window and widget index not set");
1038 }
1039
1040 _dropdownIds.clear();
1041
1042 size_t index{};
1043 std::optional<size_t> highlightedIndex;
1044 for (const auto& item : _items)
1045 {
1046 auto& id = std::get<0>(item);
1047 if (id)
1048 {
1049 auto& text = std::get<1>(item);
1050 Dropdown::add(index, text);
1051
1052 if (id == _highlightedId)
1053 {
1054 highlightedIndex = index;
1055 }
1056 }
1057 else
1058 {
1059 Dropdown::addSeparator(index);
1060 }
1061 _dropdownIds.push_back(id);
1062 index++;
1063 }
1064
1065 showBelow(_window, _widgetIndex, _items.size(), 0);
1066 if (highlightedIndex)
1067 {
1068 Dropdown::setHighlightedItem(*highlightedIndex);
1069 _dropdownUseDefault = true;
1070 }
1071 else
1072 {
1073 _dropdownUseDefault = false;
1074 }
1075 }
1076
1077 Builder create()
1078 {

Callers 1

loadsaveMenuMouseDownFunction · 0.80

Calls 7

addSeparatorFunction · 0.85
showBelowFunction · 0.85
setHighlightedItemFunction · 0.85
push_backMethod · 0.80
addFunction · 0.70
clearMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected