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

Function windowDrawSplit

src/OpenLoco/src/Ui/WindowManager.cpp:1896–1949  ·  view source on GitHub ↗

* 0x004C5EA9 * * @param rt * @param w @ * @param left @ * @param top @ * @param right @ * @param bottom @ * @return */

Source from the content-addressed store, hash-verified

1894 * @return
1895 */
1896 static bool windowDrawSplit(Gfx::DrawingContext& ctx, Ui::Window* w, int32_t left, int32_t top, int32_t right, int32_t bottom)
1897 {
1898 // Divide the draws up for only the visible regions of the window recursively
1899 for (size_t index = indexOf(*w) + 1; index < count(); index++)
1900 {
1901 auto topwindow = get(index);
1902
1903 // Check if this window overlaps w
1904 if (topwindow->x >= right || topwindow->y >= bottom)
1905 {
1906 continue;
1907 }
1908 if (topwindow->x + topwindow->width <= left || topwindow->y + topwindow->height <= top)
1909 {
1910 continue;
1911 }
1912 if (topwindow->isTranslucent())
1913 {
1914 continue;
1915 }
1916
1917 // A window overlaps w, split up the draw into two regions where the window starts to overlap
1918 if (topwindow->x > left)
1919 {
1920 // Split draw at topwindow.left
1921 windowDraw(ctx, w, left, top, topwindow->x, bottom);
1922 windowDraw(ctx, w, topwindow->x, top, right, bottom);
1923 }
1924 else if (topwindow->x + topwindow->width < right)
1925 {
1926 // Split draw at topwindow.right
1927 windowDraw(ctx, w, left, top, topwindow->x + topwindow->width, bottom);
1928 windowDraw(ctx, w, topwindow->x + topwindow->width, top, right, bottom);
1929 }
1930 else if (topwindow->y > top)
1931 {
1932 // Split draw at topwindow.top
1933 windowDraw(ctx, w, left, top, right, topwindow->y);
1934 windowDraw(ctx, w, left, topwindow->y, right, bottom);
1935 }
1936 else if (topwindow->y + topwindow->height < bottom)
1937 {
1938 // Split draw at topwindow.bottom
1939 windowDraw(ctx, w, left, top, right, topwindow->y + topwindow->height);
1940 windowDraw(ctx, w, left, topwindow->y + topwindow->height, right, bottom);
1941 }
1942
1943 // Drawing for this region should be done now, exit
1944 return true;
1945 }
1946
1947 // No windows overlap
1948 return false;
1949 }
1950
1951 void render(Gfx::DrawingContext& drawingCtx, const Rect& rect)
1952 {

Callers 1

windowDrawFunction · 0.85

Calls 5

indexOfFunction · 0.85
countFunction · 0.85
windowDrawFunction · 0.85
getFunction · 0.70
isTranslucentMethod · 0.45

Tested by

no test coverage detected