OpenTTD Source
20241121-master-g67a0fccfad
|
List template of 'things' T
to sort in a GUI.
More...
#include <sortlist_type.h>
Public Types | |
using | SortFunction = std::conditional_t< std::is_same_v< P, std::nullptr_t >, bool(const T &, const T &), bool(const T &, const T &, const P)> |
Signature of sort function. | |
using | FilterFunction = bool(const T *, F) |
Signature of filter function. | |
Public Member Functions | |
template<typename T_ = T, typename P_ = P, typename _F = F, std::enable_if_t<!std::is_same_v< P_, std::nullptr_t >> * = nullptr> | |
GUIList (const P ¶ms) | |
uint8_t | SortType () const |
Get the sorttype of the list. More... | |
void | SetSortType (uint8_t n_type) |
Set the sorttype of the list. More... | |
Listing | GetListing () const |
Export current sort conditions. More... | |
void | SetListing (Listing l) |
Import sort conditions. More... | |
uint8_t | FilterType () const |
Get the filtertype of the list. More... | |
void | SetFilterType (uint8_t n_type) |
Set the filtertype of the list. More... | |
Filtering | GetFiltering () const |
Export current filter conditions. More... | |
void | SetFiltering (Filtering f) |
Import filter conditions. More... | |
bool | NeedResort () |
Check if a resort is needed next loop If used the resort timer will decrease every call till 0. More... | |
void | ForceResort () |
Force a resort next Sort call Reset the resort timer if used too. | |
bool | IsDescSortOrder () const |
Check if the sort order is descending. More... | |
void | ToggleSortOrder () |
Toggle the sort order Since that is the worst condition for the sort function reverse the list here. | |
template<typename Comp > | |
bool | Sort (Comp compare) |
Sort the list. More... | |
void | SetSortFuncs (std::span< SortFunction *const > n_funcs) |
Hand the sort function pointers to the GUIList. More... | |
bool | Sort () |
Overload of #Sort(SortFunction *compare) Overloaded to reduce external code. More... | |
bool | IsFilterEnabled () const |
Check if the filter is enabled. More... | |
void | SetFilterState (bool state) |
Enable or disable the filter. More... | |
bool | Filter (FilterFunction *decide, F filter_data) |
Filter the list. More... | |
void | SetFilterFuncs (std::span< FilterFunction *const > n_funcs) |
Hand the filter function pointers to the GUIList. More... | |
bool | Filter (F filter_data) |
Filter the data with the currently selected filter. More... | |
bool | NeedRebuild () const |
Check if a rebuild is needed. More... | |
void | ForceRebuild () |
Force that a rebuild is needed. | |
void | RebuildDone () |
Notify the sortlist that the rebuild is done. More... | |
Protected Types | |
using | SortParameterReference = std::conditional_t< std::is_same_v< P, std::nullptr_t >, P, P & > |
Protected Member Functions | |
bool | IsSortable () const |
Check if the list is sortable. More... | |
void | ResetResortTimer () |
Reset the resort timer. | |
Protected Attributes | |
std::span< SortFunction *const > | sort_func_list |
the sort criteria functions | |
std::span< FilterFunction *const > | filter_func_list |
the filter criteria functions | |
SortListFlags | flags |
used to control sorting/resorting/etc. | |
uint8_t | sort_type |
what criteria to sort on | |
uint8_t | filter_type |
what criteria to filter on | |
uint16_t | resort_timer |
resort list after a given amount of ticks if set | |
const SortParameterReference | params |
List template of 'things' T
to sort in a GUI.
T | Type of data stored in the list to represent each item. |
P | Tyoe of data passed as additional parameter to the sort function. |
F | Type of data fed as additional value to the filter function. |
Definition at line 47 of file sortlist_type.h.
|
inline |
Filter the data with the currently selected filter.
filter_data | Additional data passed to the filter function. |
Definition at line 380 of file sortlist_type.h.
|
inline |
Filter the list.
decide | The function to decide about an item |
filter_data | Additional data passed to the filter function |
Definition at line 346 of file sortlist_type.h.
Referenced by PickerWindow::BuildPickerClassList(), PickerWindow::BuildPickerTypeList(), IndustryDirectoryWindow::BuildSortIndustriesList(), NetworkContentListWindow::FilterContentList(), BuildVehicleWindow::FilterEngineList(), SignList::FilterSignList(), and BaseVehicleListWindow::FilterVehicleList().
|
inline |
Get the filtertype of the list.
Definition at line 167 of file sortlist_type.h.
References GUIList< T, P, F >::filter_type.
|
inline |
Export current filter conditions.
Definition at line 190 of file sortlist_type.h.
References Filtering::criteria, GUIList< T, P, F >::filter_type, Filtering::state, and VL_FILTER.
Referenced by NetworkContentListWindow::UpdateFilterState().
|
inline |
Export current sort conditions.
Definition at line 138 of file sortlist_type.h.
References Listing::criteria, Listing::order, GUIList< T, P, F >::sort_type, and VL_DESC.
|
inline |
Check if the sort order is descending.
Definition at line 246 of file sortlist_type.h.
References VL_DESC.
Referenced by NetworkContentListWindow::OnPaint().
|
inline |
Check if the filter is enabled.
Definition at line 320 of file sortlist_type.h.
References VL_FILTER.
|
inlineprotected |
Check if the list is sortable.
Definition at line 70 of file sortlist_type.h.
Referenced by GUIList< T, P, F >::Sort(), and GUIList< T, P, F >::ToggleSortOrder().
|
inline |
Check if a rebuild is needed.
Definition at line 391 of file sortlist_type.h.
References VL_REBUILD.
Referenced by PerformanceLeagueWindow::BuildCompanyList(), NetworkContentListWindow::BuildContentList(), VehicleGroupWindow::BuildGroupList(), NetworkGameWindow::BuildGUINetworkGameList(), PickerWindow::BuildPickerClassList(), PickerWindow::BuildPickerTypeList(), IndustryDirectoryWindow::BuildSortIndustriesList(), CompanyStationsWindow::BuildStationsList(), StoryBookWindow::BuildStoryPageElementList(), StoryBookWindow::BuildStoryPageList(), NetworkContentListWindow::OnInvalidateData(), IndustryDirectoryWindow::OnPaint(), NetworkContentListWindow::OnPaint(), NetworkGameWindow::OnPaint(), SignListWindow::OnPaint(), and TownDirectoryWindow::OnPaint().
|
inline |
Check if a resort is needed next loop If used the resort timer will decrease every call till 0.
If 0 reached the resort bit will be set and the timer will be reset.
Definition at line 222 of file sortlist_type.h.
References GUIList< T, P, F >::ResetResortTimer(), SETBITS, and VL_RESORT.
Referenced by VehicleGroupWindow::OnGameTick(), PerformanceLeagueWindow::OnGameTick(), CompanyStationsWindow::OnGameTick(), VehicleListWindow::OnGameTick(), NetworkGameWindow::OnPaint(), and SignWindow::PrevNextSign().
|
inline |
Notify the sortlist that the rebuild is done.
Definition at line 409 of file sortlist_type.h.
References CLRBITS, SETBITS, VL_REBUILD, and VL_RESORT.
Referenced by PerformanceLeagueWindow::BuildCompanyList(), NetworkContentListWindow::BuildContentList(), VehicleGroupWindow::BuildGroupList(), PickerWindow::BuildPickerClassList(), PickerWindow::BuildPickerTypeList(), IndustryDirectoryWindow::BuildSortIndustriesList(), CompanyStationsWindow::BuildStationsList(), StoryBookWindow::BuildStoryPageElementList(), StoryBookWindow::BuildStoryPageList(), and ReplaceVehicleWindow::GenerateLists().
|
inline |
Hand the filter function pointers to the GUIList.
n_funcs | Span covering the filter function pointers. |
Definition at line 369 of file sortlist_type.h.
Referenced by NetworkContentListWindow::NetworkContentListWindow(), BuildVehicleWindow::SetCargoFilterArray(), IndustryDirectoryWindow::SetCargoFilterArray(), and BaseVehicleListWindow::SetCargoFilterArray().
|
inline |
Import filter conditions.
f | The filter conditions we want to use |
Definition at line 204 of file sortlist_type.h.
References CLRBITS, Filtering::criteria, SETBITS, Filtering::state, and VL_FILTER.
Referenced by NetworkContentListWindow::NetworkContentListWindow().
|
inline |
Enable or disable the filter.
state | If filtering should be enabled or disabled |
Definition at line 330 of file sortlist_type.h.
References CLRBITS, SETBITS, and VL_FILTER.
Referenced by IndustryDirectoryWindow::SetAcceptedCargoFilter(), BaseVehicleListWindow::SetCargoFilter(), BaseVehicleListWindow::SetCargoFilterArray(), IndustryDirectoryWindow::SetProducedCargoFilter(), and NetworkContentListWindow::UpdateFilterState().
|
inline |
Set the filtertype of the list.
n_type | the new filter type |
Definition at line 177 of file sortlist_type.h.
Referenced by NetworkContentListWindow::FilterContentList(), IndustryDirectoryWindow::SetAcceptedCargoFilter(), BaseVehicleListWindow::SetCargoFilter(), and IndustryDirectoryWindow::SetProducedCargoFilter().
|
inline |
Import sort conditions.
l | The sort conditions we want to use |
Definition at line 152 of file sortlist_type.h.
References CLRBITS, Listing::criteria, Listing::order, SETBITS, and VL_DESC.
Referenced by NetworkContentListWindow::NetworkContentListWindow().
|
inline |
Hand the sort function pointers to the GUIList.
n_funcs | Span covering the sort function pointers. |
Definition at line 297 of file sortlist_type.h.
Referenced by NetworkContentListWindow::NetworkContentListWindow().
|
inline |
Set the sorttype of the list.
n_type | the new sort type |
Definition at line 124 of file sortlist_type.h.
|
inline |
Overload of #Sort(SortFunction *compare) Overloaded to reduce external code.
Definition at line 308 of file sortlist_type.h.
References GUIList< T, P, F >::sort_func_list.
|
inline |
Sort the list.
compare | The function to compare two list items |
Definition at line 270 of file sortlist_type.h.
References CLRBITS, GUIList< T, P, F >::IsSortable(), GUIList< T, P, F >::ResetResortTimer(), VL_DESC, and VL_RESORT.
Referenced by BuildGuiGroupList(), PickerWindow::BuildPickerClassList(), PickerWindow::BuildPickerTypeList(), IndustryDirectoryWindow::BuildSortIndustriesList(), StoryBookWindow::BuildStoryPageElementList(), StoryBookWindow::BuildStoryPageList(), PerformanceLeagueWindow::OnPaint(), BuildBridgeWindow::SortBridgeList(), NetworkContentListWindow::SortContentList(), NetworkGameWindow::SortNetworkGameList(), and CompanyStationsWindow::SortStationsList().
|
inline |
Get the sorttype of the list.
Definition at line 114 of file sortlist_type.h.
References GUIList< T, P, F >::sort_type.
Referenced by NetworkContentListWindow::OnPaint(), and BuildBridgeWindow::SortBridgeList().