MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / drawSingle

Function drawSingle

src/OpenLoco/src/Ui/WindowManager.cpp:816–894  ·  view source on GitHub ↗

0x004C5FC8

Source from the content-addressed store, hash-verified

814
815 // 0x004C5FC8
816 static void drawSingle(Gfx::DrawingContext& drawingCtx, Window* w, int32_t left, int32_t top, int32_t right, int32_t bottom)
817 {
818 // Copy rt so we can crop it
819 Gfx::RenderTarget rt = drawingCtx.currentRenderTarget();
820
821 // Clamp left to 0
822 int32_t overflow = left - rt.x;
823 if (overflow > 0)
824 {
825 rt.x += overflow;
826 rt.width -= overflow;
827 if (rt.width <= 0)
828 {
829 return;
830 }
831 rt.pitch += overflow;
832 rt.bits += overflow;
833 }
834
835 // Clamp width to right
836 overflow = rt.x + rt.width - right;
837 if (overflow > 0)
838 {
839 rt.width -= overflow;
840 if (rt.width <= 0)
841 {
842 return;
843 }
844 rt.pitch += overflow;
845 }
846
847 // Clamp top to 0
848 overflow = top - rt.y;
849 if (overflow > 0)
850 {
851 rt.y += overflow;
852 rt.height -= overflow;
853 if (rt.height <= 0)
854 {
855 return;
856 }
857 rt.bits += (rt.width + rt.pitch) * overflow;
858 }
859
860 // Clamp height to bottom
861 overflow = rt.y + rt.height - bottom;
862 if (overflow > 0)
863 {
864 rt.height -= overflow;
865 if (rt.height <= 0)
866 {
867 return;
868 }
869 }
870
871 if (SceneManager::isProgressBarActive() && w->type != WindowType::progressBar)
872 {
873 return;

Callers 1

windowDrawFunction · 0.85

Calls 10

isProgressBarActiveFunction · 0.85
getCompanyColourFunction · 0.85
setWindowColoursFunction · 0.85
opaqueMethod · 0.80
getColourMethod · 0.80
pushRenderTargetMethod · 0.80
callPrepareDrawMethod · 0.80
callDrawMethod · 0.80
popRenderTargetMethod · 0.80
setColourMethod · 0.45

Tested by

no test coverage detected