1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-24 15:24:30 +01:00

Keep ride list sorted (#24943)

This commit is contained in:
Aaron van Geffen
2025-08-10 11:26:40 +02:00
committed by GitHub
parent eff76240ff
commit 147eb89883

View File

@@ -206,14 +206,6 @@ namespace OpenRCT2::Ui::Windows
Invalidate();
height = min_height;
}
// Refreshing the list can be a very intensive operation
// owing to its use of ride_has_any_track_elements().
// This makes sure it's only refreshed every 64 ticks.
if (!(gCurrentRealTimeTicks & 0x3f))
{
RefreshList();
}
}
/**
@@ -237,7 +229,7 @@ namespace OpenRCT2::Ui::Windows
{
_windowListSortDescending ^= true;
}
RefreshList();
SortList();
break;
case WIDX_HEADER_OTHER:
if (list_information_type != _windowRideListInformationType)
@@ -249,7 +241,7 @@ namespace OpenRCT2::Ui::Windows
{
_windowListSortDescending ^= true;
}
RefreshList();
SortList();
break;
case WIDX_TAB_1:
case WIDX_TAB_2:
@@ -385,7 +377,7 @@ namespace OpenRCT2::Ui::Windows
if (list_information_type != INFORMATION_TYPE_STATUS)
{
list_information_type = _windowRideListInformationType;
RefreshList();
SortList();
}
}
}
@@ -402,6 +394,11 @@ namespace OpenRCT2::Ui::Windows
Invalidate();
}
void OnPeriodicUpdate() override
{
SortList();
}
/**
*
* rct2: 0x006B35A1
@@ -857,7 +854,7 @@ namespace OpenRCT2::Ui::Windows
}
/**
* Used in RefreshList() to handle the sorting of the list.
* Used in SortList() to handle the sorting of the list.
* Uses a lambda function (predicate) as exit criteria for the algorithm.
*/
template<typename TSortPred>
@@ -912,6 +909,12 @@ namespace OpenRCT2::Ui::Windows
_rideList.push_back(std::move(entry));
}
selected_list_item = -1;
SortList();
}
void SortList()
{
switch (list_information_type)
{
case INFORMATION_TYPE_STATUS: