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

Function UpdateWidgetColour

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

Source from the content-addressed store, hash-verified

1214 }
1215
1216 void UpdateWidgetColour(WindowBase* w, WidgetIndex widgetIndex, Colour colour)
1217 {
1218 if (w->classification == WindowClass::custom)
1219 {
1220 auto& customInfo = GetInfo(static_cast<CustomWindow*>(w));
1221 auto customWidgetInfo = customInfo.GetCustomWidgetDesc(w, widgetIndex);
1222 if (customWidgetInfo != nullptr)
1223 {
1224 auto& widget = w->widgets[widgetIndex];
1225
1226 auto lastColour = customWidgetInfo->Colour;
1227 if (lastColour != colour && colourIsValid(colour))
1228 {
1229 customWidgetInfo->Colour = colour;
1230 widget.image = getColourButtonImage(colour);
1231
1232 auto* windowMgr = GetWindowManager();
1233 windowMgr->InvalidateWidget(*w, widgetIndex);
1234
1235 std::vector<JSValue> args;
1236 args.push_back(JS_NewInt32(customWidgetInfo->OnChange.context, EnumValue(colour)));
1237 InvokeEventHandler(customInfo.Owner, customWidgetInfo->OnChange, args);
1238 }
1239 }
1240 }
1241 }
1242
1243 void UpdateWidgetSelectedIndex(WindowBase* w, WidgetIndex widgetIndex, int32_t selectedIndex)
1244 {

Callers 2

onDropdownMethod · 0.85
colour_setMethod · 0.85

Calls 8

colourIsValidFunction · 0.85
getColourButtonImageFunction · 0.85
GetWindowManagerFunction · 0.85
EnumValueFunction · 0.85
InvokeEventHandlerFunction · 0.85
GetCustomWidgetDescMethod · 0.80
InvalidateWidgetMethod · 0.80
push_backMethod · 0.45

Tested by

no test coverage detected