From 92d5574ffb0d9cecc8f5d88a370fd016f36e198d Mon Sep 17 00:00:00 2001 From: Michael Steenbeek <1478678+Gymnasiast@users.noreply.github.com> Date: Sat, 14 Feb 2026 23:49:40 +0100 Subject: [PATCH] Close #25526: When a shop item cannot be recoloured, show a preview of the building (#25528) --- distribution/changelog.txt | 1 + src/openrct2-ui/windows/Ride.cpp | 39 ++++++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 0dacff9933..41cf226399 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -2,6 +2,7 @@ ------------------------------------------------------------------------ - Feature: [#22704] Rides can be made invisible more easily. - Improved: [#21753] Tracked rides with cheated powered launch mode can change powered launch speed without extra cheats. +- Improved: [#25526] When a shop item cannot be recoloured, show a preview of the building instead. - Improved: [#25941] The command line sprite build command is now faster. - Fix: [#14686, #23996, #25981] Preview images from different windows overwrite each other when using OpenGL. - Fix: [#15128, #15626, #16331, #17443, #18626, #21597, #24175, #24971, #25963] Crash when loading corrupted RCT2/RCT1 save files with duplicate entity indices. diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index 7db0ff7d60..40a8733025 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -4879,21 +4879,42 @@ namespace OpenRCT2::Ui::Windows } else { - auto screenCoords = windowPos - + ScreenCoordsXY{ (trackPreviewWidget.left + trackPreviewWidget.right) / 2 - 8, - (trackPreviewWidget.bottom + trackPreviewWidget.top) / 2 - 6 }; + ShopItem shopItemIndex = rideEntry->shop_item[1] == ShopItem::none ? rideEntry->shop_item[0] + : rideEntry->shop_item[1]; + auto shopItem = GetShopItemDescriptor(shopItemIndex); - ShopItem shopItem = rideEntry->shop_item[1] == ShopItem::none ? rideEntry->shop_item[0] - : rideEntry->shop_item[1]; - if (ride->hasLifecycleFlag(RIDE_LIFECYCLE_RANDOM_SHOP_COLOURS)) + if (shopItem.IsRecolourable()) { - auto spriteColour = static_cast((getGameState().currentTicks / 32) % kColourNumTotal); + auto screenCoords = windowPos + + ScreenCoordsXY{ (trackPreviewWidget.left + trackPreviewWidget.right) / 2 - 8, + (trackPreviewWidget.bottom + trackPreviewWidget.top) / 2 - 6 }; - GfxDrawSprite(rt, ImageId(GetShopItemDescriptor(shopItem).Image, spriteColour), screenCoords); + Colour spriteColour = ride->trackColours[0].main; + if (ride->hasLifecycleFlag(RIDE_LIFECYCLE_RANDOM_SHOP_COLOURS)) + spriteColour = Colour((getGameState().currentTicks / 32) % kColourNumNormal); + + GfxDrawSprite(rt, ImageId(shopItem.Image, spriteColour), screenCoords); } else { - GfxDrawSprite(rt, ImageId(GetShopItemDescriptor(shopItem).Image, ride->trackColours[0].main), screenCoords); + const ImageIndex previewImage = rideEntry->images_offset + 3 + 1; + auto image = GfxGetG1Element(previewImage); + if (image == nullptr) + return; + + const auto& previewWidget = widgets[WIDX_TRACK_PREVIEW]; + + RenderTarget clipRT; + auto clipScreenPos = windowPos + ScreenCoordsXY{ previewWidget.left + 1, previewWidget.top + 1 }; + const auto clipWidth = previewWidget.width() - 2; + const auto clipHeight = previewWidget.height() - 1; + ClipRenderTarget(clipRT, rt, clipScreenPos, clipWidth, clipHeight); + + auto imageLocationX = (clipWidth / 2) - (image->width / 2) - image->xOffset; + auto imageLocationY = (clipHeight / 2) - (image->height / 2) - image->yOffset; + + GfxDrawSprite( + clipRT, ImageId(previewImage, ride->trackColours[0].main), { imageLocationX, imageLocationY }); } }