OpenTTD Source
20241121-master-g67a0fccfad
|
Struct containing information relating to NewGRF classes for stations and airports. More...
#include <newgrf_class.h>
Public Types | |
using | spec_type = Tspec |
using | index_type = Tindex |
Public Member Functions | |
NewGRFClass (uint32_t global_id, StringID name) | |
std::span< Tspec *const > | Specs () const |
Get read-only span of specs of this class. More... | |
void | Insert (Tspec *spec) |
Insert a spec into the class, and update its index. More... | |
Tindex | Index () const |
uint | GetSpecCount () const |
Get the number of allocated specs within the class. | |
uint | GetUISpecCount () const |
Get the number of potentially user-available specs within the class. | |
const Tspec * | GetSpec (uint index) const |
Get a spec from the class at a given index. More... | |
bool | IsUIAvailable (uint index) const |
Check whether the spec will be available to the user at some point in time. | |
Static Public Member Functions | |
static std::span< NewGRFClass< Tspec, Tindex, Tmax > const > | Classes () |
Get read-only span of all classes of this type. More... | |
static void | Reset () |
Reset the classes, i.e. More... | |
static Tindex | Allocate (uint32_t global_id) |
Allocate a class with a given global class ID. More... | |
static void | Assign (Tspec *spec) |
Assign a spec to one of the classes. More... | |
static uint | GetClassCount () |
Get the number of allocated classes. More... | |
static uint | GetUIClassCount () |
Get the number of classes available to the user. More... | |
static NewGRFClass * | Get (Tindex class_index) |
Get a particular class. More... | |
static const Tspec * | GetByGrf (uint32_t grfid, uint16_t local_id) |
Retrieve a spec by GRF location. More... | |
Data Fields | |
uint32_t | global_id |
Global ID for class, e.g. 'DFLT', 'WAYP', etc. | |
StringID | name |
Name of this class. | |
Static Private Member Functions | |
static void | InsertDefaults () |
Initialise the defaults. More... | |
Private Attributes | |
uint | ui_count = 0 |
Number of specs in this class potentially available to the user. | |
Tindex | index = static_cast<Tindex>(0) |
Index of class within the list of classes. | |
std::vector< Tspec * > | spec |
List of specifications. | |
Static Private Attributes | |
static std::vector< NewGRFClass< Tspec, Tindex, Tmax > > | classes |
The actual classes. More... | |
Struct containing information relating to NewGRF classes for stations and airports.
Definition at line 26 of file newgrf_class.h.
|
static |
Allocate a class with a given global class ID.
global_id | The global class id, such as 'DFLT'. |
Definition at line 32 of file newgrf_class_func.h.
References NewGRFClass< Tspec, Tindex, Tmax >::classes.
Referenced by NewGRFClass< Tspec, Tindex, Tmax >::InsertDefaults().
|
static |
Assign a spec to one of the classes.
spec | The spec to assign. |
Definition at line 70 of file newgrf_class_func.h.
References NewGRFClass< Tspec, Tindex, Tmax >::classes.
Referenced by BindAirportSpecs(), and ObjectSpec::BindToClasses().
|
inlinestatic |
Get read-only span of all classes of this type.
Definition at line 64 of file newgrf_class.h.
References NewGRFClass< Tspec, Tindex, Tmax >::classes.
Referenced by BuildAirportWindow::BuildAirportClassDropDown(), GetIfNewStopsByType(), StationPickerCallbacks::HasClassChoice(), WaypointPickerCallbacks::HasClassChoice(), RoadStopPickerCallbacks< roadstoptype >::HasClassChoice(), RoadWaypointPickerCallbacks::HasClassChoice(), ObjectPickerCallbacks::IsActive(), StationPickerCallbacks::IsActive(), WaypointPickerCallbacks::IsActive(), RoadStopPickerCallbacks< roadstoptype >::IsActive(), RoadWaypointPickerCallbacks::IsActive(), and BuildAirportWindow::SelectFirstAvailableAirport().
|
static |
Get a particular class.
class_index | The index of the class. |
Definition at line 82 of file newgrf_class_func.h.
References NewGRFClass< Tspec, Tindex, Tmax >::classes.
Referenced by NewGRFClass< Tspec, Tindex, Tmax >::InsertDefaults(), MoveWaypointsToBaseStations(), BuildObjectWindow::OnInvalidateData(), BuildRailStationWindow::OnInvalidateData(), BuildAirportWindow::OnPaint(), BuildRailStationWindow::OnPaint(), PlaceAirport(), and BuildAirportWindow::SelectFirstAvailableAirport().
|
static |
Retrieve a spec by GRF location.
grfid | GRF ID of spec. |
local_id | Index within GRF file of spec. |
index | Pointer to return the index of the spec in its class. If nullptr then not used. |
Definition at line 128 of file newgrf_class_func.h.
|
static |
Get the number of allocated classes.
Definition at line 93 of file newgrf_class_func.h.
References NewGRFClass< Tspec, Tindex, Tmax >::classes.
const Tspec * NewGRFClass< Tspec, Tindex, Tmax >::GetSpec | ( | uint | index | ) | const |
Get a spec from the class at a given index.
index | The index where to find the spec. |
Definition at line 114 of file newgrf_class_func.h.
Referenced by MoveWaypointsToBaseStations(), BuildObjectWindow::OnInvalidateData(), BuildRailStationWindow::OnInvalidateData(), BuildAirportWindow::OnPaint(), BuildRailStationWindow::OnPaint(), and PlaceAirport().
|
static |
Get the number of classes available to the user.
Definition at line 103 of file newgrf_class_func.h.
References NewGRFClass< Tspec, Tindex, Tmax >::classes.
Referenced by TerraformToolbarWindow::OnInit().
void NewGRFClass< Tspec, Tindex, Tmax >::Insert | ( | Tspec * | spec | ) |
Insert a spec into the class, and update its index.
spec | The spec to insert. |
Definition at line 55 of file newgrf_class_func.h.
|
staticprivate |
Initialise the defaults.
Reset airport classes to their default state.
This includes initialising the defaults classes with an empty entry, for standard airports.
Definition at line 27 of file newgrf_airport.cpp.
References NewGRFClass< Tspec, Tindex, Tmax >::Allocate(), NewGRFClass< Tspec, Tindex, Tmax >::Get(), and NewGRFClass< Tspec, Tindex, Tmax >::name.
Referenced by NewGRFClass< Tspec, Tindex, Tmax >::Reset().
|
static |
Reset the classes, i.e.
clear everything.
Definition at line 16 of file newgrf_class_func.h.
References NewGRFClass< Tspec, Tindex, Tmax >::classes, and NewGRFClass< Tspec, Tindex, Tmax >::InsertDefaults().
|
inline |
Get read-only span of specs of this class.
Definition at line 58 of file newgrf_class.h.
References NewGRFClass< Tspec, Tindex, Tmax >::spec.
Referenced by GetIfClassHasNewStopsByType(), MoveWaypointsToBaseStations(), and BuildAirportWindow::SelectFirstAvailableAirport().
|
inlinestaticprivate |
The actual classes.
Definition at line 39 of file newgrf_class.h.
Referenced by NewGRFClass< Tspec, Tindex, Tmax >::Allocate(), NewGRFClass< Tspec, Tindex, Tmax >::Assign(), NewGRFClass< Tspec, Tindex, Tmax >::Classes(), NewGRFClass< Tspec, Tindex, Tmax >::Get(), NewGRFClass< Tspec, Tindex, Tmax >::GetClassCount(), NewGRFClass< Tspec, Tindex, Tmax >::GetUIClassCount(), and NewGRFClass< Tspec, Tindex, Tmax >::Reset().