From 14a49149105908dbf3cefaa7a7cf57cc564f8fbd Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Sat, 23 Aug 2025 17:25:47 +0200 Subject: [PATCH] Create ImageItem constructor, add tooltips to land styles --- distribution/changelog.txt | 1 + src/openrct2-ui/interface/Dropdown.h | 5 +++++ src/openrct2-ui/interface/LandTool.cpp | 8 ++++---- src/openrct2-ui/windows/Footpath.cpp | 14 ++++---------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 0886c28936..ba5beb5868 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -6,6 +6,7 @@ - Improved: [#24893] The ride list now has headers, and can be sorted in both directions. - Improved: [#24921] The command line sprite build command now prints out the images table entry for the compiled sprite file. - Improved: [#24953] Opening the Scenario Editor, Track Designer or Track Designs Manager now display the progress bar. +- Improved: [#25027] Land style dropdown now has tooltips with the name of the land types. - Change: [#23351] Diagonal sloped Go-Kart track can no longer be built without cheats if the karts do not have sprites for them. - Change: [#24606] Increase Misc Entity limit from 1600 to 3200. - Change: [#24974] Raise the Go-Karts maximum support height to allow 2 large sloped turns to be built on flat ground. diff --git a/src/openrct2-ui/interface/Dropdown.h b/src/openrct2-ui/interface/Dropdown.h index 39bd9d2e46..bef48d2b60 100644 --- a/src/openrct2-ui/interface/Dropdown.h +++ b/src/openrct2-ui/interface/Dropdown.h @@ -155,6 +155,11 @@ namespace OpenRCT2::Dropdown { return Item{ kSeparatorString }; } + + constexpr Item ImageItem(ImageId image, StringId tooltip = kStringIdEmpty) + { + return Item{ .format = Dropdown::kFormatLandPicker, .args = { .image = image }, .tooltip = tooltip }; + } struct DropdownState { diff --git a/src/openrct2-ui/interface/LandTool.cpp b/src/openrct2-ui/interface/LandTool.cpp index 427abd1dd6..4727a58015 100644 --- a/src/openrct2-ui/interface/LandTool.cpp +++ b/src/openrct2-ui/interface/LandTool.cpp @@ -67,8 +67,7 @@ void LandTool::ShowSurfaceStyleDropdown(WindowBase* w, Widget* widget, ObjectEnt if (surfaceObj->Colour != TerrainSurfaceObject::kNoValue) imageId = imageId.WithPrimary(surfaceObj->Colour); - gDropdown.items[itemIndex].format = Dropdown::kFormatLandPicker; - gDropdown.items[itemIndex].args.image = imageId; + gDropdown.items[itemIndex] = Dropdown::ImageItem(imageId, surfaceObj->NameStringId); if (i == currentSurfaceType) { defaultIndex = itemIndex; @@ -82,6 +81,7 @@ void LandTool::ShowSurfaceStyleDropdown(WindowBase* w, Widget* widget, ObjectEnt w->windowPos.x + widget->left, w->windowPos.y + widget->top, widget->height(), w->colours[2], 0, surfaceCount, 47, 36, DropdownGetAppropriateImageDropdownItemsPerRow(surfaceCount)); + gDropdown.hasTooltips = true; gDropdown.defaultIndex = defaultIndex; } @@ -117,8 +117,7 @@ void LandTool::ShowEdgeStyleDropdown(WindowBase* w, Widget* widget, ObjectEntryI // If fallback images are loaded, the RCT1 styles will just look like copies of already existing styles, so hide them. if (edgeObj != nullptr && !edgeObj->UsesFallbackImages()) { - gDropdown.items[itemIndex].format = Dropdown::kFormatLandPicker; - gDropdown.items[itemIndex].args.image = ImageId(edgeObj->IconImageId); + gDropdown.items[itemIndex] = Dropdown::ImageItem(ImageId(edgeObj->IconImageId), edgeObj->NameStringId); if (i == currentEdgeType) { defaultIndex = itemIndex; @@ -133,6 +132,7 @@ void LandTool::ShowEdgeStyleDropdown(WindowBase* w, Widget* widget, ObjectEntryI w->windowPos.x + widget->left, w->windowPos.y + widget->top, widget->height(), w->colours[2], 0, edgeCount, 47, 36, itemsPerRow); + gDropdown.hasTooltips = true; gDropdown.defaultIndex = defaultIndex; } diff --git a/src/openrct2-ui/windows/Footpath.cpp b/src/openrct2-ui/windows/Footpath.cpp index c86761e396..fe4bb040cf 100644 --- a/src/openrct2-ui/windows/Footpath.cpp +++ b/src/openrct2-ui/windows/Footpath.cpp @@ -702,9 +702,7 @@ namespace OpenRCT2::Ui::Windows defaultIndex = numPathTypes; } - gDropdown.items[numPathTypes].format = Dropdown::kFormatLandPicker; - gDropdown.items[numPathTypes].tooltip = pathType->NameStringId; - gDropdown.items[numPathTypes].args.image = ImageId(pathType->PreviewImageId); + gDropdown.items[numPathTypes] = Dropdown::ImageItem(ImageId(pathType->PreviewImageId), pathType->NameStringId); _dropdownEntries.push_back({ ObjectType::footpathSurface, i }); numPathTypes++; } @@ -728,10 +726,8 @@ namespace OpenRCT2::Ui::Windows defaultIndex = numPathTypes; } - gDropdown.items[numPathTypes].format = Dropdown::kFormatLandPicker; - gDropdown.items[numPathTypes].tooltip = pathEntry->string_idx; - gDropdown.items[numPathTypes].args.image = ImageId( - showQueues ? pathEntry->GetQueuePreviewImage() : pathEntry->GetPreviewImage()); + auto image = ImageId(showQueues ? pathEntry->GetQueuePreviewImage() : pathEntry->GetPreviewImage()); + gDropdown.items[numPathTypes] = Dropdown::ImageItem(image, pathEntry->string_idx); _dropdownEntries.push_back({ ObjectType::paths, i }); numPathTypes++; } @@ -766,9 +762,7 @@ namespace OpenRCT2::Ui::Windows defaultIndex = numRailingsTypes; } - gDropdown.items[numRailingsTypes].format = Dropdown::kFormatLandPicker; - gDropdown.items[numRailingsTypes].tooltip = railingsEntry->NameStringId; - gDropdown.items[numRailingsTypes].args.image = ImageId(railingsEntry->PreviewImageId); + gDropdown.items[numRailingsTypes] = Dropdown::ImageItem(ImageId(railingsEntry->PreviewImageId), railingsEntry->NameStringId); _dropdownEntries.push_back({ ObjectType::footpathRailings, i }); numRailingsTypes++; }