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

Function WidgetDrawImage

src/openrct2-ui/interface/Widget.cpp:861–903  ·  view source on GitHub ↗

* * rct2: 0x006EB951 */

Source from the content-addressed store, hash-verified

859 * rct2: 0x006EB951
860 */
861 static void WidgetDrawImage(RenderTarget& rt, WindowBase& w, WidgetIndex widgetIndex)
862 {
863 // Get the widget
864 const auto& widget = w.widgets[widgetIndex];
865
866 // Get the image
867 if (widget.image.GetIndex() == kImageIndexUndefined)
868 return;
869 auto image = widget.image;
870
871 // Resolve the absolute ltrb
872 auto screenCoords = w.windowPos + ScreenCoordsXY{ widget.left, widget.top };
873
874 if (widget.type == WidgetType::colourBtn || widget.type == WidgetType::trnBtn || widget.type == WidgetType::tab)
875 if (widgetIsPressed(w, widgetIndex) || isToolActive(w, widgetIndex))
876 image = image.WithIndexOffset(1);
877
878 const auto colour = w.colours[widget.colour].colour;
879 if (widgetIsDisabled(w, widgetIndex))
880 {
881 // Draw greyed out (light border bottom right shadow)
882 auto mappedColour = getColourMap(colour).lighter;
883 GfxDrawSpriteSolid(rt, image, screenCoords + ScreenCoordsXY{ 1, 1 }, mappedColour);
884
885 // Draw greyed out (dark)
886 mappedColour = getColourMap(colour).midLight;
887 GfxDrawSpriteSolid(rt, image, screenCoords, mappedColour);
888 }
889 else
890 {
891 if (image.HasSecondary())
892 {
893 // ?
894 }
895
896 if (image.IsBlended())
897 image = image.WithBlended(false);
898 else
899 image = image.WithPrimary(colour);
900
901 GfxDrawSprite(rt, image, screenCoords);
902 }
903 }
904
905 bool widgetIsDisabled(const WindowBase& w, WidgetIndex widgetIndex)
906 {

Callers 3

WidgetButtonDrawFunction · 0.85
WidgetTabDrawFunction · 0.85
WidgetFlatButtonDrawFunction · 0.85

Calls 12

widgetIsPressedFunction · 0.85
isToolActiveFunction · 0.85
widgetIsDisabledFunction · 0.85
getColourMapFunction · 0.85
GfxDrawSpriteSolidFunction · 0.85
GfxDrawSpriteFunction · 0.85
WithIndexOffsetMethod · 0.80
HasSecondaryMethod · 0.80
IsBlendedMethod · 0.80
WithBlendedMethod · 0.80
WithPrimaryMethod · 0.80
GetIndexMethod · 0.45

Tested by

no test coverage detected