OpenTTD Source: NIHelper Class Reference

OpenTTD Source 15.0-RC2

Public Member Functions
NIHelper Class Referenceabstract

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

Inheritance diagram for NIHelper:

## Public Member Functions
virtual | ~NIHelper ()=default
| Silence a warning.
virtual bool | IsInspectable (uint index) const =0
| Is the item with the given index inspectable?
virtual uint | GetParent (uint index) const =0
| Get the parent "window_number" of a given instance.
virtual const void * | GetInstance (uint index) const =0
| Get the instance given an index.
virtual const void * | GetSpec (uint index) const =0
| Get (NewGRF) specs given an index.
virtual std::string | GetName (uint index) const =0
| Get the name of this item.
virtual uint32_t | GetGRFID (uint index) const =0
| Get the GRFID of the file that includes this item.
virtual std::span< const BadgeID > | GetBadges (uint index) const =0
| Get the list of badges of this item.
virtual uint | Resolve (uint index, uint var, uint param, bool &avail) const =0
| Resolve (action2) variable for a given index.
virtual bool | PSAWithParameter () const
| Used to decide if the PSA needs a parameter or not.
virtual const std::span< int32_t > | GetPSA (uint index, uint32_t grfid) const
| Gets the span containing the persistent storage.

## Detailed Description

Helper class to wrap some functionality/queries in.

Definition at line 129 of file newgrf_debug_gui.cpp.

## Member Function Documentation

## ◆ GetBadges()

virtual std::span< const BadgeID > NIHelper::GetBadges | ( | uint | index | ) | const
| pure virtual

Get the list of badges of this item.

Parameters

  index | index to check.

Returns
  List of badges of the item.

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

Referenced by NewGRFInspectWindow::DrawMainPanelWidget().

## ◆ GetGRFID()

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

Get the GRFID of the file that includes this item.

Parameters

  index | index to check.

Returns
  GRFID of the item. 0 means that the item is not inspectable.

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

Referenced by NewGRFInspectWindow::OnClick().

## ◆ GetInstance()

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

Get the instance given an index.

Parameters

  index | the index to get the instance for.

Returns
  the instance.

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

Referenced by NewGRFInspectWindow::DrawMainPanelWidget().

## ◆ GetName()

virtual std::string NIHelper::GetName | ( | uint | index | ) | const
| pure virtual

Get the name of this item.

Parameters

  index | the index to get the name for.

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

Referenced by NewGRFInspectWindow::GetWidgetString().

## ◆ GetParent()

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

Get the parent "window_number" of a given instance.

Parameters

  index | the instance to get the parent for.

Returns
  the parent's window_number or UINT32_MAX if there is none.

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

Referenced by NewGRFInspectWindow::OnClick().

## ◆ GetPSA()

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

Gets the span containing the persistent storage.

Parameters

  index | Index of the item.
  grfid | Parameter for the PSA. Only required for items with parameters.

Returns
  Span of the storage array or an empty span when not present.

Reimplemented in NIHTown, NIHIndustry, and NIHAirport.

Definition at line 207 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

  index | the index to get the specs for for.

Returns
  the specs.

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

Referenced by NewGRFInspectWindow::DrawMainPanelWidget().

## ◆ IsInspectable()

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

Is the item with the given index inspectable?

Parameters

  index | the index to check.

Returns
  true iff the index is inspectable.

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

## ◆ 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 196 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

  index | The (instance) index to resolve the variable for.
  var | The variable to actually resolve.
  param | The varaction2 0x60+x parameter to pass.
  avail | Return whether the variable is available.

Returns
  The resolved variable's value.

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

Referenced by NewGRFInspectWindow::DrawMainPanelWidget().

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

- src/newgrf_debug_gui.cpp