mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-22 15:23:01 +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:
@@ -401,12 +401,13 @@ void WindowInvalidateAll()
|
||||
*/
|
||||
void WidgetInvalidate(WindowBase& w, WidgetIndex widgetIndex)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
for (int32_t i = 0; i <= widgetIndex; i++)
|
||||
if (w.widgets.empty())
|
||||
{
|
||||
assert(w.widgets[i].type != WindowWidgetType::Last);
|
||||
// This might be called before the window is fully created.
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
assert(widgetIndex < w.widgets.size());
|
||||
|
||||
const auto& widget = w.widgets[widgetIndex];
|
||||
if (widget.left == -2)
|
||||
@@ -1051,7 +1052,7 @@ void ToolCancel()
|
||||
// Reset map selection
|
||||
gMapSelectFlags = 0;
|
||||
|
||||
if (gCurrentToolWidget.widget_index != -1)
|
||||
if (gCurrentToolWidget.widget_index != kWidgetIndexNull)
|
||||
{
|
||||
// Invalidate tool widget
|
||||
WidgetInvalidateByNumber(
|
||||
@@ -1132,7 +1133,7 @@ void WindowResizeGuiScenarioEditor(int32_t width, int32_t height)
|
||||
mainWind->height = height;
|
||||
viewport->width = width;
|
||||
viewport->height = height;
|
||||
if (mainWind->widgets != nullptr && mainWind->widgets[WC_MAIN_WINDOW__0].type == WindowWidgetType::Viewport)
|
||||
if (!mainWind->widgets.empty() && mainWind->widgets[WC_MAIN_WINDOW__0].type == WindowWidgetType::Viewport)
|
||||
{
|
||||
mainWind->widgets[WC_MAIN_WINDOW__0].right = width;
|
||||
mainWind->widgets[WC_MAIN_WINDOW__0].bottom = height;
|
||||
|
||||
Reference in New Issue
Block a user