1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-22 22:34:33 +01:00

Refactor widgets state (#23621)

* Refactor windows to not share widget state

* First half of refactoring all the windows

* Refactor the remaining windows, compiles but has issues

* Fix drawing only every second widget

* Remove the need of an terminating widget

* Address WidgetIndex signedness issues; use kWidgetIndexNull more

* Address constexpr issue with Widget content union

* Fix tabs in scenery window

* Fix tabs in object selection window

* Adjust custom widget index for CustomTool events

* Use STR_NONE for default tooltip initialisation

* Adjustment for mingw compiler

* Fix bottom toolbar using the widget declaration not instance

* Remove pointless code in Guest window, handled by SetPage

* Prevent out of bounds crash

* Move scroll widgets initialization to SetPage in Cheats window

* Remove special logic in Options window

* Remove special logic in Park window

* Remove special logic for Player window

* Remove special logic for Research window

* Remove special logic for Ride window

* Remove special logic for Staff window

* Remove special logic for Finances window

* Remove special logic for MapGen window

* Remove special logic for editor objective options window

* Remove special logic for editor scenario options window

* Fix widgets not being set since page is initialized to 0

* Remove more redundant code

* Fix remaining access to widget declarations

* Remove unused variable

* Fix editor object selection tabs on successive windows

---------

Co-authored-by: Aaron van Geffen <aaron@aaronweb.net>
This commit is contained in:
Matt
2025-01-18 14:45:17 +02:00
committed by GitHub
parent 4dac6ff030
commit b9f6b6f754
92 changed files with 574 additions and 1022 deletions

View File

@@ -420,7 +420,7 @@ public:
{
auto rideIndex = intent.GetUIntExtra(INTENT_EXTRA_RIDE_ID);
auto w = FindByClass(WindowClass::RideConstruction);
if (w == nullptr || w->number != rideIndex)
if (w == nullptr || w->number != static_cast<int16_t>(rideIndex))
{
WindowCloseConstructionWindows();
_currentRideIndex = RideId::FromUnderlying(rideIndex);
@@ -713,7 +713,7 @@ public:
if (w->flags & WF_NO_BACKGROUND)
{
auto widgetIndex = FindWidgetFromPoint(*w.get(), screenCoords);
if (widgetIndex == -1)
if (widgetIndex == kWidgetIndexNull)
continue;
}
@@ -736,14 +736,10 @@ public:
w.OnPrepareDraw();
// Find the widget at point x, y
WidgetIndex widget_index = -1;
for (int32_t i = 0;; i++)
WidgetIndex widget_index = kWidgetIndexNull;
for (auto i = 0u; i < w.widgets.size(); i++)
{
const auto& widget = w.widgets[i];
if (widget.type == WindowWidgetType::Last)
{
break;
}
if (widget.type != WindowWidgetType::Empty && widget.IsVisible())
{
@@ -756,7 +752,7 @@ public:
}
// Return next widget if a dropdown
if (widget_index != -1)
if (widget_index != kWidgetIndexNull)
{
const auto& widget = w.widgets[widget_index];
if (widget.type == WindowWidgetType::DropdownMenu)