OpenTTD Source 20260218-master-g2123fca5ea
PickerCallbacks Class Referenceabstract

Class for PickerClassWindow to collect information and retain state. More...

#include <picker_gui.h>

Inheritance diagram for PickerCallbacks:
PickerCallbacksNewGRFClass< ObjectClass > PickerCallbacksNewGRFClass< RoadStopClass > PickerCallbacksNewGRFClass< StationClass > HousePickerCallbacks PickerCallbacksNewGRFClass< T > ObjectPickerCallbacks RoadStopPickerCallbacks< roadstoptype > RoadWaypointPickerCallbacks StationPickerCallbacks WaypointPickerCallbacks

Public Member Functions

 PickerCallbacks (const std::string &ini_group)
virtual void Close (int data)
 Hide the window and all its child windows, and mark them for a later deletion.
virtual GrfSpecFeature GetFeature () const =0
 NewGRF feature this picker is for.
virtual bool IsActive () const =0
 Should picker class/type selection be enabled?
virtual bool HasClassChoice () const =0
 Are there multiple classes to chose from?
virtual StringID GetClassTooltip () const =0
 Get the tooltip string for the class list.
virtual int GetClassCount () const =0
 Get the number of classes.
virtual int GetSelectedClass () const =0
 Get the index of the selected class.
virtual void SetSelectedClass (int id) const =0
 Set the selected class.
virtual StringID GetClassName (int id) const =0
 Get the name of a class.
virtual StringID GetTypeTooltip () const =0
 Get the tooltip string for the type grid.
virtual int GetTypeCount (int cls_id) const =0
 Get the number of types in a class.
virtual int GetSelectedType () const =0
 Get the selected type.
virtual void SetSelectedType (int id) const =0
 Set the selected type.
virtual PickerItem GetPickerItem (int cls_id, int id) const =0
 Get data about an item.
virtual StringID GetTypeName (int cls_id, int id) const =0
 Get the item name of a type.
virtual std::span< const BadgeID > GetTypeBadges (int cls_id, int id) const =0
 Get the item's badges of a type.
virtual bool IsTypeAvailable (int cls_id, int id) const =0
 Test if an item is currently buildable.
virtual void DrawType (int x, int y, int cls_id, int id) const =0
 Draw preview image of an item.
virtual StringID GetCollectionTooltip () const =0
 Get the tooltip string for the collection list.
virtual void FillUsedItems (std::set< PickerItem > &items)=0
 Fill a set with all items that are used by the current player.
virtual std::map< std::string, std::set< PickerItem > > UpdateSavedItems (const std::map< std::string, std::set< PickerItem > > &src)=0
 Update link between grfid/localidx and class_index/index in saved items.
std::set< std::string > InitializeInactiveCollections (const std::map< std::string, std::set< PickerItem > > collections)
 Initialize the list of active collections for sorting purposes.

Data Fields

Listing class_last_sorting = { false, 0 }
 Default sorting of PickerClassList.
Filtering class_last_filtering = { false, 0 }
 Default filtering of PickerClassList.
Listing type_last_sorting = { false, 0 }
 Default sorting of PickerTypeList.
Filtering type_last_filtering = { false, 0 }
 Default filtering of PickerTypeList.
Listing collection_last_sorting = { false, 0 }
 Default sorting of PickerCollectionList.
const std::string ini_group
 Ini Group for saving favourites.
uint8_t mode = 0
 Bitmask of PickerFilterModes.
bool rename_collection = false
 Are we renaming a collection?
std::string sel_collection
 Currently selected collection of saved items.
std::string edit_collection
 Collection to rename or delete.
std::set< std::string > rm_collections
 Set of removed or renamed collections for updating ini file.
int preview_height = 0
 Previously adjusted height.
std::set< PickerItemused
 Set of items used in the current game by the current company.
std::map< std::string, std::set< PickerItem > > saved
 Set of saved collections of items.

Detailed Description

Class for PickerClassWindow to collect information and retain state.

Definition at line 39 of file picker_gui.h.

Constructor & Destructor Documentation

◆ PickerCallbacks()

PickerCallbacks::PickerCallbacks ( const std::string & ini_group)
explicit

Definition at line 50 of file picker_gui.cpp.

◆ ~PickerCallbacks()

PickerCallbacks::~PickerCallbacks ( )
virtual

Definition at line 55 of file picker_gui.cpp.

Member Function Documentation

◆ Close()

virtual void PickerCallbacks::Close ( int data)
inlinevirtual

Hide the window and all its child windows, and mark them for a later deletion.

Parameters
dataWindow specific data to be passed through the window close functions.

Reimplemented in HousePickerCallbacks, RoadWaypointPickerCallbacks, and WaypointPickerCallbacks.

Definition at line 45 of file picker_gui.h.

◆ DrawType()

virtual void PickerCallbacks::DrawType ( int x,
int y,
int cls_id,
int id ) const
pure virtual

Draw preview image of an item.

Parameters
xThe X-position for the sprite to draw.
yThe Y-position for the sprite to draw.
cls_idThe chosen class.
idThe chosen type within the class.

Implemented in HousePickerCallbacks, ObjectPickerCallbacks, RoadStopPickerCallbacks< roadstoptype >, RoadWaypointPickerCallbacks, StationPickerCallbacks, and WaypointPickerCallbacks.

◆ FillUsedItems()

virtual void PickerCallbacks::FillUsedItems ( std::set< PickerItem > & items)
pure virtual

Fill a set with all items that are used by the current player.

Parameters
itemsThe set to fill.

Implemented in HousePickerCallbacks, ObjectPickerCallbacks, RoadStopPickerCallbacks< roadstoptype >, RoadWaypointPickerCallbacks, StationPickerCallbacks, and WaypointPickerCallbacks.

◆ GetClassCount()

virtual int PickerCallbacks::GetClassCount ( ) const
pure virtual

Get the number of classes.

Returns
Number of classes.
Note
Used only to estimate space requirements.

Implemented in HousePickerCallbacks, PickerCallbacksNewGRFClass< T >, PickerCallbacksNewGRFClass< ObjectClass >, PickerCallbacksNewGRFClass< RoadStopClass >, and PickerCallbacksNewGRFClass< StationClass >.

◆ GetClassName()

virtual StringID PickerCallbacks::GetClassName ( int id) const
pure virtual

Get the name of a class.

Parameters
idThe class to get the name for.
Returns
StringID without parameters.

Implemented in HousePickerCallbacks, ObjectPickerCallbacks, RoadStopPickerCallbacks< roadstoptype >, RoadWaypointPickerCallbacks, StationPickerCallbacks, and WaypointPickerCallbacks.

Referenced by ClassTagNameFilter().

◆ GetClassTooltip()

virtual StringID PickerCallbacks::GetClassTooltip ( ) const
pure virtual

◆ GetCollectionTooltip()

virtual StringID PickerCallbacks::GetCollectionTooltip ( ) const
pure virtual

◆ GetFeature()

virtual GrfSpecFeature PickerCallbacks::GetFeature ( ) const
pure virtual

NewGRF feature this picker is for.

Returns
The associated NewGRF feature.

Implemented in HousePickerCallbacks, ObjectPickerCallbacks, RoadStopPickerCallbacks< roadstoptype >, RoadWaypointPickerCallbacks, StationPickerCallbacks, and WaypointPickerCallbacks.

◆ GetPickerItem()

virtual PickerItem PickerCallbacks::GetPickerItem ( int cls_id,
int id ) const
pure virtual

Get data about an item.

Parameters
cls_idThe chosen class.
idThe chosen type within the class.
Returns
The metadata about the item.

Implemented in HousePickerCallbacks, and PickerCallbacksNewGRFClass< T >.

◆ GetSelectedClass()

virtual int PickerCallbacks::GetSelectedClass ( ) const
pure virtual

Get the index of the selected class.

Returns
The previously selected class.

Implemented in HousePickerCallbacks, ObjectPickerCallbacks, RoadStopPickerCallbacks< roadstoptype >, RoadWaypointPickerCallbacks, StationPickerCallbacks, and WaypointPickerCallbacks.

◆ GetSelectedType()

virtual int PickerCallbacks::GetSelectedType ( ) const
pure virtual

◆ GetTypeBadges()

virtual std::span< const BadgeID > PickerCallbacks::GetTypeBadges ( int cls_id,
int id ) const
pure virtual

Get the item's badges of a type.

Parameters
cls_idThe chosen class.
idThe chosen type within the class.
Returns
The badge IDs.

Implemented in HousePickerCallbacks, ObjectPickerCallbacks, RoadStopPickerCallbacks< roadstoptype >, RoadWaypointPickerCallbacks, StationPickerCallbacks, and WaypointPickerCallbacks.

Referenced by TypeTagNameFilter().

◆ GetTypeCount()

virtual int PickerCallbacks::GetTypeCount ( int cls_id) const
pure virtual

Get the number of types in a class.

Parameters
cls_idThe class' identifier.
Returns
The number of types.
Note
Used only to estimate space requirements.

Implemented in HousePickerCallbacks, PickerCallbacksNewGRFClass< T >, PickerCallbacksNewGRFClass< ObjectClass >, PickerCallbacksNewGRFClass< RoadStopClass >, and PickerCallbacksNewGRFClass< StationClass >.

◆ GetTypeName()

virtual StringID PickerCallbacks::GetTypeName ( int cls_id,
int id ) const
pure virtual

Get the item name of a type.

Parameters
cls_idThe chosen class.
idThe chosen type within the class.
Returns
The name of the item.

Implemented in HousePickerCallbacks, ObjectPickerCallbacks, RoadStopPickerCallbacks< roadstoptype >, RoadWaypointPickerCallbacks, StationPickerCallbacks, and WaypointPickerCallbacks.

Referenced by InitializeInactiveCollections(), and TypeTagNameFilter().

◆ GetTypeTooltip()

virtual StringID PickerCallbacks::GetTypeTooltip ( ) const
pure virtual

◆ HasClassChoice()

virtual bool PickerCallbacks::HasClassChoice ( ) const
pure virtual

◆ InitializeInactiveCollections()

std::set< std::string > PickerCallbacks::InitializeInactiveCollections ( const std::map< std::string, std::set< PickerItem > > collections)
inline

Initialize the list of active collections for sorting purposes.

Parameters
collectionsThe map of collections to check.
Returns
The set of collections with inactive items.

Definition at line 175 of file picker_gui.h.

References GetTypeName(), and INVALID_STRING_ID.

◆ IsActive()

virtual bool PickerCallbacks::IsActive ( ) const
pure virtual

Should picker class/type selection be enabled?

Returns
true when to show the class/type picker.

Implemented in HousePickerCallbacks, ObjectPickerCallbacks, RoadStopPickerCallbacks< roadstoptype >, RoadWaypointPickerCallbacks, StationPickerCallbacks, and WaypointPickerCallbacks.

◆ IsTypeAvailable()

virtual bool PickerCallbacks::IsTypeAvailable ( int cls_id,
int id ) const
pure virtual

Test if an item is currently buildable.

Parameters
cls_idThe chosen class.
idThe chosen type within the class.
Returns
true if the combination is buildable.

Implemented in HousePickerCallbacks, ObjectPickerCallbacks, RoadStopPickerCallbacks< roadstoptype >, RoadWaypointPickerCallbacks, StationPickerCallbacks, and WaypointPickerCallbacks.

◆ SetSelectedClass()

virtual void PickerCallbacks::SetSelectedClass ( int id) const
pure virtual

◆ SetSelectedType()

virtual void PickerCallbacks::SetSelectedType ( int id) const
pure virtual

◆ UpdateSavedItems()

virtual std::map< std::string, std::set< PickerItem > > PickerCallbacks::UpdateSavedItems ( const std::map< std::string, std::set< PickerItem > > & src)
pure virtual

Update link between grfid/localidx and class_index/index in saved items.

Parameters
srcMapping of name to set of PickerItems with only grfid and localidx set.
Returns
Mapping of name to fully populated PickerItems for loaded NewGRFs and 'src' items when the NewGRF is not loaded.

Implemented in HousePickerCallbacks, PickerCallbacksNewGRFClass< T >, PickerCallbacksNewGRFClass< ObjectClass >, PickerCallbacksNewGRFClass< RoadStopClass >, and PickerCallbacksNewGRFClass< StationClass >.

Field Documentation

◆ class_last_filtering

Filtering PickerCallbacks::class_last_filtering = { false, 0 }

Default filtering of PickerClassList.

Definition at line 196 of file picker_gui.h.

◆ class_last_sorting

Listing PickerCallbacks::class_last_sorting = { false, 0 }

Default sorting of PickerClassList.

Definition at line 195 of file picker_gui.h.

◆ collection_last_sorting

Listing PickerCallbacks::collection_last_sorting = { false, 0 }

Default sorting of PickerCollectionList.

Definition at line 201 of file picker_gui.h.

◆ edit_collection

std::string PickerCallbacks::edit_collection

Collection to rename or delete.

Definition at line 207 of file picker_gui.h.

◆ ini_group

const std::string PickerCallbacks::ini_group

Ini Group for saving favourites.

Definition at line 203 of file picker_gui.h.

Referenced by PickerLoadConfig(), and PickerSaveConfig().

◆ mode

uint8_t PickerCallbacks::mode = 0

Bitmask of PickerFilterModes.

Definition at line 204 of file picker_gui.h.

◆ preview_height

int PickerCallbacks::preview_height = 0

Previously adjusted height.

Definition at line 210 of file picker_gui.h.

◆ rename_collection

bool PickerCallbacks::rename_collection = false

Are we renaming a collection?

Definition at line 205 of file picker_gui.h.

◆ rm_collections

std::set<std::string> PickerCallbacks::rm_collections

Set of removed or renamed collections for updating ini file.

Definition at line 208 of file picker_gui.h.

Referenced by PickerSaveConfig().

◆ saved

std::map<std::string, std::set<PickerItem> > PickerCallbacks::saved

Set of saved collections of items.

Definition at line 213 of file picker_gui.h.

Referenced by PickerLoadConfig(), and PickerSaveConfig().

◆ sel_collection

std::string PickerCallbacks::sel_collection

Currently selected collection of saved items.

Definition at line 206 of file picker_gui.h.

◆ type_last_filtering

Filtering PickerCallbacks::type_last_filtering = { false, 0 }

Default filtering of PickerTypeList.

Definition at line 199 of file picker_gui.h.

◆ type_last_sorting

Listing PickerCallbacks::type_last_sorting = { false, 0 }

Default sorting of PickerTypeList.

Definition at line 198 of file picker_gui.h.

◆ used

std::set<PickerItem> PickerCallbacks::used

Set of items used in the current game by the current company.

Definition at line 212 of file picker_gui.h.


The documentation for this class was generated from the following files: