From 249eaa989e0121b176c8db12400b34d11251abd0 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Tue, 7 Jun 2022 12:17:56 +0100 Subject: [PATCH] Refactor sign internal variables --- src/openrct2-ui/windows/Sign.cpp | 35 +++++++++++++----------- src/openrct2/interface/Window_internal.h | 1 - 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/openrct2-ui/windows/Sign.cpp b/src/openrct2-ui/windows/Sign.cpp index 158364542a..4afc0e0753 100644 --- a/src/openrct2-ui/windows/Sign.cpp +++ b/src/openrct2-ui/windows/Sign.cpp @@ -58,6 +58,9 @@ class SignWindow final : public Window { private: bool _isSmall = false; + ObjectEntryIndex _sceneryEntry = OBJECT_ENTRY_INDEX_NULL; + colour_t _mainColour = {}; + colour_t _textColour = {}; BannerIndex GetBannerIndex() const { @@ -110,9 +113,9 @@ public: { return false; } - list_information_type = wallElement->GetPrimaryColour(); - var_492 = wallElement->GetSecondaryColour(); - SceneryEntry = wallElement->GetEntryIndex(); + _mainColour = wallElement->GetPrimaryColour(); + _textColour = wallElement->GetSecondaryColour(); + _sceneryEntry = wallElement->GetEntryIndex(); } else { @@ -121,9 +124,9 @@ public: { return false; } - list_information_type = sceneryElement->GetPrimaryColour(); - var_492 = sceneryElement->GetSecondaryColour(); - SceneryEntry = sceneryElement->GetEntryIndex(); + _mainColour = sceneryElement->GetPrimaryColour(); + _textColour = sceneryElement->GetSecondaryColour(); + _sceneryEntry = sceneryElement->GetEntryIndex(); } // Create viewport @@ -188,10 +191,10 @@ public: switch (widgetIndex) { case WIDX_MAIN_COLOUR: - WindowDropdownShowColour(this, widget, TRANSLUCENT(colours[1]), static_cast(list_information_type)); + WindowDropdownShowColour(this, widget, TRANSLUCENT(colours[1]), static_cast(_mainColour)); break; case WIDX_TEXT_COLOUR: - WindowDropdownShowColour(this, widget, TRANSLUCENT(colours[1]), static_cast(var_492)); + WindowDropdownShowColour(this, widget, TRANSLUCENT(colours[1]), static_cast(_textColour)); break; } } @@ -204,8 +207,8 @@ public: { if (dropdownIndex == -1) return; - list_information_type = dropdownIndex; - auto signSetStyleAction = SignSetStyleAction(GetBannerIndex(), dropdownIndex, var_492, !_isSmall); + _mainColour = dropdownIndex; + auto signSetStyleAction = SignSetStyleAction(GetBannerIndex(), dropdownIndex, _textColour, !_isSmall); GameActions::Execute(&signSetStyleAction); break; } @@ -213,8 +216,8 @@ public: { if (dropdownIndex == -1) return; - var_492 = dropdownIndex; - auto signSetStyleAction = SignSetStyleAction(GetBannerIndex(), list_information_type, dropdownIndex, !_isSmall); + _textColour = dropdownIndex; + auto signSetStyleAction = SignSetStyleAction(GetBannerIndex(), _mainColour, dropdownIndex, !_isSmall); GameActions::Execute(&signSetStyleAction); break; } @@ -241,7 +244,7 @@ public: if (_isSmall) { - auto* wallEntry = get_wall_entry(SceneryEntry); + auto* wallEntry = get_wall_entry(_sceneryEntry); main_colour_btn->type = WindowWidgetType::Empty; text_colour_btn->type = WindowWidgetType::Empty; @@ -257,7 +260,7 @@ public: } else { - auto* sceneryEntry = get_large_scenery_entry(SceneryEntry); + auto* sceneryEntry = get_large_scenery_entry(_sceneryEntry); main_colour_btn->type = WindowWidgetType::Empty; text_colour_btn->type = WindowWidgetType::Empty; @@ -272,8 +275,8 @@ public: } } - main_colour_btn->image = SPRITE_ID_PALETTE_COLOUR_1(list_information_type) | IMAGE_TYPE_TRANSPARENT | SPR_PALETTE_BTN; - text_colour_btn->image = SPRITE_ID_PALETTE_COLOUR_1(var_492) | IMAGE_TYPE_TRANSPARENT | SPR_PALETTE_BTN; + main_colour_btn->image = SPRITE_ID_PALETTE_COLOUR_1(_mainColour) | IMAGE_TYPE_TRANSPARENT | SPR_PALETTE_BTN; + text_colour_btn->image = SPRITE_ID_PALETTE_COLOUR_1(_textColour) | IMAGE_TYPE_TRANSPARENT | SPR_PALETTE_BTN; } void OnDraw(rct_drawpixelinfo& dpi) override diff --git a/src/openrct2/interface/Window_internal.h b/src/openrct2/interface/Window_internal.h index a658471558..3506a1f403 100644 --- a/src/openrct2/interface/Window_internal.h +++ b/src/openrct2/interface/Window_internal.h @@ -74,7 +74,6 @@ struct rct_window int16_t picked_peep_old_x; // staff/guest window: peep x gets set to 0x8000 on pickup, this is the old value int16_t vehicleIndex; // Ride window: selected car when setting vehicle colours int16_t numberOfStaff; // Used in park window. - int16_t SceneryEntry; // Used in sign window. int16_t var_48C; }; uint16_t frame_no{}; // updated every tic for motion in windows sprites