Skip to content

Commit

Permalink
Merge pull request OpenRCT2#23687 from ZehMatt/fix-23686
Browse files Browse the repository at this point in the history
Fix OpenRCT2#23686: Shortcut window crashing and missing widgets
  • Loading branch information
ZehMatt authored Jan 23, 2025
2 parents f70d202 + fe950f7 commit e3929c1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/openrct2-ui/input/MouseInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ namespace OpenRCT2
{
windowClass = w->classification;
windowNumber = w->number;
widget = &w->widgets[widgetIndex];
widget = widgetIndex == kWidgetIndexNull ? nullptr : &w->widgets[widgetIndex];
}

InputWidgetOverChangeCheck(windowClass, windowNumber, widgetIndex);
Expand Down
5 changes: 5 additions & 0 deletions src/openrct2-ui/interface/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,12 +527,17 @@ namespace OpenRCT2

void WindowAlignTabs(WindowBase* w, WidgetIndex start_tab_id, WidgetIndex end_tab_id)
{
assert(start_tab_id < w->widgets.size());
assert(end_tab_id < w->widgets.size());

int32_t i, x = w->widgets[start_tab_id].left;
int32_t tab_width = w->widgets[start_tab_id].width();

for (i = start_tab_id; i <= end_tab_id; i++)
{
auto& widget = w->widgets[i];
assert(widget.type == WindowWidgetType::Tab);

if (!WidgetIsDisabled(*w, i))
{
widget.left = x;
Expand Down
4 changes: 2 additions & 2 deletions src/openrct2-ui/windows/ShortcutKeys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ namespace OpenRCT2::Ui::Windows
widgets[WIDX_SCROLL].bottom = height - 19;
widgets[WIDX_RESET].top = height - 16;
widgets[WIDX_RESET].bottom = height - 5;
WindowAlignTabs(this, WIDX_TAB_0, static_cast<WidgetIndex>(WIDX_TAB_0 + _tabs.size()));
WindowAlignTabs(this, WIDX_TAB_0, static_cast<WidgetIndex>(WIDX_TAB_0 + _tabs.size() - 1));

// Set selected tab
for (size_t i = 0; i < _tabs.size(); i++)
Expand Down Expand Up @@ -450,7 +450,7 @@ namespace OpenRCT2::Ui::Windows
void InitialiseWidgets()
{
widgets.clear();
widgets.insert(widgets.begin(), std::begin(_shortcutWidgets), std::end(_shortcutWidgets) - 1);
widgets.insert(widgets.begin(), std::begin(_shortcutWidgets), std::end(_shortcutWidgets));

int32_t x = 3;
for (size_t i = 0; i < _tabs.size(); i++)
Expand Down

0 comments on commit e3929c1

Please sign in to comment.