OpenTTD
|
List template of 'things' T
to sort in a GUI.
More...
#include <sortlist_type.h>
Public Types | |
typedef int CDECL | SortFunction (const T *, const T *) |
Signature of sort function. | |
typedef bool CDECL | FilterFunction (const T *, F) |
Signature of filter function. |
Public Member Functions | |
uint8 | SortType () const |
Get the sorttype of the list. | |
void | SetSortType (uint8 n_type) |
Set the sorttype of the list. | |
Listing | GetListing () const |
Export current sort conditions. | |
void | SetListing (Listing l) |
Import sort conditions. | |
uint8 | FilterType () const |
Get the filtertype of the list. | |
void | SetFilterType (uint8 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. | |
bool | Sort (SortFunction *compare) |
Sort the list. | |
void | SetSortFuncs (SortFunction *const *n_funcs) |
Hand the array of sort function pointers to the sort list. | |
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 (FilterFunction *const *n_funcs) |
Hand the array of filter function pointers to the sort list. | |
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. | |
![]() | |
SmallVector (const SmallVector &other) | |
Copy constructor. | |
SmallVector (const SmallVector< T, X > &other) | |
Generic copy constructor. | |
SmallVector & | operator= (const SmallVector &other) |
Assignment. | |
SmallVector & | operator= (const SmallVector< T, X > &other) |
Generic assignment. | |
void | Assign (const SmallVector< T, X > &other) |
Assign items from other vector. | |
void | Clear () |
Remove all items from the list. | |
void | Reset () |
Remove all items from the list and free allocated memory. | |
void | Compact () |
Compact the list down to the smallest block size boundary. | |
T * | Append (uint to_add=1) |
Append an item and return it. | |
void | Resize (uint num_items) |
Set the size of the vector, effectively truncating items from the end or appending uninitialised ones. | |
const T * | Find (const T &item) const |
Search for the first occurrence of an item. | |
T * | Find (const T &item) |
Search for the first occurrence of an item. | |
int | FindIndex (const T &item) const |
Search for the first occurrence of an item. | |
bool | Contains (const T &item) const |
Tests whether a item is present in the vector. | |
void | Erase (T *item) |
Removes given item from this vector. | |
void | ErasePreservingOrder (uint pos, uint count=1) |
Remove items from the vector while preserving the order of other items. | |
bool | Include (const T &item) |
Tests whether a item is present in the vector, and appends it to the end if not. | |
uint | Length () const |
Get the number of items in the list. | |
const T * | Begin () const |
Get the pointer to the first item (const) | |
T * | Begin () |
Get the pointer to the first item. | |
const T * | End () const |
Get the pointer behind the last valid item (const) | |
T * | End () |
Get the pointer behind the last valid item. | |
const T * | Get (uint index) const |
Get the pointer to item "number" (const) | |
T * | Get (uint index) |
Get the pointer to item "number". | |
const T & | operator[] (uint index) const |
Get item "number" (const) | |
T & | operator[] (uint index) |
Get item "number". |
Protected Member Functions | |
bool | IsSortable () const |
Check if the list is sortable. | |
void | ResetResortTimer () |
Reset the resort timer. |
Protected Attributes | |
SortFunction *const * | sort_func_list |
the sort criteria functions | |
FilterFunction *const * | filter_func_list |
the filter criteria functions | |
SortListFlags | flags |
used to control sorting/resorting/etc. | |
uint8 | sort_type |
what criteria to sort on | |
uint8 | filter_type |
what criteria to filter on | |
uint16 | resort_timer |
resort list after a given amount of ticks if set | |
![]() | |
T * | data |
The pointer to the first item. | |
uint | items |
The number of items stored. | |
uint | capacity |
The available space for storing items. |
List template of 'things' T
to sort in a GUI.
T | Type of data stored in the list to represent each item. |
F | Type of data fed as additional value to the filter function. |
Definition at line 50 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 334 of file sortlist_type.h.
Referenced by NetworkGameWindow::BuildGUINetworkGameList(), GUIList< const Sign *, StringFilter & >::Filter(), NetworkContentListWindow::FilterContentList(), BuildVehicleWindow::FilterEngineList(), and SignList::FilterSignList().
|
inline |
Filter the data with the currently selected filter.
filter_data | Additional data passed to the filter function. |
Definition at line 369 of file sortlist_type.h.
|
inline |
Get the filtertype of the list.
Definition at line 151 of file sortlist_type.h.
|
inline |
Export current filter conditions.
Definition at line 173 of file sortlist_type.h.
Referenced by NetworkContentListWindow::UpdateFilterState().
Export current sort conditions.
Definition at line 120 of file sortlist_type.h.
Referenced by TownDirectoryWindow::OnClick(), and TownDirectoryWindow::OnDropdownSelect().
|
inline |
Check if the sort order is descending.
Definition at line 229 of file sortlist_type.h.
Referenced by BuildBridgeWindow::DrawWidget(), VehicleGroupWindow::DrawWidget(), NetworkGameWindow::DrawWidget(), TownDirectoryWindow::DrawWidget(), IndustryDirectoryWindow::DrawWidget(), and VehicleListWindow::DrawWidget().
|
inline |
Check if the filter is enabled.
Definition at line 308 of file sortlist_type.h.
|
inlineprotected |
Check if the list is sortable.
Definition at line 68 of file sortlist_type.h.
Referenced by GUIList< const Sign *, StringFilter & >::Sort(), and GUIList< const Sign *, StringFilter & >::ToggleSortOrder().
|
inline |
Check if a rebuild is needed.
Definition at line 379 of file sortlist_type.h.
Referenced by CompanyLeagueWindow::BuildCompanyList(), NetworkContentListWindow::BuildContentList(), VehicleGroupWindow::BuildGroupList(), NetworkGameWindow::BuildGUINetworkGameList(), IndustryDirectoryWindow::BuildSortIndustriesList(), CompanyStationsWindow::BuildStationsList(), StoryBookWindow::BuildStoryPageElementList(), StoryBookWindow::BuildStoryPageList(), NetworkContentListWindow::OnInvalidateData(), SignListWindow::OnPaint(), NetworkGameWindow::OnPaint(), TownDirectoryWindow::OnPaint(), and IndustryDirectoryWindow::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 205 of file sortlist_type.h.
Referenced by SignWindow::OnClick(), NetworkGameWindow::OnPaint(), VehicleGroupWindow::OnTick(), CompanyLeagueWindow::OnTick(), VehicleListWindow::OnTick(), and SignWindow::PrevNextSign().
|
inline |
Notify the sortlist that the rebuild is done.
Definition at line 397 of file sortlist_type.h.
Referenced by CompanyLeagueWindow::BuildCompanyList(), NetworkContentListWindow::BuildContentList(), VehicleGroupWindow::BuildGroupList(), NetworkGameWindow::BuildGUINetworkGameList(), IndustryDirectoryWindow::BuildSortIndustriesList(), CompanyStationsWindow::BuildStationsList(), StoryBookWindow::BuildStoryPageElementList(), StoryBookWindow::BuildStoryPageList(), and ReplaceVehicleWindow::GenerateLists().
|
inline |
Hand the array of filter function pointers to the sort list.
n_funcs | The pointer to the first filter func |
Definition at line 358 of file sortlist_type.h.
Referenced by NetworkContentListWindow::NetworkContentListWindow(), and BuildVehicleWindow::SetCargoFilterArray().
|
inline |
Import filter conditions.
f | The filter conditions we want to use |
Definition at line 187 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 318 of file sortlist_type.h.
Referenced by NetworkGameWindow::BuildGUINetworkGameList(), BuildVehicleWindow::OnDropdownSelect(), BuildVehicleWindow::SetCargoFilterArray(), and NetworkContentListWindow::UpdateFilterState().
|
inline |
Set the filtertype of the list.
n_type | the new filter type |
Definition at line 161 of file sortlist_type.h.
Referenced by NetworkContentListWindow::FilterContentList().
Import sort conditions.
l | The sort conditions we want to use |
Definition at line 134 of file sortlist_type.h.
Referenced by NetworkContentListWindow::NetworkContentListWindow(), and TownDirectoryWindow::OnClick().
|
inline |
Hand the array of sort function pointers to the sort list.
n_funcs | The pointer to the first sort func |
Definition at line 286 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 107 of file sortlist_type.h.
Referenced by NetworkGameWindow::OnClick(), BuildBridgeWindow::OnDropdownSelect(), VehicleGroupWindow::OnDropdownSelect(), TownDirectoryWindow::OnDropdownSelect(), IndustryDirectoryWindow::OnDropdownSelect(), and VehicleListWindow::OnDropdownSelect().
|
inline |
Sort the list.
For the first sorting we use quick sort since it is faster for irregular sorted data. After that we use gsort.
compare | The function to compare two list items |
Definition at line 256 of file sortlist_type.h.
Referenced by VehicleGroupWindow::BuildGroupList(), NetworkGameWindow::BuildGUINetworkGameList(), IndustryDirectoryWindow::BuildSortIndustriesList(), StoryBookWindow::BuildStoryPageElementList(), StoryBookWindow::BuildStoryPageList(), TownDirectoryWindow::OnClick(), CompanyLeagueWindow::OnPaint(), BuildBridgeWindow::SortBridgeList(), NetworkContentListWindow::SortContentList(), NetworkGameWindow::SortNetworkGameList(), and CompanyStationsWindow::SortStationsList().
|
inline |
Overload of Sort(SortFunction *compare) Overloaded to reduce external code.
Definition at line 297 of file sortlist_type.h.
Referenced by GUIList< const Sign *, StringFilter & >::Sort().
|
inline |
Get the sorttype of the list.
Definition at line 97 of file sortlist_type.h.
Referenced by NetworkGameWindow::DrawWidget(), BuildBridgeWindow::OnClick(), VehicleGroupWindow::OnClick(), NetworkGameWindow::OnClick(), TownDirectoryWindow::OnClick(), IndustryDirectoryWindow::OnClick(), VehicleListWindow::OnClick(), BuildBridgeWindow::OnDropdownSelect(), TownDirectoryWindow::OnDropdownSelect(), IndustryDirectoryWindow::OnDropdownSelect(), VehicleGroupWindow::OnPaint(), VehicleListWindow::OnPaint(), TownDirectoryWindow::SetStringParameters(), IndustryDirectoryWindow::SetStringParameters(), and BuildBridgeWindow::SortBridgeList().