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

Method onDraw

src/openrct2-ui/windows/Footpath.cpp:556–620  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

554 }
555
556 void onDraw(Drawing::RenderTarget& rt) override
557 {
558 ScreenCoordsXY screenCoords;
559 WindowDrawWidgets(*this, rt);
560 WindowFootpathDrawDropdownButtons(rt);
561
562 if (!isWidgetDisabled(WIDX_CONSTRUCT))
563 {
564 // Get construction image
565 uint8_t direction = (_footpathConstructDirection + GetCurrentRotation()) % kNumOrthogonalDirections;
566 auto slopeOffset = EnumValue(_footpathConstructSlope);
567
568 std::optional<uint32_t> baseImage;
569 if (gFootpathSelection.legacyPath == kObjectEntryIndexNull)
570 {
571 auto selectedPath = gFootpathSelection.getSelectedSurface();
572 const auto* pathType = GetPathSurfaceEntry(selectedPath);
573 if (pathType != nullptr)
574 {
575 baseImage = pathType->BaseImageId;
576 }
577 }
578 else
579 {
580 auto& objManager = GetContext()->GetObjectManager();
581 const auto* pathObj = objManager.GetLoadedObject<FootpathObject>(gFootpathSelection.legacyPath);
582 if (pathObj != nullptr)
583 {
584 auto pathEntry = reinterpret_cast<const FootpathEntry*>(pathObj->GetLegacyData());
585 if (gFootpathSelection.isQueueSelected)
586 baseImage = pathEntry->GetQueueImage();
587 else
588 baseImage = pathEntry->image;
589 }
590 }
591
592 if (baseImage)
593 {
594 auto image = *baseImage + kConstructionPreviewImages[slopeOffset][direction];
595
596 // Draw construction image
597 screenCoords = this->windowPos
598 + ScreenCoordsXY{ widgets[WIDX_CONSTRUCT].midX(), widgets[WIDX_CONSTRUCT].bottom - 60 };
599 GfxDrawSprite(rt, ImageId(image), screenCoords);
600 }
601
602 // Draw build this... label
603 screenCoords = this->windowPos
604 + ScreenCoordsXY{ widgets[WIDX_CONSTRUCT].midX(), widgets[WIDX_CONSTRUCT].bottom - 23 };
605 drawText(rt, screenCoords, STR_BUILD_THIS, { TextAlignment::centre });
606 }
607
608 // Draw cost
609 screenCoords = this->windowPos
610 + ScreenCoordsXY{ widgets[WIDX_CONSTRUCT].midX(), widgets[WIDX_CONSTRUCT].bottom - 12 };
611 if (_windowFootpathCost != kMoney64Undefined)
612 {
613 if (!(getGameState().park.flags & PARK_FLAGS_NO_MONEY))

Callers

nothing calls this directly

Calls 13

WindowDrawWidgetsFunction · 0.85
GetCurrentRotationFunction · 0.85
EnumValueFunction · 0.85
GetPathSurfaceEntryFunction · 0.85
GetContextFunction · 0.85
GfxDrawSpriteFunction · 0.85
drawTextFunction · 0.85
getSelectedSurfaceMethod · 0.80
GetQueueImageMethod · 0.80
midXMethod · 0.80
FormatterClass · 0.70
ImageIdClass · 0.50

Tested by

no test coverage detected