From fa90a84d223292ba9e8c20f4b83bef39a696de16 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Sun, 5 May 2024 13:38:49 +0200 Subject: [PATCH] Make construction and removal buttons holdable (#21950) * Footpath: make construction button holdable * RideConstruction: make construction button holdable * Allow repeated removal as well * Amend changelog --- distribution/changelog.txt | 1 + src/openrct2-ui/windows/Footpath.cpp | 16 ++++++------ src/openrct2-ui/windows/RideConstruction.cpp | 26 +++++++++++--------- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 2961a51903..6226c5e03c 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -9,6 +9,7 @@ - Change: [#21715] [Plugin] Remove access to the internal `owner` property. Note: `ownership` is still accessible. - Change: [#21855] Cheats menu dropdown no longer requires dragging. - Change: [#21866] Hide the FPS Counter when the top toolbar/widgets have been toggled off. +- Change: [#21950] Construction and removal buttons can now be held down for repeated placement. - Fix: [#866] Boat Hire boats get stuck entering track (original bug). - Fix: [#10701] No reason specified when placing door over unsuitable track. - Fix: [#18723, #21870] Attempting to demolish a flat ride in pause mode allows you to place multiple copies. diff --git a/src/openrct2-ui/windows/Footpath.cpp b/src/openrct2-ui/windows/Footpath.cpp index 08474f4ba1..df62fb269a 100644 --- a/src/openrct2-ui/windows/Footpath.cpp +++ b/src/openrct2-ui/windows/Footpath.cpp @@ -177,6 +177,8 @@ static constexpr uint8_t ConstructionPreviewImages[][4] = { InputSetFlag(INPUT_FLAG_6, true); _footpathErrorOccured = false; WindowFootpathSetEnabledAndPressedWidgets(); + + hold_down_widgets = (1u << WIDX_CONSTRUCT) | (1u << WIDX_REMOVE); } void OnClose() override @@ -269,6 +271,12 @@ static constexpr uint8_t ConstructionPreviewImages[][4] = { case WIDX_SLOPEUP: WindowFootpathMousedownSlope(2); break; + case WIDX_CONSTRUCT: + WindowFootpathConstruct(); + break; + case WIDX_REMOVE: + WindowFootpathRemove(); + break; } } @@ -279,12 +287,6 @@ static constexpr uint8_t ConstructionPreviewImages[][4] = { case WIDX_CLOSE: Close(); break; - case WIDX_CONSTRUCT: - WindowFootpathConstruct(); - break; - case WIDX_REMOVE: - WindowFootpathRemove(); - break; case WIDX_CONSTRUCT_ON_LAND: if (_footpathConstructionMode == PATH_CONSTRUCTION_MODE_LAND) { @@ -1411,7 +1413,7 @@ static constexpr uint8_t ConstructionPreviewImages[][4] = { return; } - OnMouseUp(WIDX_CONSTRUCT); + OnMouseDown(WIDX_CONSTRUCT); } void OnResize() override diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index b5a9dedf36..a3383ddfa1 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -978,14 +978,6 @@ static Widget _rideConstructionWidgets[] = { case WIDX_PREVIOUS_SECTION: RideSelectPreviousSection(); break; - case WIDX_CONSTRUCT: - Construct(); - // Force any footpath construction to recheck the area. - gProvisionalFootpath.Flags |= PROVISIONAL_PATH_FLAG_2; - break; - case WIDX_DEMOLISH: - MouseUpDemolish(); - break; case WIDX_ROTATE: Rotate(); break; @@ -1021,6 +1013,16 @@ static Widget _rideConstructionWidgets[] = { WindowRideConstructionUpdateEnabledTrackPieces(); switch (widgetIndex) { + case WIDX_CONSTRUCT: + { + Construct(); + // Force any footpath construction to recheck the area. + gProvisionalFootpath.Flags |= PROVISIONAL_PATH_FLAG_2; + break; + } + case WIDX_DEMOLISH: + MouseUpDemolish(); + break; case WIDX_LEFT_CURVE: RideConstructionInvalidateCurrentTrack(); _currentTrackCurve = EnumValue(TrackCurve::Left); @@ -1595,7 +1597,7 @@ static Widget _rideConstructionWidgets[] = { const auto& rtd = GetRideTypeDescriptor(currentRide->type); auto trackDrawerDescriptor = getCurrentTrackDrawerDescriptor(rtd); - hold_down_widgets = 0; + hold_down_widgets = (1u << WIDX_CONSTRUCT) | (1u << WIDX_DEMOLISH); if (rtd.HasFlag(RIDE_TYPE_FLAG_IS_SHOP_OR_FACILITY) || !currentRide->HasStation()) { widgets[WIDX_ENTRANCE_EXIT_GROUPBOX].type = WindowWidgetType::Empty; @@ -3623,7 +3625,7 @@ static Widget _rideConstructionWidgets[] = { break; gDisableErrorWindowSound = true; - w->OnMouseUp(WIDX_CONSTRUCT); + w->OnMouseDown(WIDX_CONSTRUCT); gDisableErrorWindowSound = false; if (_trackPlaceCost == kMoney64Undefined) @@ -4532,7 +4534,7 @@ static Widget _rideConstructionWidgets[] = { return; } - w->OnMouseUp(WIDX_CONSTRUCT); + w->OnMouseDown(WIDX_CONSTRUCT); } void WindowRideConstructionKeyboardShortcutDemolishCurrent() @@ -4543,7 +4545,7 @@ static Widget _rideConstructionWidgets[] = { return; } - w->OnMouseUp(WIDX_DEMOLISH); + w->OnMouseDown(WIDX_DEMOLISH); } static void WindowRideConstructionMouseUpDemolishNextPiece(const CoordsXYZD& piecePos, int32_t type)