Skip to content

Commit

Permalink
Prevent closing object selection window when selection is invalid (Op…
Browse files Browse the repository at this point in the history
…enRCT2#23487)

* Prevent closing object selection window when selection is invalid

* Ride window: remove superfluous virtual keyword from event signatures

* Amend changelog
  • Loading branch information
AaronVanGeffen authored Dec 29, 2024
1 parent fef568c commit 25ac4cf
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 18 deletions.
1 change: 1 addition & 0 deletions distribution/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- Fix: [#23286] Currency formatted incorrectly in the in game console.
- Fix: [#23348] Console set commands don't print output properly.
- Fix: [#23376] Peeps with balloons, hats and umbrellas may leave artifacts on screen.
- Fix: [#23486] Object selection minimum requirements can be bypassed with close window hotkey.

0.4.17 (2024-12-08)
------------------------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions src/openrct2-ui/windows/EditorObjectSelection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,12 @@ namespace OpenRCT2::Ui::Windows
VisibleListRefresh();
}

bool CanClose() override
{
// Prevent window closure when selection is invalid
return EditorObjectSelectionWindowCheck();
}

/**
*
* rct2: 0x006AB199
Expand Down
36 changes: 18 additions & 18 deletions src/openrct2-ui/windows/Ride.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ namespace OpenRCT2::Ui::Windows
rideId = ride.id;
}

virtual void OnOpen() override
void OnOpen() override
{
widgets = PageWidgets[WINDOW_RIDE_PAGE_MAIN];
hold_down_widgets = PageHoldDownWidgets[WINDOW_RIDE_PAGE_MAIN];
Expand All @@ -778,7 +778,7 @@ namespace OpenRCT2::Ui::Windows
PopulateVehicleTypeDropdown(*ride, true);
}

virtual void OnClose() override
void OnClose() override
{
switch (page)
{
Expand All @@ -790,7 +790,7 @@ namespace OpenRCT2::Ui::Windows
break;
}
}
virtual void OnResize() override
void OnResize() override
{
switch (page)
{
Expand Down Expand Up @@ -826,7 +826,7 @@ namespace OpenRCT2::Ui::Windows
break;
}
}
virtual void OnUpdate() override
void OnUpdate() override
{
switch (page)
{
Expand Down Expand Up @@ -863,7 +863,7 @@ namespace OpenRCT2::Ui::Windows
}
}

virtual void OnPrepareDraw() override
void OnPrepareDraw() override
{
switch (page)
{
Expand Down Expand Up @@ -899,7 +899,7 @@ namespace OpenRCT2::Ui::Windows
break;
}
}
virtual void OnDraw(DrawPixelInfo& dpi) override
void OnDraw(DrawPixelInfo& dpi) override
{
switch (page)
{
Expand Down Expand Up @@ -936,7 +936,7 @@ namespace OpenRCT2::Ui::Windows
}
}

virtual OpenRCT2String OnTooltip(WidgetIndex widgetIndex, StringId fallback) override
OpenRCT2String OnTooltip(WidgetIndex widgetIndex, StringId fallback) override
{
switch (page)
{
Expand All @@ -947,7 +947,7 @@ namespace OpenRCT2::Ui::Windows
}
return { fallback, {} };
}
virtual void OnMouseDown(WidgetIndex widgetIndex) override
void OnMouseDown(WidgetIndex widgetIndex) override
{
switch (page)
{
Expand Down Expand Up @@ -980,7 +980,7 @@ namespace OpenRCT2::Ui::Windows
break;
}
}
virtual void OnMouseUp(WidgetIndex widgetIndex) override
void OnMouseUp(WidgetIndex widgetIndex) override
{
switch (page)
{
Expand Down Expand Up @@ -1016,7 +1016,7 @@ namespace OpenRCT2::Ui::Windows
break;
}
}
virtual void OnDropdown(WidgetIndex widgetIndex, int32_t selectedIndex) override
void OnDropdown(WidgetIndex widgetIndex, int32_t selectedIndex) override
{
switch (page)
{
Expand All @@ -1043,7 +1043,7 @@ namespace OpenRCT2::Ui::Windows
break;
}
}
virtual void OnTextInput(WidgetIndex widgetIndex, std::string_view text) override
void OnTextInput(WidgetIndex widgetIndex, std::string_view text) override
{
switch (page)
{
Expand All @@ -1058,7 +1058,7 @@ namespace OpenRCT2::Ui::Windows
break;
}
}
virtual ScreenSize OnScrollGetSize(int32_t scrollIndex) override
ScreenSize OnScrollGetSize(int32_t scrollIndex) override
{
switch (page)
{
Expand All @@ -1069,7 +1069,7 @@ namespace OpenRCT2::Ui::Windows
}
return {};
}
virtual void OnScrollSelect(int32_t scrollIndex, int32_t scrollAreaType) override
void OnScrollSelect(int32_t scrollIndex, int32_t scrollAreaType) override
{
switch (page)
{
Expand All @@ -1078,7 +1078,7 @@ namespace OpenRCT2::Ui::Windows
break;
}
}
virtual void OnScrollDraw(int32_t scrollIndex, DrawPixelInfo& dpi) override
void OnScrollDraw(int32_t scrollIndex, DrawPixelInfo& dpi) override
{
switch (page)
{
Expand All @@ -1096,7 +1096,7 @@ namespace OpenRCT2::Ui::Windows
break;
}
}
virtual void OnToolDown(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords) override
void OnToolDown(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords) override
{
switch (page)
{
Expand All @@ -1108,7 +1108,7 @@ namespace OpenRCT2::Ui::Windows
break;
}
}
virtual void OnToolDrag(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords) override
void OnToolDrag(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords) override
{
switch (page)
{
Expand All @@ -1120,7 +1120,7 @@ namespace OpenRCT2::Ui::Windows
break;
}
}
virtual void OnToolAbort(WidgetIndex widgetIndex) override
void OnToolAbort(WidgetIndex widgetIndex) override
{
switch (page)
{
Expand All @@ -1129,7 +1129,7 @@ namespace OpenRCT2::Ui::Windows
break;
}
}
virtual void OnViewportRotate() override
void OnViewportRotate() override
{
switch (page)
{
Expand Down
6 changes: 6 additions & 0 deletions src/openrct2/interface/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,12 @@ void WindowSetWindowLimit(int32_t value)
*/
void WindowClose(WindowBase& w)
{
if (!w.CanClose())
{
// Something's preventing this window from closing -- bail out early
return;
}

w.OnClose();

// Remove viewport
Expand Down
4 changes: 4 additions & 0 deletions src/openrct2/interface/Window_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ struct WindowBase
virtual void OnOpen()
{
}
virtual bool CanClose()
{
return true;
}
virtual void OnClose()
{
}
Expand Down

0 comments on commit 25ac4cf

Please sign in to comment.