Park admittance price can now be set via text input

This commit is contained in:
Rik Smeets 2024-04-12 20:38:08 +02:00 committed by GitHub
parent 005aece802
commit 953bb4ee91
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 0 deletions

View File

@ -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.

View File

@ -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();