OpenTTD Source  20241121-master-g67a0fccfad
NIHelper Class Referenceabstract

Helper class to wrap some functionality/queries in. More...

Inheritance diagram for NIHelper:
NIHAirport NIHAirportTile NIHHouse NIHIndustry NIHIndustryTile NIHObject NIHRailType NIHRoadStop NIHRoadType NIHStation NIHTown NIHVehicle

Public Member Functions

virtual ~NIHelper ()=default
 Silence a warning.
 
virtual bool IsInspectable (uint index) const =0
 Is the item with the given index inspectable? More...
 
virtual uint GetParent (uint index) const =0
 Get the parent "window_number" of a given instance. More...
 
virtual const void * GetInstance (uint index) const =0
 Get the instance given an index. More...
 
virtual const void * GetSpec (uint index) const =0
 Get (NewGRF) specs given an index. More...
 
virtual void SetStringParameters (uint index) const =0
 Set the string parameters to write the right data for a STRINGn. More...
 
virtual uint32_t GetGRFID (uint index) const =0
 Get the GRFID of the file that includes this item. More...
 
virtual uint Resolve (uint index, uint var, uint param, bool &avail) const =0
 Resolve (action2) variable for a given index. More...
 
virtual bool PSAWithParameter () const
 Used to decide if the PSA needs a parameter or not. More...
 
virtual const std::span< int32_t > GetPSA ([[maybe_unused]] uint index, [[maybe_unused]] uint32_t grfid) const
 Gets the span containing the persistent storage. More...
 

Protected Member Functions

void SetSimpleStringParameters (StringID string, uint32_t index) const
 Helper to make setting the strings easier. More...
 
void SetObjectAtStringParameters (StringID string, uint32_t index, TileIndex tile) const
 Helper to make setting the strings easier for objects at a specific tile. More...
 

Detailed Description

Helper class to wrap some functionality/queries in.

Definition at line 118 of file newgrf_debug_gui.cpp.

Member Function Documentation

◆ GetGRFID()

virtual uint32_t NIHelper::GetGRFID ( uint  index) const
pure virtual

Get the GRFID of the file that includes this item.

Parameters
indexindex to check.
Returns
GRFID of the item. 0 means that the item is not inspectable.

Implemented in NIHRoadType, NIHTown, NIHRailType, NIHRoadStop, NIHAirport, NIHAirportTile, NIHObject, NIHIndustry, NIHIndustryTile, NIHHouse, NIHStation, and NIHVehicle.

◆ GetInstance()

virtual const void* NIHelper::GetInstance ( uint  index) const
pure virtual

Get the instance given an index.

Parameters
indexthe index to get the instance for.
Returns
the instance.

Implemented in NIHRoadStop, NIHRoadType, NIHAirportTile, NIHRailType, NIHIndustryTile, NIHHouse, NIHStation, NIHTown, NIHAirport, NIHObject, NIHIndustry, and NIHVehicle.

Referenced by NewGRFInspectWindow::DrawMainPanelWidget().

◆ GetParent()

virtual uint NIHelper::GetParent ( uint  index) const
pure virtual

Get the parent "window_number" of a given instance.

Parameters
indexthe instance to get the parent for.
Returns
the parent's window_number or UINT32_MAX if there is none.

Implemented in NIHRoadType, NIHTown, NIHRailType, NIHRoadStop, NIHAirport, NIHAirportTile, NIHObject, NIHIndustry, NIHIndustryTile, NIHHouse, NIHStation, and NIHVehicle.

◆ GetPSA()

virtual const std::span<int32_t> NIHelper::GetPSA ( [[maybe_unused] ] uint  index,
[[maybe_unused] ] uint32_t  grfid 
) const
inlinevirtual

Gets the span containing the persistent storage.

Parameters
indexIndex of the item.
grfidParameter for the PSA. Only required for items with parameters.
Returns
Span of the storage array or an empty span when not present.

Definition at line 189 of file newgrf_debug_gui.cpp.

Referenced by NewGRFInspectWindow::DrawMainPanelWidget().

◆ GetSpec()

virtual const void* NIHelper::GetSpec ( uint  index) const
pure virtual

Get (NewGRF) specs given an index.

Parameters
indexthe index to get the specs for for.
Returns
the specs.

Implemented in NIHRoadType, NIHTown, NIHRailType, NIHRoadStop, NIHAirport, NIHAirportTile, NIHObject, NIHIndustry, NIHIndustryTile, NIHHouse, NIHStation, and NIHVehicle.

Referenced by NewGRFInspectWindow::DrawMainPanelWidget().

◆ IsInspectable()

virtual bool NIHelper::IsInspectable ( uint  index) const
pure virtual

Is the item with the given index inspectable?

Parameters
indexthe index to check.
Returns
true iff the index is inspectable.

Implemented in NIHRoadType, NIHRailType, NIHRoadStop, NIHTown, NIHAirport, NIHAirportTile, NIHObject, NIHIndustry, NIHIndustryTile, NIHHouse, NIHStation, and NIHVehicle.

Referenced by IsNewGRFInspectable().

◆ PSAWithParameter()

virtual bool NIHelper::PSAWithParameter ( ) const
inlinevirtual

Used to decide if the PSA needs a parameter or not.

Returns
True iff this item has a PSA that requires a parameter.

Reimplemented in NIHTown.

Definition at line 178 of file newgrf_debug_gui.cpp.

Referenced by NewGRFInspectWindow::DrawMainPanelWidget().

◆ Resolve()

virtual uint NIHelper::Resolve ( uint  index,
uint  var,
uint  param,
bool &  avail 
) const
pure virtual

Resolve (action2) variable for a given index.

Parameters
indexThe (instance) index to resolve the variable for.
varThe variable to actually resolve.
paramThe varaction2 0x60+x parameter to pass.
availReturn whether the variable is available.
Returns
The resolved variable's value.

Implemented in NIHRoadType, NIHTown, NIHAirport, NIHAirportTile, NIHRailType, NIHObject, NIHIndustry, NIHIndustryTile, NIHHouse, NIHStation, and NIHVehicle.

Referenced by NewGRFInspectWindow::DrawMainPanelWidget().

◆ SetObjectAtStringParameters()

void NIHelper::SetObjectAtStringParameters ( StringID  string,
uint32_t  index,
TileIndex  tile 
) const
inlineprotected

Helper to make setting the strings easier for objects at a specific tile.

Parameters
stringthe string to draw the object's name
indexthe (instance) index for the string.
tilethe tile the object is at

Definition at line 213 of file newgrf_debug_gui.cpp.

References SetDParam().

Referenced by NIHStation::SetStringParameters(), NIHHouse::SetStringParameters(), NIHIndustryTile::SetStringParameters(), NIHObject::SetStringParameters(), NIHRailType::SetStringParameters(), NIHAirportTile::SetStringParameters(), NIHAirport::SetStringParameters(), NIHRoadType::SetStringParameters(), and NIHRoadStop::SetStringParameters().

◆ SetSimpleStringParameters()

void NIHelper::SetSimpleStringParameters ( StringID  string,
uint32_t  index 
) const
inlineprotected

Helper to make setting the strings easier.

Parameters
stringthe string to actually draw.
indexthe (instance) index for the string.

Definition at line 200 of file newgrf_debug_gui.cpp.

References SetDParam().

Referenced by NIHVehicle::SetStringParameters(), NIHIndustry::SetStringParameters(), and NIHTown::SetStringParameters().

◆ SetStringParameters()

virtual void NIHelper::SetStringParameters ( uint  index) const
pure virtual

Set the string parameters to write the right data for a STRINGn.

Parameters
indexthe index to get the string parameters for.

Implemented in NIHRoadStop, NIHRoadType, NIHTown, NIHAirport, NIHAirportTile, NIHRailType, NIHObject, NIHIndustry, NIHIndustryTile, NIHHouse, NIHStation, and NIHVehicle.


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