From ed25fbcb3aa4e771e2579864353b03beb46f1672 Mon Sep 17 00:00:00 2001 From: mix <167040362+mixiate@users.noreply.github.com> Date: Sun, 9 Nov 2025 00:20:34 +0000 Subject: [PATCH] Fix track design mini preview enlarged UI position --- distribution/changelog.txt | 1 + src/openrct2-ui/windows/TrackDesignPlace.cpp | 32 +++++++++++--------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index a8c39e1d83..98846aeb18 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -7,6 +7,7 @@ - Fix: [#25461] Path connections in raised track designs are sometimes broken when placed. - Fix: [#25467] Paths are not connected together correctly in track design previews. - Fix: [#25476] When both RCT2 and RCT1 are present, autodetection fails. +- Fix: [#25480] The mini track design preview and price are misaligned in Enlarged UI mode. 0.4.28 (2025-11-01) ------------------------------------------------------------------------ diff --git a/src/openrct2-ui/windows/TrackDesignPlace.cpp b/src/openrct2-ui/windows/TrackDesignPlace.cpp index b8f1db2c44..0994be4ee7 100644 --- a/src/openrct2-ui/windows/TrackDesignPlace.cpp +++ b/src/openrct2-ui/windows/TrackDesignPlace.cpp @@ -45,9 +45,7 @@ namespace OpenRCT2::Ui::Windows { static constexpr StringId kWindowTitle = STR_STRING; static constexpr ScreenSize kWindowSize = { 200, 124 }; - constexpr int16_t kTrackMiniPreviewWidth = 168; - constexpr int16_t kTrackMiniPreviewHeight = 78; - constexpr uint16_t kTrackMiniPreviewSize = kTrackMiniPreviewWidth * kTrackMiniPreviewHeight; + static constexpr ScreenSize kTrackMiniPreviewSize = { 168, 78 }; static constexpr uint8_t kPaletteIndexColourEntrance = PaletteIndex::pi20; // White static constexpr uint8_t kPaletteIndexColourExit = PaletteIndex::pi10; // Black @@ -62,7 +60,8 @@ namespace OpenRCT2::Ui::Windows WIDX_ROTATE, WIDX_MIRROR, WIDX_SELECT_DIFFERENT_DESIGN, - WIDX_PRICE + WIDX_PRICE, + WIDX_PREVIEW, }; VALIDATE_GLOBAL_WIDX(WC_TRACK_DESIGN_PLACE, WIDX_ROTATE); @@ -70,10 +69,11 @@ namespace OpenRCT2::Ui::Windows // clang-format off static constexpr auto _trackPlaceWidgets = makeWidgets( makeWindowShim(kWindowTitle, kWindowSize), - makeWidget({173, 83}, { 24, 24}, WidgetType::flatBtn, WindowColour::primary, ImageId(SPR_ROTATE_ARROW), STR_ROTATE_90_TIP ), - makeWidget({173, 59}, { 24, 24}, WidgetType::flatBtn, WindowColour::primary, ImageId(SPR_MIRROR_ARROW), STR_MIRROR_IMAGE_TIP ), - makeWidget({ 4, 109}, {192, 12}, WidgetType::button, WindowColour::primary, STR_SELECT_A_DIFFERENT_DESIGN, STR_GO_BACK_TO_DESIGN_SELECTION_WINDOW_TIP), - makeWidget({ 0, 0}, { 1, 1}, WidgetType::empty, WindowColour::primary) + makeWidget({173, 83}, { 24, 24}, WidgetType::flatBtn, WindowColour::primary, ImageId(SPR_ROTATE_ARROW), STR_ROTATE_90_TIP ), + makeWidget({173, 59}, { 24, 24}, WidgetType::flatBtn, WindowColour::primary, ImageId(SPR_MIRROR_ARROW), STR_MIRROR_IMAGE_TIP ), + makeWidget({ 4, 109}, {192, 12}, WidgetType::button, WindowColour::primary, STR_SELECT_A_DIFFERENT_DESIGN, STR_GO_BACK_TO_DESIGN_SELECTION_WINDOW_TIP), + makeWidget({ 88, 93}, { 1, 1}, WidgetType::empty, WindowColour::primary), + makeWidget({ 4, 17}, kTrackMiniPreviewSize, WidgetType::empty, WindowColour::primary) ); // clang-format on @@ -111,7 +111,7 @@ namespace OpenRCT2::Ui::Windows gInputFlags.set(InputFlag::unk6); WindowPushOthersRight(*this); ShowGridlines(); - _miniPreview.resize(kTrackMiniPreviewSize); + _miniPreview.resize(kTrackMiniPreviewSize.width * kTrackMiniPreviewSize.height); _placementCost = kMoney64Undefined; _placementLoc.SetNull(); _currentTrackPieceDirection = (2 - GetCurrentRotation()) & 3; @@ -360,12 +360,14 @@ namespace OpenRCT2::Ui::Windows // Draw mini tile preview RenderTarget clippedRT; - if (ClipDrawPixelInfo(clippedRT, rt, this->windowPos + ScreenCoordsXY{ 4, 18 }, 168, 78)) + const auto& previewWidget = widgets[WIDX_PREVIEW]; + const auto previewCoords = windowPos + ScreenCoordsXY{ previewWidget.left, previewWidget.top }; + if (ClipDrawPixelInfo(clippedRT, rt, previewCoords, previewWidget.width(), previewWidget.height())) { G1Element g1temp = {}; g1temp.offset = _miniPreview.data(); - g1temp.width = kTrackMiniPreviewWidth; - g1temp.height = kTrackMiniPreviewHeight; + g1temp.width = kTrackMiniPreviewSize.width; + g1temp.height = kTrackMiniPreviewSize.height; GfxSetG1Element(SPR_TEMP, &g1temp); DrawingEngineInvalidateImage(SPR_TEMP); GfxDrawSprite(clippedRT, ImageId(SPR_TEMP, this->colours[0].colour), { 0, 0 }); @@ -376,7 +378,9 @@ namespace OpenRCT2::Ui::Windows { ft = Formatter(); ft.Add(_placementCost); - DrawTextBasic(rt, this->windowPos + ScreenCoordsXY{ 88, 94 }, STR_COST_LABEL, ft, { TextAlignment::centre }); + const auto& priceWidget = widgets[WIDX_PRICE]; + const auto priceCoords = windowPos + ScreenCoordsXY{ priceWidget.left, priceWidget.top }; + DrawTextBasic(rt, priceCoords, STR_COST_LABEL, ft, { TextAlignment::centre }); } } @@ -735,7 +739,7 @@ namespace OpenRCT2::Ui::Windows uint8_t* DrawMiniPreviewGetPixelPtr(const ScreenCoordsXY& pixel) { - return &_miniPreview[pixel.y * kTrackMiniPreviewWidth + pixel.x]; + return &_miniPreview[pixel.y * kTrackMiniPreviewSize.width + pixel.x]; } GameActions::Result FindValidTrackDesignPlaceHeight(CoordsXYZ& loc, uint32_t newFlags)