OpenTTD Source: PickerCallbacks Class Reference

OpenTTD Source 15.0-beta1

Public Member Functions | Data Fields
PickerCallbacks Class Referenceabstract

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

`#include <picker_gui.h>`

Inheritance diagram for PickerCallbacks:

## Public Member Functions
| PickerCallbacks (const std::string &ini_group)
virtual void | Close (int)
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 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 void | FillUsedItems (std::set< PickerItem > &items)=0
| Fill a set with all items that are used by the current player.
virtual std::set< PickerItem > | UpdateSavedItems (const std::set< PickerItem > &src)=0
| Update link between grfid/localidx and class_index/index in saved items.

## 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.
const std::string | ini_group
| Ini Group for saving favourites.
uint8_t | mode = 0
| Bitmask of `PickerFilterModes`.
std::set< PickerItem > | used
| Set of items used in the current game by the current company.
std::set< PickerItem > | saved
| Set of saved favourite items.

## Detailed Description

Class for PickerClassWindow to collect information and retain state.

Definition at line 37 of file picker_gui.h.

## Constructor & Destructor Documentation

## ◆ PickerCallbacks()

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

Definition at line 44 of file picker_gui.cpp.

## ◆ ~PickerCallbacks()

PickerCallbacks::~PickerCallbacks | ( |  | ) |
| virtual

Definition at line 49 of file picker_gui.cpp.

## Member Function Documentation

## ◆ Close()

virtual void PickerCallbacks::Close | ( | int |  | ) |
| inlinevirtual

Definition at line 42 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.

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

Referenced by PickerWindow::DrawWidget().

## ◆ FillUsedItems()

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

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

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

## ◆ GetClassCount()

virtual int PickerCallbacks::GetClassCount | ( |  | ) | const
| pure virtual

Get the number of classes.

Note
  Used only to estimate space requirements.

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

Referenced by PickerWindow::BuildPickerClassList(), and PickerWindow::BuildPickerTypeList().

## ◆ GetClassName()

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

Get the name of a class.

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

Referenced by PickerWindow::BuildPickerClassList(), ClassTagNameFilter(), and PickerWindow::DrawWidget().

## ◆ GetClassTooltip()

virtual StringID PickerCallbacks::GetClassTooltip | ( |  | ) | const
| pure virtual

Get the tooltip string for the class list.

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

## ◆ GetPickerItem()

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

Get data about an item.

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

Referenced by PickerWindow::BuildPickerTypeList().

## ◆ GetSelectedClass()

virtual int PickerCallbacks::GetSelectedClass | ( |  | ) | const
| pure virtual

Get the index of the selected class.

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

Referenced by PickerWindow::BuildPickerTypeList(), PickerWindow::DrawWidget(), and PickerWindow::OnClick().

## ◆ GetSelectedType()

virtual int PickerCallbacks::GetSelectedType | ( |  | ) | const
| pure virtual

Get the selected type.

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

## ◆ GetTypeCount()

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

Get the number of types in a class.

Note
  Used only to estimate space requirements.

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

Referenced by PickerWindow::BuildPickerTypeList().

## ◆ GetTypeName()

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

Get the item of a type.

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

Referenced by PickerWindow::BuildPickerTypeList(), PickerWindow::DrawWidget(), and TypeTagNameFilter().

## ◆ GetTypeTooltip()

virtual StringID PickerCallbacks::GetTypeTooltip | ( |  | ) | const
| pure virtual

Get the tooltip string for the type grid.

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

## ◆ HasClassChoice()

virtual bool PickerCallbacks::HasClassChoice | ( |  | ) | const
| pure virtual

Are there multiple classes to chose from?

Implemented in PickerCallbacksNewGRFClass< T >, PickerCallbacksNewGRFClass< ObjectClass >, PickerCallbacksNewGRFClass< RoadStopClass >, PickerCallbacksNewGRFClass< StationClass >, StationPickerCallbacks, WaypointPickerCallbacks, RoadStopPickerCallbacks< roadstoptype >, RoadWaypointPickerCallbacks, and HousePickerCallbacks.

## ◆ IsActive()

virtual bool PickerCallbacks::IsActive | ( |  | ) | const
| pure virtual

Should picker class/type selection be enabled?

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

## ◆ IsTypeAvailable()

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

Test if an item is currently buildable.

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

Referenced by PickerWindow::DrawWidget(), and PickerWindow::OnClick().

## ◆ SetSelectedClass()

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

Set the selected class.

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

Referenced by PickerWindow::OnClick().

## ◆ SetSelectedType()

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

Set the selected type.

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

Referenced by PickerWindow::OnClick().

## ◆ UpdateSavedItems()

virtual std::set< PickerItem > PickerCallbacks::UpdateSavedItems | ( | const std::set< PickerItem > & | src | ) |
| pure virtual

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

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

## Field Documentation

## ◆ class_last_filtering

Filtering PickerCallbacks::class_last_filtering = { false, 0 }

Default filtering of PickerClassList.

Definition at line 86 of file picker_gui.h.

## ◆ class_last_sorting

Listing PickerCallbacks::class_last_sorting = { false, 0 }

Default sorting of PickerClassList.

Definition at line 85 of file picker_gui.h.

## ◆ ini_group

const std::string PickerCallbacks::ini_group

Ini Group for saving favourites.

Definition at line 91 of file picker_gui.h.

Referenced by PickerLoadConfig(), and PickerSaveConfig().

## ◆ mode

uint8_t PickerCallbacks::mode = 0

Bitmask of `PickerFilterModes`.

Definition at line 92 of file picker_gui.h.

Referenced by PickerWindow::BuildPickerClassList(), PickerWindow::BuildPickerTypeList(), PickerWindow::OnClick(), and PickerWindow::OnInvalidateData().

## ◆ saved

std::set<PickerItem> PickerCallbacks::saved

Set of saved favourite items.

Definition at line 95 of file picker_gui.h.

Referenced by PickerWindow::BuildPickerClassList(), PickerWindow::BuildPickerTypeList(), PickerWindow::DrawWidget(), PickerWindow::OnClick(), PickerLoadConfig(), and PickerSaveConfig().

## ◆ type_last_filtering

Filtering PickerCallbacks::type_last_filtering = { false, 0 }

Default filtering of PickerTypeList.

Definition at line 89 of file picker_gui.h.

## ◆ type_last_sorting

Listing PickerCallbacks::type_last_sorting = { false, 0 }

Default sorting of PickerTypeList.

Definition at line 88 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 94 of file picker_gui.h.

Referenced by PickerWindow::BuildPickerClassList(), PickerWindow::BuildPickerTypeList(), and PickerWindow::DrawWidget().

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

- src/picker_gui.h
- src/picker_gui.cpp