From 953bb4ee9146eb2f378e8e7b76803ee11aeb20ec Mon Sep 17 00:00:00 2001 From: Rik Smeets <30838294+rik-smeets@users.noreply.github.com> Date: Fri, 12 Apr 2024 20:38:08 +0200 Subject: [PATCH] Park admittance price can now be set via text input --- distribution/changelog.txt | 1 + src/openrct2-ui/windows/Park.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 841af623a9..788f37006b 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -1,5 +1,6 @@ 0.4.11 (in development) ------------------------------------------------------------------------ +- Feature: [#21734] Park admittance price can now be set via text input. - Improved: [#21769] Expose “animation is backwards” wall property in Tile Inspector. - Fix: [#866] Boat Hire boats get stuck entering track. diff --git a/src/openrct2-ui/windows/Park.cpp b/src/openrct2-ui/windows/Park.cpp index dc384e173c..199a12147e 100644 --- a/src/openrct2-ui/windows/Park.cpp +++ b/src/openrct2-ui/windows/Park.cpp @@ -334,6 +334,9 @@ static constexpr WindowParkAward _parkAwards[] = { case WINDOW_PARK_PAGE_OBJECTIVE: OnTextInputObjective(widgetIndex, text); break; + case WINDOW_PARK_PAGE_PRICE: + OnTextInputPrice(widgetIndex, text); + break; } } @@ -848,6 +851,14 @@ static constexpr WindowParkAward _parkAwards[] = { GameActions::Execute(&gameAction); break; } + case WIDX_PRICE: + { + utf8 _moneyInputText[MONEY_STRING_MAXLENGTH] = {}; + MoneyToString(Park::GetEntranceFee(), _moneyInputText, MONEY_STRING_MAXLENGTH, false); + WindowTextInputRawOpen( + this, WIDX_PRICE, STR_ENTER_NEW_VALUE, STR_ENTER_NEW_VALUE, {}, _moneyInputText, + MONEY_STRING_MAXLENGTH); + } } } @@ -1052,6 +1063,23 @@ static constexpr WindowParkAward _parkAwards[] = { } } + void OnTextInputPrice(WidgetIndex widgetIndex, std::string_view text) + { + if (widgetIndex == WIDX_PRICE && !text.empty()) + { + std::string strText(text); + auto money = StringToMoney(strText.c_str()); + if (money == kMoney64Undefined) + { + return; + } + + money = std::clamp(money, 0.00_GBP, MAX_ENTRANCE_FEE); + auto gameAction = ParkSetEntranceFeeAction(money); + GameActions::Execute(&gameAction); + } + } + void OnPrepareDrawObjective() { SetPressedTab();