1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-18 04:23:20 +01:00

Add GetBannerIndex helper in SignWindow

This commit is contained in:
ζeh Matt
2021-11-30 18:43:33 +02:00
parent e6187a0af4
commit a1b2996178

View File

@@ -59,9 +59,14 @@ class SignWindow final : public Window
private:
bool _isSmall = false;
BannerIndex GetBannerIndex() const
{
return BannerIndex::FromUnderlying(number);
}
void ShowTextInput()
{
auto* banner = GetBanner(BannerIndex::FromUnderlying(number));
auto* banner = GetBanner(GetBannerIndex());
if (banner != nullptr)
{
auto bannerText = banner->GetText();
@@ -87,14 +92,14 @@ public:
{
number = windowNumber;
_isSmall = isSmall;
auto* banner = GetBanner(BannerIndex::FromUnderlying(number));
auto* banner = GetBanner(GetBannerIndex());
if (banner == nullptr)
{
return false;
}
auto signViewPosition = banner->position.ToCoordsXY().ToTileCentre();
auto* tileElement = banner_get_tile_element(BannerIndex::FromUnderlying(number));
auto* tileElement = banner_get_tile_element(GetBannerIndex());
if (tileElement == nullptr)
return false;
@@ -138,7 +143,7 @@ public:
void OnMouseUp(rct_widgetindex widgetIndex) override
{
auto* banner = GetBanner(BannerIndex::FromUnderlying(number));
auto* banner = GetBanner(GetBannerIndex());
if (banner == nullptr)
{
Close();
@@ -151,7 +156,7 @@ public:
break;
case WIDX_SIGN_DEMOLISH:
{
auto* tileElement = banner_get_tile_element(BannerIndex::FromUnderlying(number));
auto* tileElement = banner_get_tile_element(GetBannerIndex());
if (tileElement == nullptr)
{
Close();
@@ -203,8 +208,7 @@ public:
if (dropdownIndex == -1)
return;
list_information_type = dropdownIndex;
auto signSetStyleAction = SignSetStyleAction(
BannerIndex::FromUnderlying(number), dropdownIndex, var_492, !_isSmall);
auto signSetStyleAction = SignSetStyleAction(GetBannerIndex(), dropdownIndex, var_492, !_isSmall);
GameActions::Execute(&signSetStyleAction);
break;
}
@@ -213,8 +217,7 @@ public:
if (dropdownIndex == -1)
return;
var_492 = dropdownIndex;
auto signSetStyleAction = SignSetStyleAction(
BannerIndex::FromUnderlying(number), list_information_type, dropdownIndex, !_isSmall);
auto signSetStyleAction = SignSetStyleAction(GetBannerIndex(), list_information_type, dropdownIndex, !_isSmall);
GameActions::Execute(&signSetStyleAction);
break;
}
@@ -229,7 +232,7 @@ public:
{
if (widgetIndex == WIDX_SIGN_TEXT && !text.empty())
{
auto signSetNameAction = SignSetNameAction(BannerIndex::FromUnderlying(number), std::string(text));
auto signSetNameAction = SignSetNameAction(GetBannerIndex(), std::string(text));
GameActions::Execute(&signSetNameAction);
}
}
@@ -290,7 +293,7 @@ public:
{
RemoveViewport();
auto banner = GetBanner(BannerIndex::FromUnderlying(number));
auto banner = GetBanner(GetBannerIndex());
if (banner == nullptr)
{
return;