MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / RefreshWidgets

Method RefreshWidgets

src/openrct2-ui/scripting/CustomWindow.cpp:870–946  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

868 }
869
870 void RefreshWidgets()
871 {
872 auto& widgetList = _info.Widgets;
873
874 widgetList.clear();
875 _info.WidgetIndexMap.clear();
876 _info.ListViews.clear();
877
878 // Add default widgets (window shim)
879 widgetList.insert(widgetList.begin(), std::begin(CustomDefaultWidgets), std::end(CustomDefaultWidgets));
880 for (size_t i = 0; i < widgetList.size(); i++)
881 {
882 _info.WidgetIndexMap.push_back(std::numeric_limits<size_t>::max());
883 }
884
885 // Add window tabs
886 if (!_info.Desc.Tabs.empty())
887 {
888 widgetList[WIDX_CONTENT_PANEL].top = kTabBarHeight;
889 }
890 for (size_t tabDescIndex = 0; tabDescIndex < _info.Desc.Tabs.size(); tabDescIndex++)
891 {
892 Widget widget{};
893 widget.type = WidgetType::tab;
894 widget.colour = 1;
895 widget.left = static_cast<int16_t>(3 + (tabDescIndex * 31));
896 widget.right = widget.left + 30;
897 widget.top = 17;
898 widget.bottom = kTabBarHeight;
899 widget.image = ImageId(SPR_TAB, FilterPaletteID::paletteNull);
900 widget.tooltip = kStringIdNone;
901 widgetList.push_back(widget);
902 _info.WidgetIndexMap.push_back(std::numeric_limits<size_t>::max());
903 }
904
905 // Add custom widgets
906 auto totalWidgets = _info.Desc.Widgets.size();
907 auto tabWidgetsOffset = totalWidgets;
908 if (!_info.Desc.Tabs.empty())
909 {
910 totalWidgets += _info.Desc.Tabs[page].Widgets.size();
911 }
912 for (size_t widgetDescIndex = 0; widgetDescIndex < totalWidgets; widgetDescIndex++)
913 {
914 const auto& widgetDesc = widgetDescIndex < _info.Desc.Widgets.size()
915 ? _info.Desc.Widgets[widgetDescIndex]
916 : _info.Desc.Tabs[page].Widgets[widgetDescIndex - tabWidgetsOffset];
917 auto preWidgetSize = widgetList.size();
918 CreateWidget(widgetList, widgetDesc);
919 auto numWidgetsAdded = widgetList.size() - preWidgetSize;
920 for (size_t i = 0; i < numWidgetsAdded; i++)
921 {
922 _info.WidgetIndexMap.push_back(widgetDescIndex);
923 }
924
925 if (widgetDesc.Type == "listview")
926 {
927 CustomListView listView(this, _info.ListViews.size());

Callers

nothing calls this directly

Calls 10

WindowInitScrollWidgetsFunction · 0.85
SetScrollbarsMethod · 0.80
SetColumnsMethod · 0.80
SetItemsMethod · 0.80
clearMethod · 0.65
ImageIdClass · 0.50
beginMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected