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

Function WidgetTabDraw

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

* * rct2: 0x006EB806 */

Source from the content-addressed store, hash-verified

232 * rct2: 0x006EB806
233 */
234 static void WidgetTabDraw(RenderTarget& rt, WindowBase& w, WidgetIndex widgetIndex)
235 {
236 // Get the widget
237 auto& widget = w.widgets[widgetIndex];
238
239 if (widget.type != WidgetType::tab && widget.image.GetIndex() == kImageIndexUndefined)
240 return;
241
242 if (widget.type == WidgetType::tab)
243 {
244 if (widgetIsDisabled(w, widgetIndex))
245 return;
246
247 if (widget.image.GetIndex() == kImageIndexUndefined)
248 {
249 // Set standard tab sprite to use.
250 widget.image = ImageId(SPR_TAB, FilterPaletteID::paletteNull);
251 }
252 }
253
254 // Draw widgets that aren't explicitly disabled.
255 if (!widgetIsDisabled(w, widgetIndex))
256 {
257 WidgetDrawImage(rt, w, widgetIndex);
258 return;
259 }
260
261 if (widget.type != WidgetType::trnBtn)
262 {
263 WidgetDrawImage(rt, w, widgetIndex);
264 return;
265 }
266
267 // Resolve the absolute ltrb
268 auto leftTop = w.windowPos + ScreenCoordsXY{ widget.left, widget.top };
269
270 // Get the colour and disabled image
271 auto colour = w.colours[widget.colour].colour;
272 const auto newIndex = widget.image.GetIndex() + 2;
273 auto image = widget.image.WithIndex(newIndex).WithPrimary(colour);
274
275 // Draw disabled image
276 GfxDrawSprite(rt, image, leftTop);
277 }
278
279 /**
280 *

Callers 1

widgetDrawFunction · 0.85

Calls 7

widgetIsDisabledFunction · 0.85
WidgetDrawImageFunction · 0.85
GfxDrawSpriteFunction · 0.85
WithPrimaryMethod · 0.80
WithIndexMethod · 0.80
ImageIdClass · 0.70
GetIndexMethod · 0.45

Tested by

no test coverage detected