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

Function WindowDrawSingle

src/openrct2/interface/Window.cpp:578–638  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

576 }
577
578 static void WindowDrawSingle(
579 Drawing::RenderTarget& rt, WindowBase& w, int32_t left, int32_t top, int32_t right, int32_t bottom)
580 {
581 assert(rt.zoom_level == ZoomLevel{ 0 });
582
583 // Copy render target so we can crop it
584 Drawing::RenderTarget copy = rt;
585
586 // Clamp left to 0
587 int32_t overflow = left - copy.x;
588 if (overflow > 0)
589 {
590 copy.x += overflow;
591 copy.width -= overflow;
592 if (copy.width <= 0)
593 return;
594 copy.pitch += overflow;
595 copy.bits += overflow;
596 }
597
598 // Clamp width to right
599 overflow = copy.x + copy.width - right;
600 if (overflow > 0)
601 {
602 copy.width -= overflow;
603 if (copy.width <= 0)
604 return;
605 copy.pitch += overflow;
606 }
607
608 // Clamp top to 0
609 overflow = top - copy.y;
610 if (overflow > 0)
611 {
612 copy.y += overflow;
613 copy.height -= overflow;
614 if (copy.height <= 0)
615 return;
616 copy.bits += copy.LineStride() * overflow;
617 }
618
619 // Clamp height to bottom
620 overflow = copy.y + copy.height - bottom;
621 if (overflow > 0)
622 {
623 copy.height -= overflow;
624 if (copy.height <= 0)
625 return;
626 }
627
628 // Invalidate modifies the window colours so first get the correct
629 // colour before setting the global variables for the string painting
630 w.onPrepareDraw();
631
632 // Text colouring
633 gCurrentWindowColours[0] = w.colours[0].colour;
634 gCurrentWindowColours[1] = w.colours[1].colour;
635 gCurrentWindowColours[2] = w.colours[2].colour;

Callers 1

WindowDrawCoreFunction · 0.85

Calls 3

LineStrideMethod · 0.80
onPrepareDrawMethod · 0.45
onDrawMethod · 0.45

Tested by

no test coverage detected