OpenTTD Source 20241224-master-gf74b0cf984
|
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. | |
void | Insert (Tspec *spec) |
Insert a spec into the class, and update its index. | |
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. | |
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. | |
static void | Reset () |
Reset the classes, i.e. | |
static Tindex | Allocate (uint32_t global_id) |
Allocate a class with a given global class ID. | |
static void | Assign (Tspec *spec) |
Assign a spec to one of the classes. | |
static uint | GetClassCount () |
Get the number of allocated classes. | |
static uint | GetUIClassCount () |
Get the number of classes available to the user. | |
static NewGRFClass * | Get (Tindex class_index) |
Get a particular class. | |
static const Tspec * | GetByGrf (uint32_t grfid, uint16_t local_id) |
Retrieve a spec by GRF location. | |
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. | |
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. | |
Struct containing information relating to NewGRF classes for stations and airports.
Definition at line 26 of file newgrf_class.h.
using NewGRFClass< Tspec, Tindex, Tmax >::index_type = Tindex |
Definition at line 46 of file newgrf_class.h.
using NewGRFClass< Tspec, Tindex, Tmax >::spec_type = Tspec |
Definition at line 45 of file newgrf_class.h.
|
inline |
Definition at line 52 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, and NewGRFClass< Tspec, Tindex, Tmax >::global_id.
Referenced by NewGRFClass< Tspec, Tindex, Tmax >::InsertDefaults(), ObjectChangeInfo(), ResetObjects(), and StationChangeInfo().
|
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(), BuildAirportWindow::SelectFirstAvailableAirport(), and BuildAirportWindow::UpdateWidgetSize().
|
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 CcRoadStop(), CheckFlatLandRailStation(), CmdBuildRailStation(), CmdBuildRailWaypoint(), CmdBuildRoadStop(), CmdBuildRoadWaypoint(), DrawStationTile(), BuildAirportWindow::DrawWidget(), BuildObjectWindow::DrawWidget(), BuildRoadStationWindow::DrawWidget(), NewGRFClass< Tspec, Tindex, Tmax >::InsertDefaults(), MoveWaypointsToBaseStations(), BuildAirportWindow::OnClick(), BuildRailStationWindow::OnClick(), BuildRoadStationWindow::OnClick(), BuildAirportWindow::OnDropdownSelect(), BuildObjectWindow::OnInvalidateData(), BuildRailStationWindow::OnInvalidateData(), BuildAirportWindow::OnPaint(), BuildRailStationWindow::OnPaint(), BuildObjectWindow::OnPlaceMouseUp(), BuildRoadToolbarWindow::OnPlaceMouseUp(), BuildObjectWindow::OnPlaceObject(), PlaceAirport(), BuildAirportWindow::SelectFirstAvailableAirport(), BuildAirportWindow::SetStringParameters(), BuildObjectWindow::SetStringParameters(), and BuildObjectWindow::UpdateWidgetSize().
|
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.
References NewGRFClass< Tspec, Tindex, Tmax >::classes.
|
static |
Get the number of allocated classes.
Definition at line 93 of file newgrf_class_func.h.
References NewGRFClass< Tspec, Tindex, Tmax >::classes.
Referenced by CcRoadStop(), CmdBuildRailStation(), CmdBuildRailWaypoint(), CmdBuildRoadStop(), and CmdBuildRoadWaypoint().
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 CcRoadStop(), CheckFlatLandRailStation(), CmdBuildRailStation(), CmdBuildRailWaypoint(), CmdBuildRoadStop(), CmdBuildRoadWaypoint(), DrawStationTile(), BuildAirportWindow::DrawWidget(), BuildRoadStationWindow::DrawWidget(), MoveWaypointsToBaseStations(), BuildAirportWindow::OnClick(), BuildRailStationWindow::OnClick(), BuildRoadStationWindow::OnClick(), BuildRailStationWindow::OnInvalidateData(), BuildAirportWindow::OnPaint(), BuildRailStationWindow::OnPaint(), BuildObjectWindow::OnPlaceMouseUp(), BuildObjectWindow::OnPlaceObject(), PlaceAirport(), and BuildAirportWindow::SetStringParameters().
|
inline |
Get the number of allocated specs within the class.
Definition at line 70 of file newgrf_class.h.
Referenced by CmdBuildRailStation(), CmdBuildRailWaypoint(), CmdBuildRoadStop(), CmdBuildRoadWaypoint(), and BuildAirportWindow::OnDropdownSelect().
|
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().
|
inline |
Get the number of potentially user-available specs within the class.
Definition at line 72 of file newgrf_class.h.
References NewGRFClass< Tspec, Tindex, Tmax >::ui_count.
|
inline |
Definition at line 68 of file newgrf_class.h.
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().
bool StationClass::IsUIAvailable | ( | uint | index | ) | const |
Check whether the spec will be available to the user at some point in time.
Definition at line 36 of file newgrf_airport.cpp.
|
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().
Referenced by ResetNewGRFData().
|
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 BuildAirportWindow::DrawWidget(), GetIfClassHasNewStopsByType(), and MoveWaypointsToBaseStations().
|
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 >::GetByGrf(), NewGRFClass< Tspec, Tindex, Tmax >::GetClassCount(), NewGRFClass< Tspec, Tindex, Tmax >::GetUIClassCount(), and NewGRFClass< Tspec, Tindex, Tmax >::Reset().
uint32_t NewGRFClass< Tspec, Tindex, Tmax >::global_id |
Global ID for class, e.g. 'DFLT', 'WAYP', etc.
Definition at line 48 of file newgrf_class.h.
Referenced by NewGRFClass< Tspec, Tindex, Tmax >::Allocate(), IsWaypointClass(), and IsWaypointClass().
|
private |
Index of class within the list of classes.
Definition at line 32 of file newgrf_class.h.
StringID NewGRFClass< Tspec, Tindex, Tmax >::name |
Name of this class.
Definition at line 49 of file newgrf_class.h.
Referenced by NewGRFClass< Tspec, Tindex, Tmax >::InsertDefaults().
|
private |
List of specifications.
Definition at line 33 of file newgrf_class.h.
Referenced by NewGRFClass< Tspec, Tindex, Tmax >::Specs().
|
private |
Number of specs in this class potentially available to the user.
Definition at line 31 of file newgrf_class.h.
Referenced by NewGRFClass< Tspec, Tindex, Tmax >::GetUISpecCount().