diff --git a/src/openrct2-ui/UiContext.cpp b/src/openrct2-ui/UiContext.cpp index 99ba70d155..885463cc1f 100644 --- a/src/openrct2-ui/UiContext.cpp +++ b/src/openrct2-ui/UiContext.cpp @@ -299,10 +299,10 @@ public: void DrawWeatherAnimation(IWeatherDrawer* weatherDrawer, DrawPixelInfo& dpi, DrawWeatherFunc drawFunc) override { - int32_t left = dpi.ScreenX(); - int32_t right = left + dpi.ScreenWidth(); - int32_t top = dpi.ScreenY(); - int32_t bottom = top + dpi.ScreenHeight(); + int32_t left = dpi.x; + int32_t right = left + dpi.width; + int32_t top = dpi.y; + int32_t bottom = top + dpi.height; for (auto& w : g_window_list) { diff --git a/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp b/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp index 1941c20593..3bedf9d20b 100644 --- a/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp +++ b/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp @@ -82,7 +82,7 @@ private: static uint8_t ComputeOutCode(ScreenCoordsXY, ScreenCoordsXY, ScreenCoordsXY); static bool CohenSutherlandLineClip(ScreenLine&, const DrawPixelInfo&); - ScreenRect CalculateClipping(const DrawPixelInfo& dpi); + [[nodiscard]] ScreenRect CalculateClipping(const DrawPixelInfo& dpi) const; public: explicit OpenGLDrawingContext(OpenGLDrawingEngine& engine); @@ -159,8 +159,8 @@ public: auto patternPixel = pattern[patternYPos * 2 + 1]; for (; xPixelOffset < finalPixelOffset; xPixelOffset += patternXSpace) { - int32_t pixelX = xPixelOffset % dpi.ScreenWidth(); - int32_t pixelY = (xPixelOffset / dpi.ScreenWidth()) % dpi.ScreenHeight(); + int32_t pixelX = xPixelOffset % dpi.width; + int32_t pixelY = (xPixelOffset / dpi.width) % dpi.height; _drawingContext->DrawLine(dpi, patternPixel, { { pixelX, pixelY }, { pixelX + 1, pixelY + 1 } }); } @@ -429,10 +429,10 @@ private: DrawPixelInfo* dpi = &_bitsDPI; dpi->bits = _bits.get(); - dpi->SetX(0); - dpi->SetY(0); - dpi->SetWidth(width); - dpi->SetHeight(height); + dpi->x = 0; + dpi->y = 0; + dpi->width = width; + dpi->height = height; dpi->pitch = _pitch - width; } @@ -508,8 +508,7 @@ void OpenGLDrawingContext::StartNewDraw() void OpenGLDrawingContext::Clear(DrawPixelInfo& dpi, uint8_t paletteIndex) { - FillRect( - dpi, paletteIndex, dpi.ScreenX(), dpi.ScreenY(), dpi.ScreenX() + dpi.ScreenWidth(), dpi.ScreenY() + dpi.ScreenHeight()); + FillRect(dpi, paletteIndex, dpi.x, dpi.y, dpi.x + dpi.width, dpi.y + dpi.height); } void OpenGLDrawingContext::FillRect( @@ -517,10 +516,10 @@ void OpenGLDrawingContext::FillRect( { const ScreenRect clip = CalculateClipping(dpi); - left += clip.GetLeft() - dpi.ScreenX(); - top += clip.GetTop() - dpi.ScreenY(); - right += clip.GetLeft() - dpi.ScreenX(); - bottom += clip.GetTop() - dpi.ScreenY(); + left += clip.GetLeft() - dpi.x; + top += clip.GetTop() - dpi.y; + right += clip.GetLeft() - dpi.x; + bottom += clip.GetTop() - dpi.y; DrawRectCommand& command = _commandBuffers.rects.allocate(); @@ -552,10 +551,10 @@ void OpenGLDrawingContext::FilterRect( { const ScreenRect clip = CalculateClipping(dpi); - left += clip.GetLeft() - dpi.ScreenX(); - top += clip.GetTop() - dpi.ScreenY(); - right += clip.GetLeft() - dpi.ScreenX(); - bottom += clip.GetTop() - dpi.ScreenY(); + left += clip.GetLeft() - dpi.x; + top += clip.GetTop() - dpi.y; + right += clip.GetLeft() - dpi.x; + bottom += clip.GetTop() - dpi.y; DrawRectCommand& command = _commandBuffers.transparent.allocate(); @@ -593,8 +592,8 @@ uint8_t OpenGLDrawingContext::ComputeOutCode( // based on: https://en.wikipedia.org/wiki/Cohen%E2%80%93Sutherland_algorithm bool OpenGLDrawingContext::CohenSutherlandLineClip(ScreenLine& line, const DrawPixelInfo& dpi) { - ScreenCoordsXY topLeft = { dpi.ScreenX(), dpi.ScreenY() }; - ScreenCoordsXY bottomRight = { dpi.ScreenX() + dpi.ScreenWidth() - 1, dpi.ScreenY() + dpi.ScreenHeight() - 1 }; + ScreenCoordsXY topLeft = { dpi.x, dpi.y }; + ScreenCoordsXY bottomRight = { dpi.x + dpi.width - 1, dpi.y + dpi.height - 1 }; uint8_t outcode1 = ComputeOutCode(line.Point1, topLeft, bottomRight); uint8_t outcode2 = ComputeOutCode(line.Point2, topLeft, bottomRight); @@ -666,10 +665,10 @@ void OpenGLDrawingContext::DrawLine(DrawPixelInfo& dpi, uint32_t colour, const S DrawLineCommand& command = _commandBuffers.lines.allocate(); const ScreenRect clip = CalculateClipping(dpi); - const int32_t x1 = trimmedLine.GetX1() - dpi.ScreenX() + clip.GetLeft(); - const int32_t y1 = trimmedLine.GetY1() - dpi.ScreenY() + clip.GetTop(); - const int32_t x2 = trimmedLine.GetX2() - dpi.ScreenX() + clip.GetLeft(); - const int32_t y2 = trimmedLine.GetY2() - dpi.ScreenY() + clip.GetTop(); + const int32_t x1 = trimmedLine.GetX1() - dpi.x + clip.GetLeft(); + const int32_t y1 = trimmedLine.GetY1() - dpi.y + clip.GetTop(); + const int32_t x2 = trimmedLine.GetX2() - dpi.x + clip.GetLeft(); + const int32_t y2 = trimmedLine.GetY2() - dpi.y + clip.GetTop(); command.bounds = { x1, y1, x2, y2 }; command.colour = colour & 0xFF; @@ -690,10 +689,10 @@ void OpenGLDrawingContext::DrawSprite(DrawPixelInfo& dpi, const ImageId imageId, { DrawPixelInfo zoomedDPI; zoomedDPI.bits = dpi.bits; - zoomedDPI.SetX(dpi.ScreenX()); - zoomedDPI.SetY(dpi.ScreenY()); - zoomedDPI.SetHeight(dpi.ScreenHeight()); - zoomedDPI.SetWidth(dpi.ScreenWidth()); + zoomedDPI.x = dpi.x; + zoomedDPI.y = dpi.y; + zoomedDPI.height = dpi.height; + zoomedDPI.width = dpi.width; zoomedDPI.pitch = dpi.pitch; zoomedDPI.zoom_level = dpi.zoom_level - 1; DrawSprite(zoomedDPI, imageId.WithIndex(imageId.GetIndex() - g1Element->zoomed_offset), x >> 1, y >> 1); @@ -749,10 +748,10 @@ void OpenGLDrawingContext::DrawSprite(DrawPixelInfo& dpi, const ImageId imageId, bottom = dpi.zoom_level.ApplyInversedTo(bottom); const ScreenRect clip = CalculateClipping(dpi); - left += clip.GetLeft() - dpi.ScreenX(); - top += clip.GetTop() - dpi.ScreenY(); - right += clip.GetLeft() - dpi.ScreenX(); - bottom += clip.GetTop() - dpi.ScreenY(); + left += clip.GetLeft() - dpi.x; + top += clip.GetTop() - dpi.y; + right += clip.GetLeft() - dpi.x; + bottom += clip.GetTop() - dpi.y; const auto texture = _textureCache->GetOrLoadImageTexture(imageId); @@ -858,10 +857,10 @@ void OpenGLDrawingContext::DrawSpriteRawMasked( bottom = dpi.zoom_level.ApplyInversedTo(bottom); const ScreenRect clip = CalculateClipping(dpi); - left += clip.GetLeft() - dpi.ScreenX(); - top += clip.GetTop() - dpi.ScreenY(); - right += clip.GetLeft() - dpi.ScreenX(); - bottom += clip.GetTop() - dpi.ScreenY(); + left += clip.GetLeft() - dpi.x; + top += clip.GetTop() - dpi.y; + right += clip.GetLeft() - dpi.x; + bottom += clip.GetTop() - dpi.y; DrawRectCommand& command = _commandBuffers.rects.allocate(); @@ -907,10 +906,10 @@ void OpenGLDrawingContext::DrawSpriteSolid(DrawPixelInfo& dpi, const ImageId ima } const ScreenRect clip = CalculateClipping(dpi); - left += clip.GetLeft() - dpi.ScreenX(); - top += clip.GetTop() - dpi.ScreenY(); - right += clip.GetLeft() - dpi.ScreenX(); - bottom += clip.GetTop() - dpi.ScreenY(); + left += clip.GetLeft() - dpi.x; + top += clip.GetTop() - dpi.y; + right += clip.GetLeft() - dpi.x; + bottom += clip.GetTop() - dpi.y; DrawRectCommand& command = _commandBuffers.rects.allocate(); @@ -956,10 +955,10 @@ void OpenGLDrawingContext::DrawGlyph(DrawPixelInfo& dpi, const ImageId image, in bottom = dpi.zoom_level.ApplyInversedTo(bottom); const ScreenRect clip = CalculateClipping(dpi); - left += clip.GetLeft() - dpi.ScreenX(); - top += clip.GetTop() - dpi.ScreenY(); - right += clip.GetLeft() - dpi.ScreenX(); - bottom += clip.GetTop() - dpi.ScreenY(); + left += clip.GetLeft() - dpi.x; + top += clip.GetTop() - dpi.y; + right += clip.GetLeft() - dpi.x; + bottom += clip.GetTop() - dpi.y; DrawRectCommand& command = _commandBuffers.rects.allocate(); @@ -1009,10 +1008,10 @@ void OpenGLDrawingContext::DrawTTFBitmap( } const ScreenRect clip = CalculateClipping(dpi); - left += clip.GetLeft() - dpi.ScreenX(); - top += clip.GetTop() - dpi.ScreenY(); - right += clip.GetLeft() - dpi.ScreenX(); - bottom += clip.GetTop() - dpi.ScreenY(); + left += clip.GetLeft() - dpi.x; + top += clip.GetTop() - dpi.y; + right += clip.GetLeft() - dpi.x; + bottom += clip.GetTop() - dpi.y; if (info->flags & TEXT_DRAW_FLAG_OUTLINE) { @@ -1143,7 +1142,7 @@ void OpenGLDrawingContext::HandleTransparency() _commandBuffers.transparent.clear(); } -ScreenRect OpenGLDrawingContext::CalculateClipping(const DrawPixelInfo& dpi) +ScreenRect OpenGLDrawingContext::CalculateClipping(const DrawPixelInfo& dpi) const { // mber: Calculating the screen coordinates by dividing the difference between pointers like this is a dirty hack. // It's also quite slow. In future the drawing code needs to be refactored to avoid this somehow. @@ -1151,14 +1150,14 @@ ScreenRect OpenGLDrawingContext::CalculateClipping(const DrawPixelInfo& dpi) const int32_t bytesPerRow = screenDPI->LineStride(); const int32_t bitsOffset = static_cast(dpi.bits - screenDPI->bits); # ifndef NDEBUG - const ssize_t bitsSize = static_cast(screenDPI->ScreenHeight()) * static_cast(bytesPerRow); + const ssize_t bitsSize = static_cast(screenDPI->height) * static_cast(bytesPerRow); assert(static_cast(bitsOffset) < bitsSize && static_cast(bitsOffset) >= 0); # endif const int32_t left = bitsOffset % bytesPerRow; const int32_t top = bitsOffset / bytesPerRow; - const int32_t right = left + dpi.ScreenWidth(); - const int32_t bottom = top + dpi.ScreenHeight(); + const int32_t right = left + dpi.width; + const int32_t bottom = top + dpi.height; return { { left, top }, { right, bottom } }; } diff --git a/src/openrct2-ui/drawing/engines/opengl/OpenGLFramebuffer.cpp b/src/openrct2-ui/drawing/engines/opengl/OpenGLFramebuffer.cpp index f38980156a..f636647799 100644 --- a/src/openrct2-ui/drawing/engines/opengl/OpenGLFramebuffer.cpp +++ b/src/openrct2-ui/drawing/engines/opengl/OpenGLFramebuffer.cpp @@ -91,7 +91,7 @@ void OpenGLFramebuffer::BindRead() const void OpenGLFramebuffer::GetPixels(DrawPixelInfo& dpi) const { - assert(dpi.ScreenWidth() == _width && dpi.ScreenHeight() == _height); + assert(dpi.width == _width && dpi.height == _height); auto pixels = std::make_unique(_width * _height); glBindTexture(GL_TEXTURE_2D, _texture); diff --git a/src/openrct2-ui/drawing/engines/opengl/TextureCache.cpp b/src/openrct2-ui/drawing/engines/opengl/TextureCache.cpp index dab486f0a9..414e39b3b3 100644 --- a/src/openrct2-ui/drawing/engines/opengl/TextureCache.cpp +++ b/src/openrct2-ui/drawing/engines/opengl/TextureCache.cpp @@ -289,13 +289,13 @@ AtlasTextureInfo TextureCache::LoadImageTexture(const ImageId imageId) { DrawPixelInfo dpi = GetImageAsDPI(ImageId(imageId.GetIndex())); - auto cacheInfo = AllocateImage(dpi.ScreenWidth(), dpi.ScreenHeight()); + auto cacheInfo = AllocateImage(dpi.width, dpi.height); cacheInfo.image = imageId.GetIndex(); glBindTexture(GL_TEXTURE_2D_ARRAY, _atlasesTexture); glTexSubImage3D( - GL_TEXTURE_2D_ARRAY, 0, cacheInfo.bounds.x, cacheInfo.bounds.y, cacheInfo.index, dpi.ScreenWidth(), dpi.ScreenHeight(), - 1, GL_RED_INTEGER, GL_UNSIGNED_BYTE, dpi.bits); + GL_TEXTURE_2D_ARRAY, 0, cacheInfo.bounds.x, cacheInfo.bounds.y, cacheInfo.index, dpi.width, dpi.height, 1, + GL_RED_INTEGER, GL_UNSIGNED_BYTE, dpi.bits); DeleteDPI(dpi); @@ -306,13 +306,13 @@ AtlasTextureInfo TextureCache::LoadGlyphTexture(const ImageId imageId, const Pal { DrawPixelInfo dpi = GetGlyphAsDPI(imageId, paletteMap); - auto cacheInfo = AllocateImage(dpi.ScreenWidth(), dpi.ScreenHeight()); + auto cacheInfo = AllocateImage(dpi.width, dpi.height); cacheInfo.image = imageId.GetIndex(); glBindTexture(GL_TEXTURE_2D_ARRAY, _atlasesTexture); glTexSubImage3D( - GL_TEXTURE_2D_ARRAY, 0, cacheInfo.bounds.x, cacheInfo.bounds.y, cacheInfo.index, dpi.ScreenWidth(), dpi.ScreenHeight(), - 1, GL_RED_INTEGER, GL_UNSIGNED_BYTE, dpi.bits); + GL_TEXTURE_2D_ARRAY, 0, cacheInfo.bounds.x, cacheInfo.bounds.y, cacheInfo.index, dpi.width, dpi.height, 1, + GL_RED_INTEGER, GL_UNSIGNED_BYTE, dpi.bits); DeleteDPI(dpi); @@ -407,10 +407,10 @@ DrawPixelInfo TextureCache::CreateDPI(int32_t width, int32_t height) DrawPixelInfo dpi; dpi.bits = pixels8; dpi.pitch = 0; - dpi.SetX(0); - dpi.SetY(0); - dpi.SetWidth(width); - dpi.SetHeight(height); + dpi.x = 0; + dpi.y = 0; + dpi.width = width; + dpi.height = height; dpi.zoom_level = ZoomLevel{ 0 }; return dpi; } diff --git a/src/openrct2-ui/interface/Widget.cpp b/src/openrct2-ui/interface/Widget.cpp index f75878fae9..88b31421c9 100644 --- a/src/openrct2-ui/interface/Widget.cpp +++ b/src/openrct2-ui/interface/Widget.cpp @@ -715,22 +715,22 @@ namespace OpenRCT2::Ui DrawPixelInfo scroll_dpi = dpi; // Clip the scroll dpi against the outer dpi - int32_t cl = std::max(dpi.ScreenX(), topLeft.x); - int32_t ct = std::max(dpi.ScreenY(), topLeft.y); - int32_t cr = std::min(dpi.ScreenX() + dpi.ScreenWidth(), bottomRight.x); - int32_t cb = std::min(dpi.ScreenY() + dpi.ScreenHeight(), bottomRight.y); + int32_t cl = std::max(dpi.x, topLeft.x); + int32_t ct = std::max(dpi.y, topLeft.y); + int32_t cr = std::min(dpi.x + dpi.width, bottomRight.x); + int32_t cb = std::min(dpi.y + dpi.height, bottomRight.y); // Set the respective dpi attributes - scroll_dpi.SetX(cl - topLeft.x + scroll.contentOffsetX); - scroll_dpi.SetY(ct - topLeft.y + scroll.contentOffsetY); - scroll_dpi.SetWidth(cr - cl); - scroll_dpi.SetHeight(cb - ct); - scroll_dpi.bits += cl - dpi.ScreenX(); - scroll_dpi.bits += (ct - dpi.ScreenY()) * dpi.LineStride(); - scroll_dpi.pitch = dpi.LineStride() - scroll_dpi.ScreenWidth(); + scroll_dpi.x = cl - topLeft.x + scroll.contentOffsetX; + scroll_dpi.y = ct - topLeft.y + scroll.contentOffsetY; + scroll_dpi.width = cr - cl; + scroll_dpi.height = cb - ct; + scroll_dpi.bits += cl - dpi.x; + scroll_dpi.bits += (ct - dpi.y) * dpi.LineStride(); + scroll_dpi.pitch = dpi.LineStride() - scroll_dpi.width; // Draw the scroll contents - if (scroll_dpi.ScreenWidth() > 0 && scroll_dpi.ScreenHeight() > 0) + if (scroll_dpi.width > 0 && scroll_dpi.height > 0) w.OnScrollDraw(scrollIndex, scroll_dpi); } diff --git a/src/openrct2-ui/interface/Window.cpp b/src/openrct2-ui/interface/Window.cpp index ffbacd67ba..5d0a27e8aa 100644 --- a/src/openrct2-ui/interface/Window.cpp +++ b/src/openrct2-ui/interface/Window.cpp @@ -1323,11 +1323,9 @@ namespace OpenRCT2::Ui::Windows if (widget->IsVisible()) { // Check if widget is outside the draw region - if (w.windowPos.x + widget->left < dpi.ScreenX() + dpi.ScreenWidth() - && w.windowPos.x + widget->right >= dpi.ScreenX()) + if (w.windowPos.x + widget->left < dpi.x + dpi.width && w.windowPos.x + widget->right >= dpi.x) { - if (w.windowPos.y + widget->top < dpi.ScreenY() + dpi.ScreenHeight() - && w.windowPos.y + widget->bottom >= dpi.ScreenY()) + if (w.windowPos.y + widget->top < dpi.y + dpi.height && w.windowPos.y + widget->bottom >= dpi.y) { w.OnDrawWidget(widgetIndex, dpi); } diff --git a/src/openrct2-ui/scripting/CustomImages.cpp b/src/openrct2-ui/scripting/CustomImages.cpp index ca77885928..93d2854890 100644 --- a/src/openrct2-ui/scripting/CustomImages.cpp +++ b/src/openrct2-ui/scripting/CustomImages.cpp @@ -434,8 +434,8 @@ namespace OpenRCT2::Scripting auto drawingEngine = std::make_unique(GetContext()->GetUiContext()); DrawPixelInfo dpi; dpi.DrawingEngine = drawingEngine.get(); - dpi.SetWidth(size.width); - dpi.SetHeight(size.height); + dpi.width = size.width; + dpi.height = size.height; auto createNewImage = false; auto g1 = GfxGetG1Element(id); diff --git a/src/openrct2-ui/scripting/CustomListView.cpp b/src/openrct2-ui/scripting/CustomListView.cpp index e911ac87ee..e9486c434c 100644 --- a/src/openrct2-ui/scripting/CustomListView.cpp +++ b/src/openrct2-ui/scripting/CustomListView.cpp @@ -552,20 +552,18 @@ void CustomListView::MouseUp(const ScreenCoordsXY& pos) void CustomListView::Paint(WindowBase* w, DrawPixelInfo& dpi, const ScrollArea* scroll) const { auto paletteIndex = ColourMapA[w->colours[1].colour].mid_light; - GfxFillRect( - dpi, { { dpi.ScreenX(), dpi.ScreenY() }, { dpi.ScreenX() + dpi.ScreenWidth(), dpi.ScreenY() + dpi.ScreenHeight() } }, - paletteIndex); + GfxFillRect(dpi, { { dpi.x, dpi.y }, { dpi.x + dpi.width, dpi.y + dpi.height } }, paletteIndex); int32_t y = ShowColumnHeaders ? COLUMN_HEADER_HEIGHT : 0; for (size_t i = 0; i < Items.size(); i++) { - if (y > dpi.ScreenY() + dpi.ScreenHeight()) + if (y > dpi.y + dpi.height) { // Past the scroll view area break; } - if (y + kListRowHeight >= dpi.ScreenY()) + if (y + kListRowHeight >= dpi.y) { const auto& itemIndex = static_cast(SortedItems[i]); const auto& item = Items[itemIndex]; @@ -585,19 +583,19 @@ void CustomListView::Paint(WindowBase* w, DrawPixelInfo& dpi, const ScrollArea* if (isSelected) { GfxFilterRect( - dpi, { { dpi.ScreenX(), y }, { dpi.ScreenX() + dpi.ScreenWidth(), y + (kListRowHeight - 1) } }, + dpi, { { dpi.x, y }, { dpi.x + dpi.width, y + (kListRowHeight - 1) } }, FilterPaletteID::PaletteDarken2); } else if (isHighlighted) { GfxFilterRect( - dpi, { { dpi.ScreenX(), y }, { dpi.ScreenX() + dpi.ScreenWidth(), y + (kListRowHeight - 1) } }, + dpi, { { dpi.x, y }, { dpi.x + dpi.width, y + (kListRowHeight - 1) } }, FilterPaletteID::PaletteDarken2); } else if (isStriped) { GfxFillRect( - dpi, { { dpi.ScreenX(), y }, { dpi.ScreenX() + dpi.ScreenWidth(), y + (kListRowHeight - 1) } }, + dpi, { { dpi.x, y }, { dpi.x + dpi.width, y + (kListRowHeight - 1) } }, ColourMapA[w->colours[1].colour].lighter | 0x1000000); } @@ -643,7 +641,7 @@ void CustomListView::Paint(WindowBase* w, DrawPixelInfo& dpi, const ScrollArea* y = scroll->contentOffsetY; auto bgColour = ColourMapA[w->colours[1].colour].mid_light; - GfxFillRect(dpi, { { dpi.ScreenX(), y }, { dpi.ScreenX() + dpi.ScreenWidth(), y + 12 } }, bgColour); + GfxFillRect(dpi, { { dpi.x, y }, { dpi.x + dpi.width, y + 12 } }, bgColour); int32_t x = 0; for (int32_t j = 0; j < static_cast(Columns.size()); j++) diff --git a/src/openrct2-ui/scripting/ScGraphicsContext.hpp b/src/openrct2-ui/scripting/ScGraphicsContext.hpp index f69408e1cf..ad1ec00091 100644 --- a/src/openrct2-ui/scripting/ScGraphicsContext.hpp +++ b/src/openrct2-ui/scripting/ScGraphicsContext.hpp @@ -141,12 +141,12 @@ namespace OpenRCT2::Scripting int32_t width_get() const { - return _dpi.ScreenWidth(); + return _dpi.width; } int32_t height_get() const { - return _dpi.ScreenHeight(); + return _dpi.height; } DukValue getImage(uint32_t id) diff --git a/src/openrct2-ui/windows/AssetPacks.cpp b/src/openrct2-ui/windows/AssetPacks.cpp index 4b1c6efbe3..01029985c8 100644 --- a/src/openrct2-ui/windows/AssetPacks.cpp +++ b/src/openrct2-ui/windows/AssetPacks.cpp @@ -194,9 +194,9 @@ namespace OpenRCT2::Ui::Windows void OnScrollDraw(int32_t scrollIndex, DrawPixelInfo& dpi) override { - auto dpiCoords = ScreenCoordsXY{ dpi.ScreenX(), dpi.ScreenY() }; + auto dpiCoords = ScreenCoordsXY{ dpi.x, dpi.y }; GfxFillRect( - dpi, { dpiCoords, dpiCoords + ScreenCoordsXY{ dpi.ScreenWidth() - 1, dpi.ScreenHeight() - 1 } }, + dpi, { dpiCoords, dpiCoords + ScreenCoordsXY{ dpi.width - 1, dpi.height - 1 } }, ColourMapA[colours[1].colour].mid_light); auto assetPackManager = GetContext()->GetAssetPackManager(); @@ -207,9 +207,9 @@ namespace OpenRCT2::Ui::Windows auto y = 0; for (size_t i = 0; i <= numAssetPacks; i++) { - if (y > dpi.ScreenY() + dpi.ScreenHeight()) + if (y > dpi.y + dpi.height) break; - if (y + 11 < dpi.ScreenY()) + if (y + 11 < dpi.y) continue; auto isSelected = i == _selectedIndex; diff --git a/src/openrct2-ui/windows/Changelog.cpp b/src/openrct2-ui/windows/Changelog.cpp index 4c647607df..8c1e08bcb2 100644 --- a/src/openrct2-ui/windows/Changelog.cpp +++ b/src/openrct2-ui/windows/Changelog.cpp @@ -199,7 +199,7 @@ namespace OpenRCT2::Ui::Windows for (const auto& line : _changelogLines) { screenCoords.y += lineHeight; - if (screenCoords.y + lineHeight < dpi.ScreenY() || screenCoords.y >= dpi.ScreenY() + dpi.ScreenHeight()) + if (screenCoords.y + lineHeight < dpi.y || screenCoords.y >= dpi.y + dpi.height) continue; DrawText(dpi, screenCoords, { colours[0] }, line.c_str()); diff --git a/src/openrct2-ui/windows/EditorInventionsList.cpp b/src/openrct2-ui/windows/EditorInventionsList.cpp index 989738b165..abdd21b50c 100644 --- a/src/openrct2-ui/windows/EditorInventionsList.cpp +++ b/src/openrct2-ui/windows/EditorInventionsList.cpp @@ -287,7 +287,7 @@ namespace OpenRCT2::Ui::Windows for (const auto& researchItem : researchList) { itemY += kScrollableRowHeight; - if (itemY + kScrollableRowHeight < dpi.ScreenY() || itemY >= dpi.ScreenY() + dpi.ScreenHeight()) + if (itemY + kScrollableRowHeight < dpi.y || itemY >= dpi.y + dpi.height) continue; if (_selectedResearchItem == &researchItem) diff --git a/src/openrct2-ui/windows/EditorObjectSelection.cpp b/src/openrct2-ui/windows/EditorObjectSelection.cpp index af54a96e8b..31734e4414 100644 --- a/src/openrct2-ui/windows/EditorObjectSelection.cpp +++ b/src/openrct2-ui/windows/EditorObjectSelection.cpp @@ -725,8 +725,7 @@ namespace OpenRCT2::Ui::Windows for (size_t i = 0; i < _listItems.size(); i++) { const auto& listItem = _listItems[i]; - if (screenCoords.y + kScrollableRowHeight >= dpi.ScreenY() - && screenCoords.y <= dpi.ScreenY() + dpi.ScreenHeight()) + if (screenCoords.y + kScrollableRowHeight >= dpi.y && screenCoords.y <= dpi.y + dpi.height) { // Draw checkbox if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) && !(*listItem.flags & 0x20)) diff --git a/src/openrct2-ui/windows/EditorObjectiveOptions.cpp b/src/openrct2-ui/windows/EditorObjectiveOptions.cpp index a6aa62f894..96e99a21f1 100644 --- a/src/openrct2-ui/windows/EditorObjectiveOptions.cpp +++ b/src/openrct2-ui/windows/EditorObjectiveOptions.cpp @@ -1145,17 +1145,13 @@ namespace OpenRCT2::Ui::Windows void OnScrollDrawRides(DrawPixelInfo& dpi, int32_t scrollIndex) { int32_t colour = ColourMapA[colours[1].colour].mid_light; - GfxFillRect( - dpi, - { { dpi.ScreenX(), dpi.ScreenY() }, - { dpi.ScreenX() + dpi.ScreenWidth() - 1, dpi.ScreenY() + dpi.ScreenHeight() - 1 } }, - colour); + GfxFillRect(dpi, { { dpi.x, dpi.y }, { dpi.x + dpi.width - 1, dpi.y + dpi.height - 1 } }, colour); for (int32_t i = 0; i < static_cast(_rideableRides.size()); i++) { int32_t y = i * 12; - if (y + 12 < dpi.ScreenY() || y >= dpi.ScreenY() + dpi.ScreenHeight()) + if (y + 12 < dpi.y || y >= dpi.y + dpi.height) continue; // Checkbox diff --git a/src/openrct2-ui/windows/Guest.cpp b/src/openrct2-ui/windows/Guest.cpp index 3af21288cb..3a0242438a 100644 --- a/src/openrct2-ui/windows/Guest.cpp +++ b/src/openrct2-ui/windows/Guest.cpp @@ -1331,11 +1331,7 @@ namespace OpenRCT2::Ui::Windows void OnScrollDrawRides(int32_t scrollIndex, DrawPixelInfo& dpi) { auto colour = ColourMapA[colours[1].colour].mid_light; - GfxFillRect( - dpi, - { { dpi.ScreenX(), dpi.ScreenY() }, - { dpi.ScreenX() + dpi.ScreenWidth() - 1, dpi.ScreenY() + dpi.ScreenHeight() - 1 } }, - colour); + GfxFillRect(dpi, { { dpi.x, dpi.y }, { dpi.x + dpi.width - 1, dpi.y + dpi.height - 1 } }, colour); for (int32_t listIndex = 0; listIndex < static_cast(_riddenRides.size()); listIndex++) { diff --git a/src/openrct2-ui/windows/GuestList.cpp b/src/openrct2-ui/windows/GuestList.cpp index 82b63aeaab..8b46fbf4ce 100644 --- a/src/openrct2-ui/windows/GuestList.cpp +++ b/src/openrct2-ui/windows/GuestList.cpp @@ -595,9 +595,7 @@ namespace OpenRCT2::Ui::Windows void OnScrollDraw(int32_t scrollIndex, DrawPixelInfo& dpi) override { GfxFillRect( - dpi, - { { dpi.ScreenX(), dpi.ScreenY() }, - { dpi.ScreenX() + dpi.ScreenWidth() - 1, dpi.ScreenY() + dpi.ScreenHeight() - 1 } }, + dpi, { { dpi.x, dpi.y }, { dpi.x + dpi.width - 1, dpi.y + dpi.height - 1 } }, ColourMapA[colours[1].colour].mid_light); switch (_selectedTab) { @@ -671,8 +669,8 @@ namespace OpenRCT2::Ui::Windows for (const auto& guestItem : _guestList) { // Check if y is beyond the scroll control - if (y + kScrollableRowHeight + 1 >= -0x7FFF && y + kScrollableRowHeight + 1 > dpi.ScreenY() && y < 0x7FFF - && y < dpi.ScreenY() + dpi.ScreenHeight()) + if (y + kScrollableRowHeight + 1 >= -0x7FFF && y + kScrollableRowHeight + 1 > dpi.y && y < 0x7FFF + && y < dpi.y + dpi.height) { // Highlight backcolour and text colour (format) StringId format = STR_BLACK_STRING; @@ -738,10 +736,10 @@ namespace OpenRCT2::Ui::Windows for (auto& group : _groups) { // Check if y is beyond the scroll control - if (y + SUMMARISED_GUEST_ROW_HEIGHT + 1 >= dpi.ScreenY()) + if (y + SUMMARISED_GUEST_ROW_HEIGHT + 1 >= dpi.y) { // Check if y is beyond the scroll control - if (y >= dpi.ScreenY() + dpi.ScreenHeight()) + if (y >= dpi.y + dpi.height) break; // Highlight backcolour and text colour (format) diff --git a/src/openrct2-ui/windows/LoadSave.cpp b/src/openrct2-ui/windows/LoadSave.cpp index a7cabbc8fb..58b7ec134c 100644 --- a/src/openrct2-ui/windows/LoadSave.cpp +++ b/src/openrct2-ui/windows/LoadSave.cpp @@ -977,9 +977,7 @@ namespace OpenRCT2::Ui::Windows void OnScrollDraw(int32_t scrollIndex, DrawPixelInfo& dpi) override { GfxFillRect( - dpi, - { { dpi.ScreenX(), dpi.ScreenY() }, - { dpi.ScreenX() + dpi.ScreenWidth() - 1, dpi.ScreenY() + dpi.ScreenHeight() - 1 } }, + dpi, { { dpi.x, dpi.y }, { dpi.x + dpi.width - 1, dpi.y + dpi.height - 1 } }, ColourMapA[colours[1].colour].mid_light); const int32_t listWidth = widgets[WIDX_SCROLL].width(); const int32_t dateAnchor = widgets[WIDX_SORT_DATE].left + maxDateWidth + DATE_TIME_GAP; @@ -987,10 +985,10 @@ namespace OpenRCT2::Ui::Windows for (int32_t i = 0; i < no_list_items; i++) { int32_t y = i * kScrollableRowHeight; - if (y > dpi.ScreenY() + dpi.ScreenHeight()) + if (y > dpi.y + dpi.height) break; - if (y + kScrollableRowHeight < dpi.ScreenY()) + if (y + kScrollableRowHeight < dpi.y) continue; StringId stringId = STR_BLACK_STRING; diff --git a/src/openrct2-ui/windows/Multiplayer.cpp b/src/openrct2-ui/windows/Multiplayer.cpp index 0e6afbcb32..d92b4d6844 100644 --- a/src/openrct2-ui/windows/Multiplayer.cpp +++ b/src/openrct2-ui/windows/Multiplayer.cpp @@ -749,12 +749,12 @@ namespace OpenRCT2::Ui::Windows for (int32_t player = firstPlayerInList; player < NetworkGetNumPlayers(); player++) { - if (screenCoords.y > dpi.ScreenY() + dpi.ScreenHeight()) + if (screenCoords.y > dpi.y + dpi.height) { break; } - if (screenCoords.y + kScrollableRowHeight + 1 >= dpi.ScreenY()) + if (screenCoords.y + kScrollableRowHeight + 1 >= dpi.y) { thread_local std::string _buffer; _buffer.reserve(512); @@ -887,9 +887,9 @@ namespace OpenRCT2::Ui::Windows { auto screenCoords = ScreenCoordsXY{ 0, 0 }; - auto dpiCoords = ScreenCoordsXY{ dpi.ScreenX(), dpi.ScreenY() }; + auto dpiCoords = ScreenCoordsXY{ dpi.x, dpi.y }; GfxFillRect( - dpi, { dpiCoords, dpiCoords + ScreenCoordsXY{ dpi.ScreenWidth() - 1, dpi.ScreenHeight() - 1 } }, + dpi, { dpiCoords, dpiCoords + ScreenCoordsXY{ dpi.width - 1, dpi.height - 1 } }, ColourMapA[colours[1].colour].mid_light); for (int32_t i = 0; i < NetworkGetNumActions(); i++) @@ -900,12 +900,12 @@ namespace OpenRCT2::Ui::Windows dpi, { 0, screenCoords.y, 800, screenCoords.y + kScrollableRowHeight - 1 }, FilterPaletteID::PaletteDarken1); } - if (screenCoords.y > dpi.ScreenY() + dpi.ScreenHeight()) + if (screenCoords.y > dpi.y + dpi.height) { break; } - if (screenCoords.y + kScrollableRowHeight + 1 >= dpi.ScreenY()) + if (screenCoords.y + kScrollableRowHeight + 1 >= dpi.y) { int32_t groupindex = NetworkGetGroupIndex(_selectedGroup); if (groupindex != -1) diff --git a/src/openrct2-ui/windows/News.cpp b/src/openrct2-ui/windows/News.cpp index 6608965556..e07083b641 100644 --- a/src/openrct2-ui/windows/News.cpp +++ b/src/openrct2-ui/windows/News.cpp @@ -182,9 +182,9 @@ namespace OpenRCT2::Ui::Windows for (const auto& newsItem : GetGameState().NewsItems.GetArchived()) { - if (y >= dpi.ScreenY() + dpi.ScreenHeight()) + if (y >= dpi.y + dpi.height) break; - if (y + itemHeight < dpi.ScreenY()) + if (y + itemHeight < dpi.y) { y += itemHeight; i++; diff --git a/src/openrct2-ui/windows/ObjectLoadError.cpp b/src/openrct2-ui/windows/ObjectLoadError.cpp index 2a2c24bc12..27ccc76fa7 100644 --- a/src/openrct2-ui/windows/ObjectLoadError.cpp +++ b/src/openrct2-ui/windows/ObjectLoadError.cpp @@ -508,9 +508,9 @@ namespace OpenRCT2::Ui::Windows void OnScrollDraw(const int32_t scrollIndex, DrawPixelInfo& dpi) override { - auto dpiCoords = ScreenCoordsXY{ dpi.ScreenX(), dpi.ScreenY() }; + auto dpiCoords = ScreenCoordsXY{ dpi.x, dpi.y }; GfxFillRect( - dpi, { dpiCoords, dpiCoords + ScreenCoordsXY{ dpi.ScreenWidth() - 1, dpi.ScreenHeight() - 1 } }, + dpi, { dpiCoords, dpiCoords + ScreenCoordsXY{ dpi.width - 1, dpi.height - 1 } }, ColourMapA[colours[1].colour].mid_light); const int32_t listWidth = widgets[WIDX_SCROLL].width(); @@ -518,10 +518,10 @@ namespace OpenRCT2::Ui::Windows { ScreenCoordsXY screenCoords; screenCoords.y = i * kScrollableRowHeight; - if (screenCoords.y > dpi.ScreenY() + dpi.ScreenHeight()) + if (screenCoords.y > dpi.y + dpi.height) break; - if (screenCoords.y + kScrollableRowHeight < dpi.ScreenY()) + if (screenCoords.y + kScrollableRowHeight < dpi.y) continue; const auto screenRect = ScreenRect{ { 0, screenCoords.y }, diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index 6d3293eb48..f042db69e1 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -1285,8 +1285,8 @@ namespace OpenRCT2::Ui::Windows clipDPI.zoom_level = ZoomLevel{ 1 }; screenCoords.x *= 2; screenCoords.y *= 2; - clipDPI.SetX(clipDPI.ScreenX() * 2); - clipDPI.SetY(clipDPI.ScreenY() * 2); + clipDPI.x *= 2; + clipDPI.y *= 2; } // For any suspended rides, move image higher in the vehicle tab on the rides window @@ -2976,10 +2976,7 @@ namespace OpenRCT2::Ui::Windows const auto* rideEntry = ride->GetRideEntry(); // Background - GfxFillRect( - dpi, - { { dpi.ScreenX(), dpi.ScreenY() }, { dpi.ScreenX() + dpi.ScreenWidth(), dpi.ScreenY() + dpi.ScreenHeight() } }, - PALETTE_INDEX_12); + GfxFillRect(dpi, { { dpi.x, dpi.y }, { dpi.x + dpi.width, dpi.y + dpi.height } }, PALETTE_INDEX_12); Widget* widget = &widgets[WIDX_VEHICLE_TRAINS_PREVIEW]; int32_t startX = std::max(2, (widget->width() - ((ride->NumTrains - 1) * 36)) / 2 - 25); @@ -4973,11 +4970,7 @@ namespace OpenRCT2::Ui::Windows auto vehicleColour = RideGetVehicleColour(*ride, _vehicleIndex); // Background colour - GfxFillRect( - dpi, - { { dpi.ScreenX(), dpi.ScreenY() }, - { dpi.ScreenX() + dpi.ScreenWidth() - 1, dpi.ScreenY() + dpi.ScreenHeight() - 1 } }, - PALETTE_INDEX_12); + GfxFillRect(dpi, { { dpi.x, dpi.y }, { dpi.x + dpi.width - 1, dpi.y + dpi.height - 1 } }, PALETTE_INDEX_12); // ? auto screenCoords = ScreenCoordsXY{ vehiclePreviewWidget->width() / 2, vehiclePreviewWidget->height() - 15 }; @@ -5333,7 +5326,7 @@ namespace OpenRCT2::Ui::Windows for (size_t i = 0; i < musicObj->GetTrackCount(); i++) { // Skip invisible items - if (y + kScrollableRowHeight < dpi.ScreenY() || y > dpi.ScreenY() + dpi.ScreenHeight()) + if (y + kScrollableRowHeight < dpi.y || y > dpi.y + dpi.height) { y += kScrollableRowHeight; continue; @@ -6138,12 +6131,12 @@ namespace OpenRCT2::Ui::Windows const uint8_t darkColour = ColourMapA[COLOUR_SATURATED_GREEN].mid_dark; int32_t time = 0; - for (int32_t x = 0; x < dpi.ScreenX() + dpi.ScreenWidth(); x += 80) + for (int32_t x = 0; x < dpi.x + dpi.width; x += 80) { - if (x + 80 >= dpi.ScreenX()) + if (x + 80 >= dpi.x) { - auto coord1 = ScreenCoordsXY{ x, dpi.ScreenY() }; - auto coord2 = ScreenCoordsXY{ x, dpi.ScreenY() + dpi.ScreenHeight() - 1 }; + auto coord1 = ScreenCoordsXY{ x, dpi.y }; + auto coord2 = ScreenCoordsXY{ x, dpi.y + dpi.height - 1 }; GfxFillRect(dpi, { coord1, coord2 }, lightColour); GfxFillRect(dpi, { coord1 + ScreenCoordsXY{ 16, 0 }, coord2 + ScreenCoordsXY{ 16, 0 } }, darkColour); GfxFillRect(dpi, { coord1 + ScreenCoordsXY{ 32, 0 }, coord2 + ScreenCoordsXY{ 32, 0 } }, darkColour); @@ -6170,7 +6163,7 @@ namespace OpenRCT2::Ui::Windows { // Minor / major line int32_t colour = yUnit == 0 ? lightColour : darkColour; - GfxFillRect(dpi, { { dpi.ScreenX(), y }, { dpi.ScreenX() + dpi.ScreenWidth() - 1, y } }, colour); + GfxFillRect(dpi, { { dpi.x, y }, { dpi.x + dpi.width - 1, y } }, colour); int16_t scaled_yUnit = yUnit; // Scale modifier @@ -6185,23 +6178,23 @@ namespace OpenRCT2::Ui::Windows // Time marks time = 0; - for (int32_t x = 0; x < dpi.ScreenX() + dpi.ScreenWidth(); x += 80) + for (int32_t x = 0; x < dpi.x + dpi.width; x += 80) { auto ft = Formatter(); ft.Add(time); - if (x + 80 >= dpi.ScreenX()) + if (x + 80 >= dpi.x) DrawTextBasic(dpi, { x + 2, 1 }, STR_RIDE_STATS_TIME, ft, { FontStyle::Small }); time += 5; } // Plot - int32_t x = dpi.ScreenX(); + int32_t x = dpi.x; int32_t firstPoint, secondPoint; // Uses the force limits (used to draw extreme G's in red on measurement tab) to determine if line should be drawn // red. int32_t intensityThresholdPositive = 0; int32_t intensityThresholdNegative = 0; - for (int32_t graphWidth = 0; graphWidth < dpi.ScreenWidth(); graphWidth++, x++) + for (int32_t graphWidth = 0; graphWidth < dpi.width; graphWidth++, x++) { if (x < 0 || x >= measurement->num_items - 1) continue; diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index ccc420cc0c..549fc37e22 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -2616,8 +2616,8 @@ namespace OpenRCT2::Ui::Windows const ScreenCoordsXY rotatedScreenCoords = Translate3DTo2DWithZ(GetCurrentRotation(), mapCoords); - dpi.SetX(dpi.ScreenX() + rotatedScreenCoords.x - widgetWidth / 2); - dpi.SetY(dpi.ScreenY() + rotatedScreenCoords.y - widgetHeight / 2 - 16); + dpi.x += rotatedScreenCoords.x - widgetWidth / 2; + dpi.y += rotatedScreenCoords.y - widgetHeight / 2 - 16; DrawTrackPieceHelper(dpi, rideIndex, trackType, trackDirection, liftHillAndInvertedState, { 4096, 4096 }, 1024); } diff --git a/src/openrct2-ui/windows/RideList.cpp b/src/openrct2-ui/windows/RideList.cpp index 4a3bdd98c8..7ebd900152 100644 --- a/src/openrct2-ui/windows/RideList.cpp +++ b/src/openrct2-ui/windows/RideList.cpp @@ -540,9 +540,9 @@ namespace OpenRCT2::Ui::Windows */ void OnScrollDraw(int32_t scrollIndex, DrawPixelInfo& dpi) override { - auto dpiCoords = ScreenCoordsXY{ dpi.ScreenX(), dpi.ScreenY() }; + auto dpiCoords = ScreenCoordsXY{ dpi.x, dpi.y }; GfxFillRect( - dpi, { dpiCoords, dpiCoords + ScreenCoordsXY{ dpi.ScreenWidth(), dpi.ScreenHeight() } }, + dpi, { dpiCoords, dpiCoords + ScreenCoordsXY{ dpi.width, dpi.height } }, ColourMapA[colours[1].colour].mid_light); auto y = 0; diff --git a/src/openrct2-ui/windows/ScenarioSelect.cpp b/src/openrct2-ui/windows/ScenarioSelect.cpp index a903943569..bdfda4915f 100644 --- a/src/openrct2-ui/windows/ScenarioSelect.cpp +++ b/src/openrct2-ui/windows/ScenarioSelect.cpp @@ -415,7 +415,7 @@ namespace OpenRCT2::Ui::Windows int32_t y = 0; for (const auto& listItem : _listItems) { - if (y > dpi.ScreenY() + dpi.ScreenHeight()) + if (y > dpi.y + dpi.height) { continue; } diff --git a/src/openrct2-ui/windows/ServerList.cpp b/src/openrct2-ui/windows/ServerList.cpp index 509574b21e..3b7e3e9c4d 100644 --- a/src/openrct2-ui/windows/ServerList.cpp +++ b/src/openrct2-ui/windows/ServerList.cpp @@ -347,7 +347,7 @@ namespace OpenRCT2::Ui::Windows screenCoords.y = 0; for (int32_t i = 0; i < no_list_items; i++) { - if (screenCoords.y >= dpi.ScreenY() + dpi.ScreenHeight()) + if (screenCoords.y >= dpi.y + dpi.height) continue; const auto& serverDetails = _serverList.GetServer(i); diff --git a/src/openrct2-ui/windows/ShortcutKeys.cpp b/src/openrct2-ui/windows/ShortcutKeys.cpp index 3458bfe84e..6c22e68c61 100644 --- a/src/openrct2-ui/windows/ShortcutKeys.cpp +++ b/src/openrct2-ui/windows/ShortcutKeys.cpp @@ -305,9 +305,9 @@ namespace OpenRCT2::Ui::Windows void OnScrollDraw(int32_t scrollIndex, DrawPixelInfo& dpi) override { - auto dpiCoords = ScreenCoordsXY{ dpi.ScreenX(), dpi.ScreenY() }; + auto dpiCoords = ScreenCoordsXY{ dpi.x, dpi.y }; GfxFillRect( - dpi, { dpiCoords, dpiCoords + ScreenCoordsXY{ dpi.ScreenWidth() - 1, dpi.ScreenHeight() - 1 } }, + dpi, { dpiCoords, dpiCoords + ScreenCoordsXY{ dpi.width - 1, dpi.height - 1 } }, ColourMapA[colours[1].colour].mid_light); // TODO: the line below is a workaround for what is presumably a bug with dpi->width @@ -317,12 +317,12 @@ namespace OpenRCT2::Ui::Windows for (size_t i = 0; i < _list.size(); ++i) { auto y = static_cast(1 + i * kScrollableRowHeight); - if (y > dpi.ScreenY() + dpi.ScreenHeight()) + if (y > dpi.y + dpi.height) { break; } - if (y + kScrollableRowHeight < dpi.ScreenY()) + if (y + kScrollableRowHeight < dpi.y) { continue; } diff --git a/src/openrct2-ui/windows/StaffList.cpp b/src/openrct2-ui/windows/StaffList.cpp index 573e6baf04..26bac9eb69 100644 --- a/src/openrct2-ui/windows/StaffList.cpp +++ b/src/openrct2-ui/windows/StaffList.cpp @@ -381,9 +381,9 @@ namespace OpenRCT2::Ui::Windows void OnScrollDraw(int32_t scrollIndex, DrawPixelInfo& dpi) override { - auto dpiCoords = ScreenCoordsXY{ dpi.ScreenX(), dpi.ScreenY() }; + auto dpiCoords = ScreenCoordsXY{ dpi.x, dpi.y }; GfxFillRect( - dpi, { dpiCoords, dpiCoords + ScreenCoordsXY{ dpi.ScreenWidth() - 1, dpi.ScreenHeight() - 1 } }, + dpi, { dpiCoords, dpiCoords + ScreenCoordsXY{ dpi.width - 1, dpi.height - 1 } }, ColourMapA[colours[1].colour].mid_light); // How much space do we have for the name and action columns? (Discount scroll area and icons.) @@ -396,12 +396,12 @@ namespace OpenRCT2::Ui::Windows size_t i = 0; for (const auto& entry : _staffList) { - if (y > dpi.ScreenY() + dpi.ScreenHeight()) + if (y > dpi.y + dpi.height) { break; } - if (y + 11 >= dpi.ScreenY()) + if (y + 11 >= dpi.y) { const auto* peep = GetEntity(entry.Id); if (peep == nullptr) diff --git a/src/openrct2-ui/windows/Themes.cpp b/src/openrct2-ui/windows/Themes.cpp index 9e22e19af1..b8ec8e72fa 100644 --- a/src/openrct2-ui/windows/Themes.cpp +++ b/src/openrct2-ui/windows/Themes.cpp @@ -761,11 +761,11 @@ namespace OpenRCT2::Ui::Windows screenCoords.y = 0; for (int32_t i = 0; i < GetColourSchemeTabCount(); i++) { - if (screenCoords.y > dpi.ScreenY() + dpi.ScreenHeight()) + if (screenCoords.y > dpi.y + dpi.height) { break; } - if (screenCoords.y + _row_height >= dpi.ScreenY()) + if (screenCoords.y + _row_height >= dpi.y) { if (i + 1 < GetColourSchemeTabCount()) { diff --git a/src/openrct2-ui/windows/TileInspector.cpp b/src/openrct2-ui/windows/TileInspector.cpp index 50e386a717..cf84cf44a7 100644 --- a/src/openrct2-ui/windows/TileInspector.cpp +++ b/src/openrct2-ui/windows/TileInspector.cpp @@ -1575,9 +1575,7 @@ static uint64_t PageDisabledWidgets[] = { { const int32_t listWidth = widgets[WIDX_LIST].width(); GfxFillRect( - dpi, - { { dpi.ScreenX(), dpi.ScreenY() }, - { dpi.ScreenX() + dpi.ScreenWidth() - 1, dpi.ScreenY() + dpi.ScreenHeight() - 1 } }, + dpi, { { dpi.x, dpi.y }, { dpi.x + dpi.width - 1, dpi.y + dpi.height - 1 } }, ColourMapA[colours[1].colour].mid_light); // Show usage hint when nothing is selected diff --git a/src/openrct2-ui/windows/TrackList.cpp b/src/openrct2-ui/windows/TrackList.cpp index e63e5e403f..5abb15d3f1 100644 --- a/src/openrct2-ui/windows/TrackList.cpp +++ b/src/openrct2-ui/windows/TrackList.cpp @@ -710,8 +710,7 @@ namespace OpenRCT2::Ui::Windows for (auto i : _filteredTrackIds) { - if (screenCoords.y + kScrollableRowHeight >= dpi.ScreenY() - && screenCoords.y < dpi.ScreenY() + dpi.ScreenHeight()) + if (screenCoords.y + kScrollableRowHeight >= dpi.y && screenCoords.y < dpi.y + dpi.height) { StringId stringId; if (listIndex == static_cast(selected_list_item)) diff --git a/src/openrct2/CommandLineSprite.cpp b/src/openrct2/CommandLineSprite.cpp index 2431aa7fa6..3fb3d96830 100644 --- a/src/openrct2/CommandLineSprite.cpp +++ b/src/openrct2/CommandLineSprite.cpp @@ -195,10 +195,10 @@ static bool SpriteImageExport(const G1Element& spriteElement, u8string_view outP DrawPixelInfo dpi; dpi.bits = pixels; - dpi.SetX(0); - dpi.SetY(0); - dpi.SetWidth(spriteElement.width); - dpi.SetHeight(spriteElement.height); + dpi.x = 0; + dpi.y = 0; + dpi.width = spriteElement.width; + dpi.height = spriteElement.height; dpi.pitch = 0; dpi.zoom_level = ZoomLevel{ 0 }; @@ -211,8 +211,8 @@ static bool SpriteImageExport(const G1Element& spriteElement, u8string_view outP try { Image image; - image.Width = dpi.ScreenWidth(); - image.Height = dpi.ScreenHeight(); + image.Width = dpi.width; + image.Height = dpi.height; image.Depth = 8; image.Stride = dpi.LineStride(); image.Palette = std::make_unique(StandardPalette); diff --git a/src/openrct2/drawing/Drawing.Sprite.cpp b/src/openrct2/drawing/Drawing.Sprite.cpp index 4c280f637f..0c57839d34 100644 --- a/src/openrct2/drawing/Drawing.Sprite.cpp +++ b/src/openrct2/drawing/Drawing.Sprite.cpp @@ -548,10 +548,10 @@ void FASTCALL GfxDrawSpritePaletteSetSoftware( { DrawPixelInfo zoomed_dpi = dpi; zoomed_dpi.bits = dpi.bits; - zoomed_dpi.SetX(dpi.ScreenX()); - zoomed_dpi.SetY(dpi.ScreenY()); - zoomed_dpi.SetHeight(dpi.ScreenHeight()); - zoomed_dpi.SetWidth(dpi.ScreenWidth()); + zoomed_dpi.x = dpi.x; + zoomed_dpi.y = dpi.y; + zoomed_dpi.height = dpi.height; + zoomed_dpi.width = dpi.width; zoomed_dpi.pitch = dpi.pitch; zoomed_dpi.zoom_level = zoomLevel - 1; @@ -577,16 +577,14 @@ void FASTCALL GfxDrawSpritePaletteSetSoftware( ScreenCoordsXY spriteBottomLeft{ zoomLevel.ApplyInversedTo(coords.x + g1->x_offset + g1->width), zoomLevel.ApplyInversedTo(coords.y + g1->y_offset + g1->height) }; - const int32_t width = std::min(spriteBottomLeft.x, dpi.ScreenX() + dpi.ScreenWidth()) - - std::max(spriteTopLeft.x, dpi.ScreenX()); - const int32_t height = std::min(spriteBottomLeft.y, dpi.ScreenY() + dpi.ScreenHeight()) - - std::max(spriteTopLeft.y, dpi.ScreenY()); + const int32_t width = std::min(spriteBottomLeft.x, dpi.x + dpi.width) - std::max(spriteTopLeft.x, dpi.x); + const int32_t height = std::min(spriteBottomLeft.y, dpi.y + dpi.height) - std::max(spriteTopLeft.y, dpi.y); if (width <= 0 || height <= 0) return; - const int32_t offsetX = dpi.ScreenX() - spriteTopLeft.x; - const int32_t offsetY = dpi.ScreenY() - spriteTopLeft.y; + const int32_t offsetX = dpi.x - spriteTopLeft.x; + const int32_t offsetY = dpi.y - spriteTopLeft.y; const int32_t srcX = std::max(0, offsetX); const int32_t srcY = std::max(0, offsetY); uint8_t* dst = dpi.bits + std::max(0, -offsetX) + std::max(0, -offsetY) * dpi.LineStride(); @@ -763,17 +761,17 @@ void FASTCALL GfxDrawSpriteRawMaskedSoftware( offsetCoords.x = zoom.ApplyInversedTo(offsetCoords.x); offsetCoords.y = zoom.ApplyInversedTo(offsetCoords.y); - left = std::max(dpi.ScreenX(), offsetCoords.x); - top = std::max(dpi.ScreenY(), offsetCoords.y); - right = std::min(dpi.ScreenX() + dpi.ScreenWidth(), offsetCoords.x + width); - bottom = std::min(dpi.ScreenY() + dpi.ScreenHeight(), offsetCoords.y + height); + left = std::max(dpi.x, offsetCoords.x); + top = std::max(dpi.y, offsetCoords.y); + right = std::min(dpi.x + dpi.width, offsetCoords.x + width); + bottom = std::min(dpi.y + dpi.height, offsetCoords.y + height); width = right - left; height = bottom - top; if (width < 0 || height < 0) return; - uint8_t* dst = dpi.bits + (left - dpi.ScreenX()) + ((top - dpi.ScreenY()) * dpi.LineStride()); + uint8_t* dst = dpi.bits + (left - dpi.x) + ((top - dpi.y) * dpi.LineStride()); int32_t skipX = left - offsetCoords.x; int32_t skipY = top - offsetCoords.y; if (zoom < ZoomLevel{ 0 }) diff --git a/src/openrct2/drawing/Drawing.String.cpp b/src/openrct2/drawing/Drawing.String.cpp index a3cbec1d41..4ad0215b06 100644 --- a/src/openrct2/drawing/Drawing.String.cpp +++ b/src/openrct2/drawing/Drawing.String.cpp @@ -325,7 +325,7 @@ static void ColourCharacterWindow(colour_t colour, const uint16_t* current_font_ void DrawStringCentredRaw( DrawPixelInfo& dpi, const ScreenCoordsXY& coords, int32_t numLines, const utf8* text, FontStyle fontStyle) { - ScreenCoordsXY screenCoords(dpi.ScreenX(), dpi.ScreenY()); + ScreenCoordsXY screenCoords(dpi.x, dpi.y); DrawText(dpi, screenCoords, { COLOUR_BLACK, fontStyle }, ""); screenCoords = coords; @@ -422,7 +422,7 @@ void DrawNewsTicker( int32_t ticks) { int32_t numLines, lineHeight, lineY; - ScreenCoordsXY screenCoords(dpi.ScreenX(), dpi.ScreenY()); + ScreenCoordsXY screenCoords(dpi.x, dpi.y); DrawText(dpi, screenCoords, { colour }, ""); diff --git a/src/openrct2/drawing/Drawing.cpp b/src/openrct2/drawing/Drawing.cpp index 5708294ab5..f59f4946dc 100644 --- a/src/openrct2/drawing/Drawing.cpp +++ b/src/openrct2/drawing/Drawing.cpp @@ -799,41 +799,41 @@ bool ClipDrawPixelInfo(DrawPixelInfo& dst, DrawPixelInfo& src, const ScreenCoord dst = src; dst.zoom_level = ZoomLevel{ 0 }; - if (coords.x > dst.ScreenX()) + if (coords.x > dst.x) { - uint16_t clippedFromLeft = coords.x - dst.ScreenX(); - dst.SetWidth(dst.ScreenWidth() - clippedFromLeft); - dst.SetX(coords.x); + uint16_t clippedFromLeft = coords.x - dst.x; + dst.width -= clippedFromLeft; + dst.x = coords.x; dst.pitch += clippedFromLeft; dst.bits += clippedFromLeft; } - int32_t stickOutWidth = dst.ScreenX() + dst.ScreenWidth() - right; + int32_t stickOutWidth = dst.x + dst.width - right; if (stickOutWidth > 0) { - dst.SetWidth(dst.ScreenWidth() - stickOutWidth); + dst.width -= stickOutWidth; dst.pitch += stickOutWidth; } - if (coords.y > dst.ScreenY()) + if (coords.y > dst.y) { - uint16_t clippedFromTop = coords.y - dst.ScreenY(); - dst.SetHeight(dst.ScreenHeight() - clippedFromTop); - dst.SetY(coords.y); + uint16_t clippedFromTop = coords.y - dst.y; + dst.height -= clippedFromTop; + dst.y = coords.y; uint32_t bitsPlus = dst.LineStride() * clippedFromTop; dst.bits += bitsPlus; } - int32_t bp = dst.ScreenY() + dst.ScreenHeight() - bottom; + int32_t bp = dst.y + dst.height - bottom; if (bp > 0) { - dst.SetHeight(dst.ScreenHeight() - bp); + dst.height -= bp; } - if (dst.ScreenWidth() > 0 && dst.ScreenHeight() > 0) + if (dst.width > 0 && dst.height > 0) { - dst.SetX(dst.ScreenX() - coords.x); - dst.SetY(dst.ScreenY() - coords.y); + dst.x -= coords.x; + dst.y -= coords.y; return true; } @@ -1140,36 +1140,25 @@ void ToggleWindowedMode() Config::Save(); } -void DebugDPI(const DrawPixelInfo& dpi) +void DebugDPI(DrawPixelInfo& dpi) { - DrawPixelInfo unzoomed = dpi; - unzoomed.zoom_level = ZoomLevel{ 0 }; - unzoomed.SetX(dpi.ScreenX()); - unzoomed.SetY(dpi.ScreenY()); - unzoomed.SetWidth(dpi.ScreenWidth()); - unzoomed.SetHeight(dpi.ScreenHeight()); + ScreenCoordsXY topLeft = { dpi.x, dpi.y }; + ScreenCoordsXY bottomRight = { dpi.x + dpi.width - 1, dpi.y + dpi.height - 1 }; + ScreenCoordsXY topRight = { dpi.x + dpi.width - 1, dpi.y }; + ScreenCoordsXY bottomLeft = { dpi.x, dpi.y + dpi.height - 1 }; - ScreenCoordsXY topLeft = { unzoomed.ScreenX(), unzoomed.ScreenY() }; - ScreenCoordsXY bottomRight = { unzoomed.ScreenX() + unzoomed.ScreenWidth() - 1, - unzoomed.ScreenY() + unzoomed.ScreenHeight() - 1 }; - ScreenCoordsXY topRight = { unzoomed.ScreenX() + unzoomed.ScreenWidth() - 1, unzoomed.ScreenY() }; - ScreenCoordsXY bottomLeft = { unzoomed.ScreenX(), unzoomed.ScreenY() + unzoomed.ScreenHeight() - 1 }; + GfxDrawLine(dpi, { topLeft, bottomRight }, PALETTE_INDEX_136); + GfxDrawLine(dpi, { bottomLeft, topRight }, PALETTE_INDEX_136); + GfxDrawLine(dpi, { topLeft, topRight }, PALETTE_INDEX_129); + GfxDrawLine(dpi, { topRight, bottomRight }, PALETTE_INDEX_129); + GfxDrawLine(dpi, { bottomLeft, bottomRight }, PALETTE_INDEX_129); + GfxDrawLine(dpi, { topLeft, bottomLeft }, PALETTE_INDEX_129); - GfxDrawLine(unzoomed, { topLeft, bottomRight }, PALETTE_INDEX_136); - GfxDrawLine(unzoomed, { bottomLeft, topRight }, PALETTE_INDEX_136); - GfxDrawLine(unzoomed, { topLeft, topRight }, PALETTE_INDEX_129); - GfxDrawLine(unzoomed, { topRight, bottomRight }, PALETTE_INDEX_129); - GfxDrawLine(unzoomed, { bottomLeft, bottomRight }, PALETTE_INDEX_129); - GfxDrawLine(unzoomed, { topLeft, bottomLeft }, PALETTE_INDEX_129); + GfxDrawLine(dpi, { topLeft, topLeft + ScreenCoordsXY{ 4, 0 } }, PALETTE_INDEX_136); - GfxDrawLine(unzoomed, { topLeft, topLeft + ScreenCoordsXY{ 4, 0 } }, PALETTE_INDEX_136); + const auto str = std::to_string(dpi.x); + DrawText(dpi, ScreenCoordsXY{ dpi.x, dpi.y }, { COLOUR_WHITE, FontStyle::Tiny }, str.c_str()); - const auto str = std::to_string(dpi.ScreenX()); - DrawText( - unzoomed, ScreenCoordsXY{ unzoomed.ScreenX(), unzoomed.ScreenY() }, { COLOUR_WHITE, FontStyle::Tiny }, str.c_str()); - - const auto str2 = std::to_string(dpi.ScreenY()); - DrawText( - unzoomed, ScreenCoordsXY{ unzoomed.ScreenX(), unzoomed.ScreenY() + 6 }, { COLOUR_WHITE, FontStyle::Tiny }, - str2.c_str()); + const auto str2 = std::to_string(dpi.y); + DrawText(dpi, ScreenCoordsXY{ dpi.x, dpi.y + 6 }, { COLOUR_WHITE, FontStyle::Tiny }, str2.c_str()); } \ No newline at end of file diff --git a/src/openrct2/drawing/Drawing.h b/src/openrct2/drawing/Drawing.h index a3e1342291..b225349944 100644 --- a/src/openrct2/drawing/Drawing.h +++ b/src/openrct2/drawing/Drawing.h @@ -108,14 +108,10 @@ struct Gx struct DrawPixelInfo { uint8_t* bits{}; - -private: int32_t x{}; int32_t y{}; int32_t width{}; int32_t height{}; - -public: int32_t pitch{}; // note: this is actually (pitch - width) ZoomLevel zoom_level{}; @@ -127,61 +123,27 @@ public: uint8_t* GetBitsOffset(const ScreenCoordsXY& pos) const; DrawPixelInfo Crop(const ScreenCoordsXY& pos, const ScreenSize& size) const; - constexpr int32_t WorldX() const + [[nodiscard]] constexpr int32_t WorldX() const { return zoom_level.ApplyTo(x); } - constexpr int32_t WorldY() const + [[nodiscard]] constexpr int32_t WorldY() const { return zoom_level.ApplyTo(y); } - constexpr int32_t WorldWidth() const + [[nodiscard]] constexpr int32_t WorldWidth() const { return zoom_level.ApplyTo(width); } - constexpr int32_t WorldHeight() const + [[nodiscard]] constexpr int32_t WorldHeight() const { return zoom_level.ApplyTo(height); } - constexpr int32_t ScreenX() const - { - return x; - } - constexpr int32_t ScreenY() const - { - return y; - } - constexpr int32_t ScreenWidth() const - { - return width; - } - constexpr int32_t ScreenHeight() const - { - return height; - } - - constexpr int32_t LineStride() const + [[nodiscard]] constexpr int32_t LineStride() const { return width + pitch; } - - void SetX(const int32_t value) - { - x = value; - } - void SetY(const int32_t value) - { - y = value; - } - void SetWidth(const int32_t value) - { - width = value; - } - void SetHeight(const int32_t value) - { - height = value; - } }; struct TextDrawInfo @@ -685,6 +647,6 @@ void UpdatePaletteEffects(); void RefreshVideo(); void ToggleWindowedMode(); -void DebugDPI(const DrawPixelInfo& dpi); +void DebugDPI(DrawPixelInfo& dpi); #include "NewDrawing.h" diff --git a/src/openrct2/drawing/LightFX.cpp b/src/openrct2/drawing/LightFX.cpp index f5c22b3166..bb63a73c84 100644 --- a/src/openrct2/drawing/LightFX.cpp +++ b/src/openrct2/drawing/LightFX.cpp @@ -182,8 +182,8 @@ void LightFXInit() void LightFXUpdateBuffers(DrawPixelInfo& info) { - _light_rendered_buffer_front = realloc(_light_rendered_buffer_front, info.ScreenWidth() * info.ScreenHeight()); - _light_rendered_buffer_back = realloc(_light_rendered_buffer_back, info.ScreenWidth() * info.ScreenHeight()); + _light_rendered_buffer_front = realloc(_light_rendered_buffer_front, info.width * info.height); + _light_rendered_buffer_back = realloc(_light_rendered_buffer_back, info.width * info.height); _pixelInfo = info; } @@ -205,8 +205,8 @@ void LightFXPrepareLightList() posOnScreenX = _current_view_zoom_front.ApplyInversedTo(posOnScreenX); posOnScreenY = _current_view_zoom_front.ApplyInversedTo(posOnScreenY); - if ((posOnScreenX < -128) || (posOnScreenY < -128) || (posOnScreenX > _pixelInfo.ScreenWidth() + 128) - || (posOnScreenY > _pixelInfo.ScreenHeight() + 128)) + if ((posOnScreenX < -128) || (posOnScreenY < -128) || (posOnScreenX > _pixelInfo.width + 128) + || (posOnScreenY > _pixelInfo.height + 128)) { entry->Type = LightType::None; continue; @@ -300,12 +300,12 @@ void LightFXPrepareLightList() // based on GetMapCoordinatesFromPosWindow DrawPixelInfo dpi; dpi.zoom_level = _current_view_zoom_front; - dpi.SetX(_current_view_zoom_front.ApplyInversedTo( - entry->ViewCoords.x + offsetPattern[0 + pat * 2] / mapFrontDiv)); - dpi.SetY(_current_view_zoom_front.ApplyInversedTo( - entry->ViewCoords.y + offsetPattern[1 + pat * 2] / mapFrontDiv)); - dpi.SetHeight(1); - dpi.SetWidth(1); + dpi.x = _current_view_zoom_front.ApplyInversedTo( + entry->ViewCoords.x + offsetPattern[0 + pat * 2] / mapFrontDiv); + dpi.y = _current_view_zoom_front.ApplyInversedTo( + entry->ViewCoords.y + offsetPattern[1 + pat * 2] / mapFrontDiv); + dpi.height = 1; + dpi.width = 1; PaintSession* session = PaintSessionAlloc(dpi, w->viewport->flags, w->viewport->rotation); PaintSessionGenerate(*session); @@ -451,7 +451,7 @@ void LightFXRenderLightsToFrontBuffer() return; } - std::memset(_light_rendered_buffer_front, 0, _pixelInfo.ScreenWidth() * _pixelInfo.ScreenHeight()); + std::memset(_light_rendered_buffer_front, 0, _pixelInfo.width * _pixelInfo.height); _lightPolution_back = 0; @@ -526,8 +526,8 @@ void LightFXRenderLightsToFrontBuffer() } // Clamp the reads to be no larger than the buffer size - bufReadHeight = std::min(_pixelInfo.ScreenHeight(), bufReadHeight); - bufReadWidth = std::min(_pixelInfo.ScreenWidth(), bufReadWidth); + bufReadHeight = std::min(_pixelInfo.height, bufReadHeight); + bufReadWidth = std::min(_pixelInfo.width, bufReadWidth); bufWriteX = inRectCentreX - bufReadWidth / 2; bufWriteY = inRectCentreY - bufReadHeight / 2; @@ -555,7 +555,7 @@ void LightFXRenderLightsToFrontBuffer() } else { - bufWriteBase += bufWriteY * _pixelInfo.ScreenWidth(); + bufWriteBase += bufWriteY * _pixelInfo.width; } if (bufWriteHeight <= 0) @@ -564,13 +564,13 @@ void LightFXRenderLightsToFrontBuffer() int32_t rightEdge = bufWriteX + bufWriteWidth; int32_t bottomEdge = bufWriteY + bufWriteHeight; - if (rightEdge > _pixelInfo.ScreenWidth()) + if (rightEdge > _pixelInfo.width) { - bufWriteWidth -= rightEdge - _pixelInfo.ScreenWidth(); + bufWriteWidth -= rightEdge - _pixelInfo.width; } - if (bottomEdge > _pixelInfo.ScreenHeight()) + if (bottomEdge > _pixelInfo.height) { - bufWriteHeight -= bottomEdge - _pixelInfo.ScreenHeight(); + bufWriteHeight -= bottomEdge - _pixelInfo.height; } if (bufWriteWidth <= 0) @@ -581,7 +581,7 @@ void LightFXRenderLightsToFrontBuffer() _lightPolution_back += (bufWriteWidth * bufWriteHeight) / 256; bufReadSkip = bufReadWidth - bufWriteWidth; - bufWriteSkip = _pixelInfo.ScreenWidth() - bufWriteWidth; + bufWriteSkip = _pixelInfo.width - bufWriteWidth; if (entry->LightIntensity == 0xFF) { diff --git a/src/openrct2/drawing/Line.cpp b/src/openrct2/drawing/Line.cpp index ca7291605a..a3208b30da 100644 --- a/src/openrct2/drawing/Line.cpp +++ b/src/openrct2/drawing/Line.cpp @@ -18,10 +18,10 @@ */ static void GfxDrawLineOnBuffer(DrawPixelInfo& dpi, char colour, const ScreenCoordsXY& coords, int32_t no_pixels) { - ScreenCoordsXY offset{ coords.x - dpi.ScreenX(), coords.y - dpi.ScreenY() }; + ScreenCoordsXY offset{ coords.x - dpi.x, coords.y - dpi.y }; - const int32_t width = dpi.ScreenWidth(); - const int32_t height = dpi.ScreenHeight(); + const int32_t width = dpi.width; + const int32_t height = dpi.height; // Check to make sure point is in the y range if (offset.y < 0) @@ -82,22 +82,22 @@ void GfxDrawLineSoftware(DrawPixelInfo& dpi, const ScreenLine& line, int32_t col int32_t y1 = zoom.ApplyInversedTo(line.GetY1()); int32_t y2 = zoom.ApplyInversedTo(line.GetY2()); // Check to make sure the line is within the drawing area - if ((x1 < dpi.ScreenX()) && (x2 < dpi.ScreenX())) + if ((x1 < dpi.x) && (x2 < dpi.x)) { return; } - if ((y1 < dpi.ScreenY()) && (y2 < dpi.ScreenY())) + if ((y1 < dpi.y) && (y2 < dpi.y)) { return; } - if ((x1 > (dpi.ScreenX() + dpi.ScreenWidth())) && (x2 > (dpi.ScreenX() + dpi.ScreenWidth()))) + if ((x1 > (dpi.x + dpi.width)) && (x2 > (dpi.x + dpi.width))) { return; } - if ((y1 > (dpi.ScreenY() + dpi.ScreenHeight())) && (y2 > (dpi.ScreenY() + dpi.ScreenHeight()))) + if ((y1 > (dpi.y + dpi.height)) && (y2 > (dpi.y + dpi.height))) { return; } diff --git a/src/openrct2/drawing/ScrollingText.cpp b/src/openrct2/drawing/ScrollingText.cpp index 9d4a5602fb..b1552f3f69 100644 --- a/src/openrct2/drawing/ScrollingText.cpp +++ b/src/openrct2/drawing/ScrollingText.cpp @@ -52,8 +52,8 @@ static void ScrollingTextInitialiseCharacterBitmaps(uint32_t glyphStart, uint16_ uint8_t drawingSurface[64]; DrawPixelInfo dpi; dpi.bits = reinterpret_cast(&drawingSurface); - dpi.SetWidth(8); - dpi.SetHeight(8); + dpi.width = 8; + dpi.height = 8; for (int32_t i = 0; i < count; i++) { diff --git a/src/openrct2/drawing/X8DrawingEngine.cpp b/src/openrct2/drawing/X8DrawingEngine.cpp index 1829da8c2c..57d7e6fc26 100644 --- a/src/openrct2/drawing/X8DrawingEngine.cpp +++ b/src/openrct2/drawing/X8DrawingEngine.cpp @@ -94,7 +94,7 @@ void X8WeatherDrawer::Restore(DrawPixelInfo& dpi) { if (_weatherPixelsCount > 0) { - uint32_t numPixels = dpi.LineStride() * dpi.ScreenHeight(); + uint32_t numPixels = dpi.LineStride() * dpi.height; uint8_t* bits = dpi.bits; for (uint32_t i = 0; i < _weatherPixelsCount; i++) { @@ -331,10 +331,10 @@ void X8DrawingEngine::ConfigureBits(uint32_t width, uint32_t height, uint32_t pi DrawPixelInfo* dpi = &_bitsDPI; dpi->bits = _bits; - dpi->SetX(0); - dpi->SetY(0); - dpi->SetWidth(width); - dpi->SetHeight(height); + dpi->x = 0; + dpi->y = 0; + dpi->width = width; + dpi->height = height; dpi->pitch = _pitch - width; ConfigureDirtyGrid(); @@ -463,8 +463,8 @@ X8DrawingContext::X8DrawingContext(X8DrawingEngine* engine) void X8DrawingContext::Clear(DrawPixelInfo& dpi, uint8_t paletteIndex) { - int32_t w = dpi.ScreenWidth(); - int32_t h = dpi.ScreenHeight(); + int32_t w = dpi.width; + int32_t h = dpi.height; uint8_t* ptr = dpi.bits; for (int32_t y = 0; y < h; y++) @@ -529,41 +529,41 @@ void X8DrawingContext::FillRect(DrawPixelInfo& dpi, uint32_t colour, int32_t lef return; if (top > bottom) return; - if (dpi.ScreenX() > right) + if (dpi.x > right) return; - if (left >= dpi.ScreenX() + dpi.ScreenWidth()) + if (left >= dpi.x + dpi.width) return; - if (bottom < dpi.ScreenY()) + if (bottom < dpi.y) return; - if (top >= dpi.ScreenY() + dpi.ScreenHeight()) + if (top >= dpi.y + dpi.height) return; uint16_t crossPattern = 0; - int32_t startX = left - dpi.ScreenX(); + int32_t startX = left - dpi.x; if (startX < 0) { crossPattern ^= startX; startX = 0; } - int32_t endX = right - dpi.ScreenX() + 1; - if (endX > dpi.ScreenWidth()) + int32_t endX = right - dpi.x + 1; + if (endX > dpi.width) { - endX = dpi.ScreenWidth(); + endX = dpi.width; } - int32_t startY = top - dpi.ScreenY(); + int32_t startY = top - dpi.y; if (startY < 0) { crossPattern ^= startY; startY = 0; } - int32_t endY = bottom - dpi.ScreenY() + 1; - if (endY > dpi.ScreenHeight()) + int32_t endY = bottom - dpi.y + 1; + if (endY > dpi.height) { - endY = dpi.ScreenHeight(); + endY = dpi.height; } int32_t width = endX - startX; @@ -603,11 +603,11 @@ void X8DrawingContext::FillRect(DrawPixelInfo& dpi, uint32_t colour, int32_t lef // The pattern loops every 15 lines this is which // part the pattern is on. - int32_t patternY = (startY + dpi.ScreenY()) % 16; + int32_t patternY = (startY + dpi.y) % 16; // The pattern loops every 15 pixels this is which // part the pattern is on. - int32_t startPatternX = (startX + dpi.ScreenX()) % 16; + int32_t startPatternX = (startX + dpi.x) % 16; int32_t patternX = startPatternX; const uint16_t* patternsrc = Patterns[colour >> 28]; // or possibly uint8_t)[esi*4] ? @@ -649,37 +649,37 @@ void X8DrawingContext::FilterRect( return; if (top > bottom) return; - if (dpi.ScreenX() > right) + if (dpi.x > right) return; - if (left >= dpi.ScreenX() + dpi.ScreenWidth()) + if (left >= dpi.x + dpi.width) return; - if (bottom < dpi.ScreenY()) + if (bottom < dpi.y) return; - if (top >= dpi.ScreenY() + dpi.ScreenHeight()) + if (top >= dpi.y + dpi.height) return; - int32_t startX = left - dpi.ScreenX(); + int32_t startX = left - dpi.x; if (startX < 0) { startX = 0; } - int32_t endX = right - dpi.ScreenX() + 1; - if (endX > dpi.ScreenWidth()) + int32_t endX = right - dpi.x + 1; + if (endX > dpi.width) { - endX = dpi.ScreenWidth(); + endX = dpi.width; } - int32_t startY = top - dpi.ScreenY(); + int32_t startY = top - dpi.y; if (startY < 0) { startY = 0; } - int32_t endY = bottom - dpi.ScreenY() + 1; - if (endY > dpi.ScreenHeight()) + int32_t endY = bottom - dpi.y + 1; + if (endY > dpi.height) { - endY = dpi.ScreenHeight(); + endY = dpi.height; } int32_t width = endX - startX; @@ -750,14 +750,14 @@ static void DrawTTFBitmapInternal( int32_t width = surfaceWidth; int32_t height = surface->h; - const int32_t overflowX = (dpi.ScreenX() + dpi.ScreenWidth()) - (x + width); - const int32_t overflowY = (dpi.ScreenY() + dpi.ScreenHeight()) - (y + height); + const int32_t overflowX = (dpi.x + dpi.width) - (x + width); + const int32_t overflowY = (dpi.y + dpi.height) - (y + height); if (overflowX < 0) width += overflowX; if (overflowY < 0) height += overflowY; - int32_t skipX = x - dpi.ScreenX(); - int32_t skipY = y - dpi.ScreenY(); + int32_t skipX = x - dpi.x; + int32_t skipY = y - dpi.y; auto src = static_cast(surface->pixels); uint8_t* dst = dpi.bits; diff --git a/src/openrct2/interface/Screenshot.cpp b/src/openrct2/interface/Screenshot.cpp index f95599b0e4..19ab1d27e3 100644 --- a/src/openrct2/interface/Screenshot.cpp +++ b/src/openrct2/interface/Screenshot.cpp @@ -55,12 +55,12 @@ uint8_t gScreenshotCountdown = 0; static bool WriteDpiToFile(std::string_view path, const DrawPixelInfo& dpi, const GamePalette& palette) { auto const pixels8 = dpi.bits; - auto const pixelsLen = dpi.LineStride() * dpi.ScreenHeight(); + auto const pixelsLen = dpi.LineStride() * dpi.height; try { Image image; - image.Width = dpi.ScreenWidth(); - image.Height = dpi.ScreenHeight(); + image.Width = dpi.width; + image.Height = dpi.height; image.Depth = 8; image.Stride = dpi.LineStride(); image.Palette = std::make_unique(palette); @@ -230,9 +230,9 @@ static int32_t GetTallestVisibleTileTop( static DrawPixelInfo CreateDPI(const Viewport& viewport) { DrawPixelInfo dpi; - dpi.SetWidth(viewport.width); - dpi.SetHeight(viewport.height); - dpi.bits = new (std::nothrow) uint8_t[dpi.ScreenWidth() * dpi.ScreenHeight()]; + dpi.width = viewport.width; + dpi.height = viewport.height; + dpi.bits = new (std::nothrow) uint8_t[dpi.width * dpi.height]; if (dpi.bits == nullptr) { throw std::runtime_error("Giant screenshot failed, unable to allocate memory for image."); @@ -240,7 +240,7 @@ static DrawPixelInfo CreateDPI(const Viewport& viewport) if (viewport.flags & VIEWPORT_FLAG_TRANSPARENT_BACKGROUND) { - std::memset(dpi.bits, PALETTE_INDEX_0, static_cast(dpi.ScreenWidth()) * dpi.ScreenHeight()); + std::memset(dpi.bits, PALETTE_INDEX_0, static_cast(dpi.width) * dpi.height); } return dpi; @@ -251,8 +251,8 @@ static void ReleaseDPI(DrawPixelInfo& dpi) if (dpi.bits != nullptr) delete[] dpi.bits; dpi.bits = nullptr; - dpi.SetWidth(0); - dpi.SetHeight(0); + dpi.width = 0; + dpi.height = 0; } static Viewport GetGiantViewport(int32_t rotation, ZoomLevel zoom) diff --git a/src/openrct2/interface/Viewport.cpp b/src/openrct2/interface/Viewport.cpp index 7009ad4eb3..8e4d4a8a37 100644 --- a/src/openrct2/interface/Viewport.cpp +++ b/src/openrct2/interface/Viewport.cpp @@ -907,13 +907,13 @@ void ViewportRender(DrawPixelInfo& dpi, const Viewport* viewport) if (viewport->flags & VIEWPORT_FLAG_RENDERING_INHIBITED) return; - if (dpi.ScreenX() + dpi.ScreenWidth() <= viewport->pos.x) + if (dpi.x + dpi.width <= viewport->pos.x) return; - if (dpi.ScreenY() + dpi.ScreenHeight() <= viewport->pos.y) + if (dpi.y + dpi.height <= viewport->pos.y) return; - if (dpi.ScreenX() >= viewport->pos.x + viewport->width) + if (dpi.x >= viewport->pos.x + viewport->width) return; - if (dpi.ScreenY() >= viewport->pos.y + viewport->height) + if (dpi.y >= viewport->pos.y + viewport->height) return; #ifdef DEBUG_SHOW_DIRTY_BOX @@ -983,23 +983,21 @@ static void ViewportPaint(const Viewport* viewport, DrawPixelInfo& dpi) { PROFILED_FUNCTION(); - const int32_t offsetX = dpi.ScreenX() - viewport->pos.x; - const int32_t offsetY = dpi.ScreenY() - viewport->pos.y; + const int32_t offsetX = dpi.x - viewport->pos.x; + const int32_t offsetY = dpi.y - viewport->pos.y; const int32_t worldX = viewport->zoom.ApplyInversedTo(viewport->viewPos.x) + std::max(0, offsetX); const int32_t worldY = viewport->zoom.ApplyInversedTo(viewport->viewPos.y) + std::max(0, offsetY); - const int32_t width = std::min(viewport->pos.x + viewport->width, dpi.ScreenX() + dpi.ScreenWidth()) - - std::max(viewport->pos.x, dpi.ScreenX()); - const int32_t height = std::min(viewport->pos.y + viewport->height, dpi.ScreenY() + dpi.ScreenHeight()) - - std::max(viewport->pos.y, dpi.ScreenY()); + const int32_t width = std::min(viewport->pos.x + viewport->width, dpi.x + dpi.width) - std::max(viewport->pos.x, dpi.x); + const int32_t height = std::min(viewport->pos.y + viewport->height, dpi.y + dpi.height) - std::max(viewport->pos.y, dpi.y); DrawPixelInfo worldDpi; worldDpi.DrawingEngine = dpi.DrawingEngine; worldDpi.bits = dpi.bits + std::max(0, -offsetX) + std::max(0, -offsetY) * dpi.LineStride(); - worldDpi.SetX(worldX); - worldDpi.SetY(worldY); - worldDpi.SetWidth(width); - worldDpi.SetHeight(height); - worldDpi.pitch = dpi.LineStride() - worldDpi.ScreenWidth(); + worldDpi.x = worldX; + worldDpi.y = worldY; + worldDpi.width = width; + worldDpi.height = height; + worldDpi.pitch = dpi.LineStride() - worldDpi.width; worldDpi.zoom_level = viewport->zoom; _paintColumns.clear(); @@ -1021,8 +1019,8 @@ static void ViewportPaint(const Viewport* viewport, DrawPixelInfo& dpi) } const int32_t columnWidth = worldDpi.zoom_level.ApplyInversedTo(kCoordsXYStep); - const int32_t rightBorder = worldDpi.ScreenX() + worldDpi.ScreenWidth(); - const int32_t alignedX = Floor2(worldDpi.ScreenX(), columnWidth); + const int32_t rightBorder = worldDpi.x + worldDpi.width; + const int32_t alignedX = Floor2(worldDpi.x, columnWidth); // Generate and sort columns. for (int32_t x = alignedX; x < rightBorder; x += columnWidth) @@ -1031,23 +1029,23 @@ static void ViewportPaint(const Viewport* viewport, DrawPixelInfo& dpi) _paintColumns.push_back(session); DrawPixelInfo& columnDpi = session->DPI; - if (x >= columnDpi.ScreenX()) + if (x >= columnDpi.x) { - const int32_t leftPitch = x - columnDpi.ScreenX(); - columnDpi.SetWidth(columnDpi.ScreenWidth() - leftPitch); + const int32_t leftPitch = x - columnDpi.x; + columnDpi.width = columnDpi.width - leftPitch; columnDpi.bits += leftPitch; columnDpi.pitch += leftPitch; - columnDpi.SetX(x); + columnDpi.x = x; } - int32_t paintRight = columnDpi.ScreenX() + columnDpi.ScreenWidth(); + int32_t paintRight = columnDpi.x + columnDpi.width; if (paintRight >= x + columnWidth) { const int32_t rightPitch = paintRight - x - columnWidth; paintRight -= rightPitch; columnDpi.pitch += rightPitch; } - columnDpi.SetWidth(paintRight - columnDpi.ScreenX()); + columnDpi.width = paintRight - columnDpi.x; if (useMultithreading) { @@ -1093,10 +1091,10 @@ static void ViewportPaintWeatherGloom(DrawPixelInfo& dpi) auto paletteId = ClimateGetWeatherGloomPaletteId(GetGameState().ClimateCurrent); if (paletteId != FilterPaletteID::PaletteNull) { - auto x = dpi.ScreenX(); - auto y = dpi.ScreenY(); - auto w = dpi.ScreenWidth(); - auto h = dpi.ScreenHeight(); + auto x = dpi.x; + auto y = dpi.y; + auto w = dpi.width; + auto h = dpi.height; GfxFilterRect(dpi, ScreenRect(x, y, x + w, y + h), paletteId); } } @@ -1761,10 +1759,10 @@ InteractionInfo GetMapCoordinatesFromPosWindow(WindowBase* window, const ScreenC } DrawPixelInfo dpi; dpi.zoom_level = viewport->zoom; - dpi.SetX(viewport->zoom.ApplyInversedTo(viewLoc.x)); - dpi.SetY(viewport->zoom.ApplyInversedTo(viewLoc.y)); - dpi.SetHeight(1); - dpi.SetWidth(1); + dpi.x = viewport->zoom.ApplyInversedTo(viewLoc.x); + dpi.y = viewport->zoom.ApplyInversedTo(viewLoc.y); + dpi.height = 1; + dpi.width = 1; PaintSession* session = PaintSessionAlloc(dpi, viewport->flags, viewport->rotation); PaintSessionGenerate(*session); diff --git a/src/openrct2/interface/Window.cpp b/src/openrct2/interface/Window.cpp index 75d018f067..c67fcca795 100644 --- a/src/openrct2/interface/Window.cpp +++ b/src/openrct2/interface/Window.cpp @@ -1049,44 +1049,44 @@ static void WindowDrawSingle(DrawPixelInfo& dpi, WindowBase& w, int32_t left, in DrawPixelInfo copy = dpi; // Clamp left to 0 - int32_t overflow = left - copy.ScreenX(); + int32_t overflow = left - copy.x; if (overflow > 0) { - copy.SetX(copy.ScreenX() + overflow); - copy.SetWidth(copy.ScreenWidth() - overflow); - if (copy.ScreenWidth() <= 0) + copy.x += overflow; + copy.width -= overflow; + if (copy.width <= 0) return; copy.pitch += overflow; copy.bits += overflow; } // Clamp width to right - overflow = copy.ScreenX() + copy.ScreenWidth() - right; + overflow = copy.x + copy.width - right; if (overflow > 0) { - copy.SetWidth(copy.ScreenWidth() - overflow); - if (copy.ScreenWidth() <= 0) + copy.width -= overflow; + if (copy.width <= 0) return; copy.pitch += overflow; } // Clamp top to 0 - overflow = top - copy.ScreenY(); + overflow = top - copy.y; if (overflow > 0) { - copy.SetY(copy.ScreenY() + overflow); - copy.SetHeight(copy.ScreenHeight() - overflow); - if (copy.ScreenHeight() <= 0) + copy.y += overflow; + copy.height -= overflow; + if (copy.height <= 0) return; copy.bits += copy.LineStride() * overflow; } // Clamp height to bottom - overflow = copy.ScreenY() + copy.ScreenHeight() - bottom; + overflow = copy.y + copy.height - bottom; if (overflow > 0) { - copy.SetHeight(copy.ScreenHeight() - overflow); - if (copy.ScreenHeight() <= 0) + copy.height -= overflow; + if (copy.height <= 0) return; } diff --git a/src/openrct2/paint/Paint.Entity.cpp b/src/openrct2/paint/Paint.Entity.cpp index d5148d144d..aa5b3d7cfa 100644 --- a/src/openrct2/paint/Paint.Entity.cpp +++ b/src/openrct2/paint/Paint.Entity.cpp @@ -102,10 +102,10 @@ void EntityPaintSetup(PaintSession& session, const CoordsXY& pos) screenCoords + ScreenCoordsXY{ spr->SpriteData.Width, spr->SpriteData.HeightMax }); const ZoomLevel zoom = session.DPI.zoom_level; - if (session.DPI.ScreenY() + session.DPI.ScreenHeight() <= zoom.ApplyInversedTo(spriteRect.GetTop()) - || zoom.ApplyInversedTo(spriteRect.GetBottom()) <= session.DPI.ScreenY() - || session.DPI.ScreenX() + session.DPI.ScreenWidth() <= zoom.ApplyInversedTo(spriteRect.GetLeft()) - || zoom.ApplyInversedTo(spriteRect.GetRight()) <= session.DPI.ScreenX()) + if (session.DPI.y + session.DPI.height <= zoom.ApplyInversedTo(spriteRect.GetTop()) + || zoom.ApplyInversedTo(spriteRect.GetBottom()) <= session.DPI.y + || session.DPI.x + session.DPI.width <= zoom.ApplyInversedTo(spriteRect.GetLeft()) + || zoom.ApplyInversedTo(spriteRect.GetRight()) <= session.DPI.x) { continue; } diff --git a/src/openrct2/paint/Paint.cpp b/src/openrct2/paint/Paint.cpp index 1b2d720e6d..70919efbe3 100644 --- a/src/openrct2/paint/Paint.cpp +++ b/src/openrct2/paint/Paint.cpp @@ -126,13 +126,13 @@ static constexpr bool ImageWithinDPI(const ScreenCoordsXY& imagePos, const G1Ele } else { - if (zoom.ApplyInversedTo(right) <= dpi.ScreenX()) + if (zoom.ApplyInversedTo(right) <= dpi.x) return false; - if (zoom.ApplyInversedTo(top) <= dpi.ScreenY()) + if (zoom.ApplyInversedTo(top) <= dpi.y) return false; - if (zoom.ApplyInversedTo(left) >= dpi.ScreenX() + dpi.ScreenWidth()) + if (zoom.ApplyInversedTo(left) >= dpi.x + dpi.width) return false; - if (zoom.ApplyInversedTo(bottom) >= dpi.ScreenY() + dpi.ScreenHeight()) + if (zoom.ApplyInversedTo(bottom) >= dpi.y + dpi.height) return false; } return true; diff --git a/src/openrct2/ride/CarEntry.cpp b/src/openrct2/ride/CarEntry.cpp index 6e6952d8c9..460c385491 100644 --- a/src/openrct2/ride/CarEntry.cpp +++ b/src/openrct2/ride/CarEntry.cpp @@ -48,14 +48,15 @@ void CarEntrySetImageMaxSizes(CarEntry& carEntry, int32_t numImages) { uint8_t bitmap[200][200] = { 0 }; - DrawPixelInfo dpi; - dpi.zoom_level = ZoomLevel{ 0 }; - dpi.bits = reinterpret_cast(bitmap); - dpi.pitch = 0; - dpi.SetX(-100); - dpi.SetY(-100); - dpi.SetWidth(200); - dpi.SetHeight(200); + DrawPixelInfo dpi = { + /*.bits = */ reinterpret_cast(bitmap), + /*.x = */ -100, + /*.y = */ -100, + /*.width = */ 200, + /*.height = */ 200, + /*.pitch = */ 0, + /*.zoom_level = */ ZoomLevel{ 0 }, + }; for (int32_t i = 0; i < numImages; ++i) { diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index 847fb4eec0..a03cdba1d2 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -2117,10 +2117,10 @@ void TrackDesignDrawPreview(TrackDesign& td, uint8_t* pixels) view.flags = VIEWPORT_FLAG_HIDE_BASE | VIEWPORT_FLAG_HIDE_ENTITIES; DrawPixelInfo dpi; - dpi.SetX(0); - dpi.SetY(0); - dpi.SetWidth(370); - dpi.SetHeight(217); + dpi.x = 0; + dpi.y = 0; + dpi.width = 370; + dpi.height = 217; dpi.pitch = 0; dpi.bits = pixels;