From 609cde2304570f6bfca0ec7438f429756f654963 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sat, 22 Aug 2020 15:05:44 +0100 Subject: [PATCH] Fix drawing of money text when zoomed in --- .../engines/opengl/OpenGLDrawingEngine.cpp | 31 +++++++++++-------- src/openrct2/paint/Paint.cpp | 14 +-------- 2 files changed, 19 insertions(+), 26 deletions(-) diff --git a/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp b/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp index 2e0febc035..1f4c6443d6 100644 --- a/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp +++ b/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp @@ -887,15 +887,10 @@ void OpenGLDrawingContext::DrawGlyph(uint32_t image, int32_t x, int32_t y, const const auto texture = _textureCache->GetOrLoadGlyphTexture(image, palette); - int32_t drawOffsetX = g1Element->x_offset; - int32_t drawOffsetY = g1Element->y_offset; - int32_t drawWidth = static_cast(g1Element->width); - int32_t drawHeight = static_cast(g1Element->height); - - int32_t left = x + drawOffsetX; - int32_t top = y + drawOffsetY; - int32_t right = left + drawWidth; - int32_t bottom = top + drawHeight; + int32_t left = x + g1Element->x_offset; + int32_t top = y + g1Element->y_offset; + int32_t right = left + static_cast(g1Element->width); + int32_t bottom = top + static_cast(g1Element->height); if (left > right) { @@ -906,10 +901,20 @@ void OpenGLDrawingContext::DrawGlyph(uint32_t image, int32_t x, int32_t y, const std::swap(top, bottom); } - left += _offsetX; - top += _offsetY; - right += _offsetX; - bottom += _offsetY; + left -= _dpi->x; + top -= _dpi->y; + right -= _dpi->x; + bottom -= _dpi->y; + + left = left / _dpi->zoom_level; + top = top / _dpi->zoom_level; + right = right / _dpi->zoom_level; + bottom = bottom / _dpi->zoom_level; + + left += _spriteOffsetX; + top += _spriteOffsetY; + right += _spriteOffsetX; + bottom += _spriteOffsetY; DrawRectCommand& command = _commandBuffers.rects.allocate(); diff --git a/src/openrct2/paint/Paint.cpp b/src/openrct2/paint/Paint.cpp index 4e092fed37..f7dd2b8fde 100644 --- a/src/openrct2/paint/Paint.cpp +++ b/src/openrct2/paint/Paint.cpp @@ -1118,24 +1118,12 @@ void paint_floating_money_effect( session->LastPSString = ps; } -static rct_drawpixelinfo draw_pixel_info_crop_by_zoom(const rct_drawpixelinfo& dpi) -{ - auto result = dpi; - result.x = dpi.x * dpi.zoom_level; - result.y = dpi.y * dpi.zoom_level; - result.width = dpi.width / dpi.zoom_level; - result.height = dpi.height / dpi.zoom_level; - result.zoom_level = 0; - return result; -} - /** * * rct2: 0x006860C3 */ void paint_draw_money_structs(rct_drawpixelinfo* dpi, paint_string_struct* ps) { - auto dpi2 = draw_pixel_info_crop_by_zoom(*dpi); do { char buffer[256]{}; @@ -1151,6 +1139,6 @@ void paint_draw_money_structs(rct_drawpixelinfo* dpi, paint_string_struct* ps) } gfx_draw_string_with_y_offsets( - &dpi2, buffer, COLOUR_BLACK, { ps->x, ps->y }, reinterpret_cast(ps->y_offsets), forceSpriteFont); + dpi, buffer, COLOUR_BLACK, { ps->x, ps->y }, reinterpret_cast(ps->y_offsets), forceSpriteFont); } while ((ps = ps->next) != nullptr); }