OpenTTD Source 20260218-master-g2123fca5ea
ObjectPickerCallbacks Class Reference
Inheritance diagram for ObjectPickerCallbacks:
PickerCallbacksNewGRFClass< ObjectClass > PickerCallbacks

Public Member Functions

GrfSpecFeature GetFeature () const override
 NewGRF feature this picker is for.
StringID GetClassTooltip () const override
 Get the tooltip string for the class list.
StringID GetTypeTooltip () const override
 Get the tooltip string for the type grid.
StringID GetCollectionTooltip () const override
 Get the tooltip string for the collection list.
bool IsActive () const override
 Should picker class/type selection be enabled?
int GetSelectedClass () const override
 Get the index of the selected class.
void SetSelectedClass (int id) const override
 Set the selected class.
StringID GetClassName (int id) const override
 Get the name of a class.
int GetSelectedType () const override
 Get the selected type.
void SetSelectedType (int id) const override
 Set the selected type.
StringID GetTypeName (int cls_id, int id) const override
 Get the item name of a type.
std::span< const BadgeID > GetTypeBadges (int cls_id, int id) const override
 Get the item's badges of a type.
bool IsTypeAvailable (int cls_id, int id) const override
 Test if an item is currently buildable.
void DrawType (int x, int y, int cls_id, int id) const override
 Draw preview image of an item.
void FillUsedItems (std::set< PickerItem > &items) override
 Fill a set with all items that are used by the current player.
Public Member Functions inherited from PickerCallbacksNewGRFClass< ObjectClass >
 PickerCallbacksNewGRFClass (const std::string &ini_group)
ObjectClass::index_type GetClassIndex (int cls_id) const
const ObjectClassGetClass (int cls_id) const
const ObjectClass::spec_type * GetSpec (int cls_id, int id) const
bool HasClassChoice () const override
 Are there multiple classes to chose from?
int GetClassCount () const override
 Get the number of classes.
int GetTypeCount (int cls_id) const override
 Get the number of types in a class.
PickerItem GetPickerItem (const typename ObjectClass::spec_type *spec, int cls_id=-1, int id=-1) const
std::map< std::string, std::set< PickerItem > > UpdateSavedItems (const std::map< std::string, std::set< PickerItem > > &src) override
 Update link between grfid/localidx and class_index/index in saved items.
Public Member Functions inherited from PickerCallbacks
 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 PickerItem GetPickerItem (int cls_id, int id) const =0
 Get data about an item.
std::set< std::string > InitializeInactiveCollections (const std::map< std::string, std::set< PickerItem > > collections)
 Initialize the list of active collections for sorting purposes.

Static Public Attributes

static ObjectPickerCallbacks instance

Additional Inherited Members

Data Fields inherited from PickerCallbacks
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

Definition at line 45 of file object_gui.cpp.

Constructor & Destructor Documentation

◆ ObjectPickerCallbacks()

ObjectPickerCallbacks::ObjectPickerCallbacks ( )
inline

Definition at line 47 of file object_gui.cpp.

Member Function Documentation

◆ DrawType()

void ObjectPickerCallbacks::DrawType ( int x,
int y,
int cls_id,
int id ) const
inlineoverridevirtual

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.

Implements PickerCallbacks.

Definition at line 97 of file object_gui.cpp.

References _object_gui, DrawNewObjectTileInGUI(), and DrawOrigTileSeqInGUI().

◆ FillUsedItems()

void ObjectPickerCallbacks::FillUsedItems ( std::set< PickerItem > & items)
inlineoverridevirtual

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

Parameters
itemsThe set to fill.

Implements PickerCallbacks.

Definition at line 109 of file object_gui.cpp.

References _current_company, NewGRFSpecBase< Tindex >::class_index, ObjectSpec::Get(), GetTileOwner(), INVALID_OBJECT_CLASS, and ObjectSpec::IsEverAvailable().

◆ GetClassName()

StringID ObjectPickerCallbacks::GetClassName ( int id) const
inlineoverridevirtual

Get the name of a class.

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

Implements PickerCallbacks.

Definition at line 68 of file object_gui.cpp.

References INVALID_STRING_ID.

◆ GetClassTooltip()

StringID ObjectPickerCallbacks::GetClassTooltip ( ) const
inlineoverridevirtual

Get the tooltip string for the class list.

Returns
StringID without parameters for the tooltip.

Implements PickerCallbacks.

Definition at line 51 of file object_gui.cpp.

◆ GetCollectionTooltip()

StringID ObjectPickerCallbacks::GetCollectionTooltip ( ) const
inlineoverridevirtual

Get the tooltip string for the collection list.

Returns
StringID without parameters.

Implements PickerCallbacks.

Definition at line 53 of file object_gui.cpp.

◆ GetFeature()

GrfSpecFeature ObjectPickerCallbacks::GetFeature ( ) const
inlineoverridevirtual

NewGRF feature this picker is for.

Returns
The associated NewGRF feature.

Implements PickerCallbacks.

Definition at line 49 of file object_gui.cpp.

◆ GetSelectedClass()

int ObjectPickerCallbacks::GetSelectedClass ( ) const
inlineoverridevirtual

Get the index of the selected class.

Returns
The previously selected class.

Implements PickerCallbacks.

Definition at line 65 of file object_gui.cpp.

References _object_gui.

◆ GetSelectedType()

int ObjectPickerCallbacks::GetSelectedType ( ) const
inlineoverridevirtual

Get the selected type.

Returns
Previously selected type.

Implements PickerCallbacks.

Definition at line 75 of file object_gui.cpp.

References _object_gui.

◆ GetTypeBadges()

std::span< const BadgeID > ObjectPickerCallbacks::GetTypeBadges ( int cls_id,
int id ) const
inlineoverridevirtual

Get the item's badges of a type.

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

Implements PickerCallbacks.

Definition at line 84 of file object_gui.cpp.

◆ GetTypeName()

StringID ObjectPickerCallbacks::GetTypeName ( int cls_id,
int id ) const
inlineoverridevirtual

Get the item name of a type.

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

Implements PickerCallbacks.

Definition at line 78 of file object_gui.cpp.

References INVALID_STRING_ID.

◆ GetTypeTooltip()

StringID ObjectPickerCallbacks::GetTypeTooltip ( ) const
inlineoverridevirtual

Get the tooltip string for the type grid.

Returns
StringID without parameters.

Implements PickerCallbacks.

Definition at line 52 of file object_gui.cpp.

◆ IsActive()

bool ObjectPickerCallbacks::IsActive ( ) const
inlineoverridevirtual

Should picker class/type selection be enabled?

Returns
true when to show the class/type picker.

Implements PickerCallbacks.

Definition at line 55 of file object_gui.cpp.

References NewGRFClass< ObjectSpec, ObjectClassID, OBJECT_CLASS_MAX >::Classes().

◆ IsTypeAvailable()

bool ObjectPickerCallbacks::IsTypeAvailable ( int cls_id,
int id ) const
inlineoverridevirtual

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.

Implements PickerCallbacks.

Definition at line 91 of file object_gui.cpp.

◆ SetSelectedClass()

void ObjectPickerCallbacks::SetSelectedClass ( int id) const
inlineoverridevirtual

Set the selected class.

Parameters
idThe new selected class.

Implements PickerCallbacks.

Definition at line 66 of file object_gui.cpp.

References _object_gui.

◆ SetSelectedType()

void ObjectPickerCallbacks::SetSelectedType ( int id) const
inlineoverridevirtual

Set the selected type.

Parameters
idThe new type.

Implements PickerCallbacks.

Definition at line 76 of file object_gui.cpp.

References _object_gui.

Field Documentation

◆ instance

ObjectPickerCallbacks ObjectPickerCallbacks::instance
static

Definition at line 119 of file object_gui.cpp.


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