mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-29 01:35:06 +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:
@@ -50,14 +50,13 @@ namespace OpenRCT2::Ui::Windows
|
||||
constexpr int32_t ACTION_BUTTONS_LEFT = WW - 100;
|
||||
|
||||
// clang-format off
|
||||
static Widget window_install_track_widgets[] = {
|
||||
static constexpr Widget window_install_track_widgets[] = {
|
||||
WINDOW_SHIM(WINDOW_TITLE, WW, WH),
|
||||
MakeWidget({ 4, 18}, {372, 219}, WindowWidgetType::FlatBtn, WindowColour::Primary ),
|
||||
MakeWidget({PREVIEW_BUTTONS_LEFT, 422}, { 22, 24}, WindowWidgetType::FlatBtn, WindowColour::Primary, ImageId(SPR_ROTATE_ARROW), STR_ROTATE_90_TIP ),
|
||||
MakeWidget({PREVIEW_BUTTONS_LEFT, 398}, { 22, 24}, WindowWidgetType::FlatBtn, WindowColour::Primary, ImageId(SPR_SCENERY), STR_TOGGLE_SCENERY_TIP),
|
||||
MakeWidget({ ACTION_BUTTONS_LEFT, 241}, { 97, 15}, WindowWidgetType::Button, WindowColour::Primary, STR_INSTALL_NEW_TRACK_DESIGN_INSTALL ),
|
||||
MakeWidget({ ACTION_BUTTONS_LEFT, 259}, { 97, 15}, WindowWidgetType::Button, WindowColour::Primary, STR_INSTALL_NEW_TRACK_DESIGN_CANCEL ),
|
||||
kWidgetsEnd,
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
@@ -83,7 +82,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
void OnOpen() override
|
||||
{
|
||||
widgets = window_install_track_widgets;
|
||||
SetWidgets(window_install_track_widgets);
|
||||
|
||||
WindowInitScrollWidgets(*this);
|
||||
WindowPushOthersRight(*this);
|
||||
@@ -152,7 +151,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
DrawWidgets(dpi);
|
||||
|
||||
// Track preview
|
||||
Widget* widget = &window_install_track_widgets[WIDX_TRACK_PREVIEW];
|
||||
Widget* widget = &widgets[WIDX_TRACK_PREVIEW];
|
||||
auto screenPos = windowPos + ScreenCoordsXY{ widget->left + 1, widget->top + 1 };
|
||||
int32_t colour = ColourMapA[colours[0].colour].darkest;
|
||||
GfxFillRect(dpi, { screenPos, screenPos + ScreenCoordsXY{ 369, 216 } }, colour);
|
||||
|
||||
Reference in New Issue
Block a user