|
OpenTTD Source 20260206-master-g4d4e37dbf1
|
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. | |
| void | SetSortType (uint8_t n_type) |
| Set the sorttype of the list. | |
| Listing | GetListing () const |
| Export current sort conditions. | |
| void | SetListing (Listing l) |
| Import sort conditions. | |
| uint8_t | FilterType () const |
| Get the filtertype of the list. | |
| void | SetFilterType (uint8_t n_type) |
| Set the filtertype of the list. | |
| Filtering | GetFiltering () const |
| Export current filter conditions. | |
| void | SetFiltering (Filtering f) |
| Import filter conditions. | |
| bool | NeedResort () |
| Check if a resort is needed next loop If used the resort timer will decrease every call till 0. | |
| 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. | |
| 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. | |
| void | SetSortFuncs (std::span< SortFunction *const > n_funcs) |
| Hand the sort function pointers to the GUIList. | |
| bool | Sort () |
| Overload of #Sort(SortFunction *compare) Overloaded to reduce external code. | |
| bool | IsFilterEnabled () const |
| Check if the filter is enabled. | |
| void | SetFilterState (bool state) |
| Enable or disable the filter. | |
| bool | Filter (FilterFunction *decide, F filter_data) |
| Filter the list. | |
| void | SetFilterFuncs (std::span< FilterFunction *const > n_funcs) |
| Hand the filter function pointers to the GUIList. | |
| bool | Filter (F filter_data) |
| Filter the data with the currently selected filter. | |
| bool | NeedRebuild () const |
| Check if a rebuild is needed. | |
| void | ForceRebuild () |
| Force that a rebuild is needed. | |
| void | RebuildDone () |
| Notify the sortlist that the rebuild is done. | |
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. | |
| 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 43 of file sortlist_type.h.
| using GUIList< T, P, F >::FilterFunction = bool(const T*, F) |
Signature of filter function.
Definition at line 46 of file sortlist_type.h.
| using GUIList< T, P, F >::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.
Definition at line 45 of file sortlist_type.h.
|
protected |
Definition at line 58 of file sortlist_type.h.
|
inline |
Definition at line 83 of file sortlist_type.h.
|
inline |
Definition at line 95 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 376 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 342 of file sortlist_type.h.
Referenced by NetworkGameWindow::BuildGUINetworkGameList(), IndustryDirectoryWindow::BuildSortIndustriesList(), GUIList< BuildBridgeData >::Filter(), NetworkContentListWindow::FilterContentList(), BuildVehicleWindow::FilterEngineList(), and SignList::FilterSignList().
|
inline |
Get the filtertype of the list.
Definition at line 163 of file sortlist_type.h.
|
inline |
Force that a rebuild is needed.
Definition at line 395 of file sortlist_type.h.
Referenced by NewGRFWindow::AddGRFToActive(), NetworkContentListWindow::NetworkContentListWindow(), NewGRFConfirmationCallback(), CompanyStationsWindow::OnClick(), NetworkContentListWindow::OnClick(), NewGRFWindow::OnClick(), SelectCompanyLiveryWindow::OnClick(), SignWindow::OnClick(), VehicleGroupWindow::OnClick(), CompanyStationsWindow::OnDropdownSelect(), NewGRFWindow::OnDropdownSelect(), NetworkContentListWindow::OnEditboxChanged(), NetworkGameWindow::OnEditboxChanged(), NewGRFWindow::OnEditboxChanged(), CompanyStationsWindow::OnInvalidateData(), IndustryDirectoryWindow::OnInvalidateData(), NetworkGameWindow::OnInvalidateData(), NewGRFWindow::OnInvalidateData(), PerformanceLeagueWindow::OnInvalidateData(), SelectCompanyLiveryWindow::OnInvalidateData(), SignListWindow::OnInvalidateData(), StoryBookWindow::OnInvalidateData(), TownDirectoryWindow::OnInvalidateData(), VehicleGroupWindow::OnInvalidateData(), NetworkContentListWindow::OnKeyPress(), NewGRFWindow::OnNewGRFsScanned(), NetworkContentListWindow::OnReceiveContentInfo(), SignWindow::PrevNextSign(), StoryBookWindow::RefreshSelectedPage(), VehicleGroupWindow::SelectGroup(), IndustryDirectoryWindow::SetAcceptedCargoFilter(), and IndustryDirectoryWindow::SetProducedCargoFilter().
|
inline |
Force a resort next Sort call Reset the resort timer if used too.
Definition at line 232 of file sortlist_type.h.
Referenced by NetworkContentListWindow::OnClick(), NetworkGameWindow::OnClick(), TownDirectoryWindow::OnClick(), NetworkContentListWindow::OnDownloadComplete(), SignListWindow::OnInit(), CompanyStationsWindow::OnInvalidateData(), IndustryDirectoryWindow::OnInvalidateData(), PerformanceLeagueWindow::OnInvalidateData(), SignListWindow::OnInvalidateData(), TownDirectoryWindow::OnInvalidateData(), VehicleGroupWindow::OnInvalidateData(), and NetworkContentListWindow::OnKeyPress().
|
inline |
Export current filter conditions.
Definition at line 186 of file sortlist_type.h.
Referenced by NetworkContentListWindow::UpdateFilterState().
|
inline |
Export current sort conditions.
Definition at line 134 of file sortlist_type.h.
Referenced by TownDirectoryWindow::OnClick(), and TownDirectoryWindow::OnDropdownSelect().
|
inline |
Check if the sort order is descending.
Definition at line 242 of file sortlist_type.h.
Referenced by BuildBridgeWindow::DrawWidget(), CompanyStationsWindow::DrawWidget(), IndustryDirectoryWindow::DrawWidget(), NetworkGameWindow::DrawWidget(), TownDirectoryWindow::DrawWidget(), and NetworkContentListWindow::OnPaint().
|
inline |
Check if the filter is enabled.
Definition at line 316 of file sortlist_type.h.
|
inlineprotected |
Check if the list is sortable.
Definition at line 66 of file sortlist_type.h.
Referenced by GUIList< BuildBridgeData >::Sort(), and GUIList< BuildBridgeData >::ToggleSortOrder().
|
inline |
Check if a rebuild is needed.
Definition at line 387 of file sortlist_type.h.
Referenced by PerformanceLeagueWindow::BuildCompanyList(), NetworkContentListWindow::BuildContentList(), VehicleGroupWindow::BuildGroupList(), NetworkGameWindow::BuildGUINetworkGameList(), 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 218 of file sortlist_type.h.
Referenced by SignWindow::OnClick(), CompanyStationsWindow::OnGameTick(), PerformanceLeagueWindow::OnGameTick(), VehicleGroupWindow::OnGameTick(), NetworkGameWindow::OnPaint(), and SignWindow::PrevNextSign().
|
inline |
Notify the sortlist that the rebuild is done.
Definition at line 405 of file sortlist_type.h.
Referenced by PerformanceLeagueWindow::BuildCompanyList(), NetworkContentListWindow::BuildContentList(), VehicleGroupWindow::BuildGroupList(), NetworkGameWindow::BuildGUINetworkGameList(), IndustryDirectoryWindow::BuildSortIndustriesList(), CompanyStationsWindow::BuildStationsList(), StoryBookWindow::BuildStoryPageElementList(), and StoryBookWindow::BuildStoryPageList().
|
inlineprotected |
Reset the resort timer.
Definition at line 74 of file sortlist_type.h.
Referenced by GUIList< BuildBridgeData >::NeedResort(), and GUIList< BuildBridgeData >::Sort().
|
inline |
Hand the filter function pointers to the GUIList.
| n_funcs | Span covering the filter function pointers. |
Definition at line 365 of file sortlist_type.h.
Referenced by NetworkContentListWindow::NetworkContentListWindow(), BuildVehicleWindow::SetCargoFilterArray(), and IndustryDirectoryWindow::SetCargoFilterArray().
|
inline |
Import filter conditions.
| f | The filter conditions we want to use |
Definition at line 200 of file sortlist_type.h.
Referenced by NetworkContentListWindow::NetworkContentListWindow().
|
inline |
Enable or disable the filter.
| state | If filtering should be enabled or disabled |
Definition at line 326 of file sortlist_type.h.
Referenced by NetworkGameWindow::BuildGUINetworkGameList(), NewGRFWindow::OnEditboxChanged(), IndustryDirectoryWindow::SetAcceptedCargoFilter(), BuildVehicleWindow::SetCargoFilterArray(), IndustryDirectoryWindow::SetCargoFilterArray(), IndustryDirectoryWindow::SetProducedCargoFilter(), and NetworkContentListWindow::UpdateFilterState().
|
inline |
Set the filtertype of the list.
| n_type | the new filter type |
Definition at line 173 of file sortlist_type.h.
Referenced by NetworkContentListWindow::FilterContentList(), IndustryDirectoryWindow::SetAcceptedCargoFilter(), and IndustryDirectoryWindow::SetProducedCargoFilter().
|
inline |
Import sort conditions.
| l | The sort conditions we want to use |
Definition at line 148 of file sortlist_type.h.
Referenced by NetworkContentListWindow::NetworkContentListWindow(), and TownDirectoryWindow::OnClick().
|
inline |
Hand the sort function pointers to the GUIList.
| n_funcs | Span covering the sort function pointers. |
Definition at line 293 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 120 of file sortlist_type.h.
Referenced by NetworkContentListWindow::OnClick(), NetworkGameWindow::OnClick(), BuildBridgeWindow::OnDropdownSelect(), CompanyStationsWindow::OnDropdownSelect(), IndustryDirectoryWindow::OnDropdownSelect(), and TownDirectoryWindow::OnDropdownSelect().
|
inline |
Overload of #Sort(SortFunction *compare) Overloaded to reduce external code.
Definition at line 304 of file sortlist_type.h.
Referenced by GUIList< BuildBridgeData >::Sort().
|
inline |
Sort the list.
| compare | The function to compare two list items |
Definition at line 266 of file sortlist_type.h.
Referenced by NetworkGameWindow::BuildGUINetworkGameList(), IndustryDirectoryWindow::BuildSortIndustriesList(), StoryBookWindow::BuildStoryPageElementList(), StoryBookWindow::BuildStoryPageList(), TownDirectoryWindow::OnClick(), PerformanceLeagueWindow::OnPaint(), BuildBridgeWindow::SortBridgeList(), NetworkContentListWindow::SortContentList(), NetworkGameWindow::SortNetworkGameList(), and CompanyStationsWindow::SortStationsList().
|
inline |
Get the sorttype of the list.
Definition at line 110 of file sortlist_type.h.
Referenced by NetworkGameWindow::DrawWidget(), IndustryDirectoryWindow::GetIndustryString(), IndustryDirectoryWindow::GetWidgetString(), TownDirectoryWindow::GetWidgetString(), BuildBridgeWindow::OnClick(), CompanyStationsWindow::OnClick(), IndustryDirectoryWindow::OnClick(), NetworkContentListWindow::OnClick(), NetworkGameWindow::OnClick(), TownDirectoryWindow::OnClick(), BuildBridgeWindow::OnDropdownSelect(), CompanyStationsWindow::OnDropdownSelect(), IndustryDirectoryWindow::OnDropdownSelect(), TownDirectoryWindow::OnDropdownSelect(), IndustryDirectoryWindow::OnInvalidateData(), TownDirectoryWindow::OnInvalidateData(), NetworkContentListWindow::OnPaint(), and BuildBridgeWindow::SortBridgeList().
|
inline |
Toggle the sort order Since that is the worst condition for the sort function reverse the list here.
Definition at line 252 of file sortlist_type.h.
Referenced by BuildBridgeWindow::OnClick(), CompanyStationsWindow::OnClick(), IndustryDirectoryWindow::OnClick(), NetworkContentListWindow::OnClick(), NetworkGameWindow::OnClick(), and TownDirectoryWindow::OnClick().
|
protected |
the filter criteria functions
Definition at line 50 of file sortlist_type.h.
|
protected |
what criteria to filter on
Definition at line 53 of file sortlist_type.h.
Referenced by GUIList< BuildBridgeData >::Filter().
|
protected |
used to control sorting/resorting/etc.
Definition at line 51 of file sortlist_type.h.
|
protected |
Definition at line 59 of file sortlist_type.h.
|
protected |
resort list after a given amount of ticks if set
Definition at line 54 of file sortlist_type.h.
|
protected |
the sort criteria functions
Definition at line 49 of file sortlist_type.h.
|
protected |
what criteria to sort on
Definition at line 52 of file sortlist_type.h.
Referenced by GUIList< BuildBridgeData >::Sort().