Codechange: Use GetWidgetString for NewGRF debug window. (#13697)

This commit is contained in:
Peter Nelson
2025-03-02 12:46:01 +00:00
committed by GitHub
parent a6f558ce2a
commit 913eadd6b0
2 changed files with 43 additions and 76 deletions

View File

@@ -70,7 +70,7 @@ class NIHVehicle : public NIHelper {
uint GetParent(uint index) const override { const Vehicle *first = Vehicle::Get(index)->First(); return GetInspectWindowNumber(GetGrfSpecFeature(first->type), first->index); }
const void *GetInstance(uint index)const override { return Vehicle::Get(index); }
const void *GetSpec(uint index) const override { return Vehicle::Get(index)->GetEngine(); }
void SetStringParameters(uint index) const override { this->SetSimpleStringParameters(STR_VEHICLE_NAME, index); }
std::string GetName(uint index) const override { return GetString(STR_VEHICLE_NAME, index); }
uint32_t GetGRFID(uint index) const override { return Vehicle::Get(index)->GetGRFID(); }
std::span<const BadgeID> GetBadges(uint index) const override { return Vehicle::Get(index)->GetEngine()->badges; }
@@ -134,7 +134,7 @@ class NIHStation : public NIHelper {
uint GetParent(uint index) const override { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Station::GetByTile(TileIndex{index})->town->index); }
const void *GetInstance(uint ) const override { return nullptr; }
const void *GetSpec(uint index) const override { return GetStationSpec(TileIndex{index}); }
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), TileIndex{index}); }
std::string GetName(uint index) const override { return GetString(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT, STR_STATION_NAME, GetStationIndex(index), index); }
uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? GetStationSpec(TileIndex{index})->grf_prop.grfid : 0; }
std::span<const BadgeID> GetBadges(uint index) const override { return this->IsInspectable(index) ? GetStationSpec(TileIndex{index})->badges : std::span<const BadgeID>{}; }
@@ -199,7 +199,7 @@ class NIHHouse : public NIHelper {
uint GetParent(uint index) const override { return GetInspectWindowNumber(GSF_FAKE_TOWNS, GetTownIndex(index)); }
const void *GetInstance(uint)const override { return nullptr; }
const void *GetSpec(uint index) const override { return HouseSpec::Get(GetHouseType(index)); }
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_TOWN_NAME, GetTownIndex(index), TileIndex{index}); }
std::string GetName(uint index) const override { return GetString(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT, STR_TOWN_NAME, GetTownIndex(index), index); }
uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? HouseSpec::Get(GetHouseType(index))->grf_prop.grfid : 0; }
std::span<const BadgeID> GetBadges(uint index) const override { return HouseSpec::Get(GetHouseType(index))->badges; }
@@ -249,7 +249,7 @@ class NIHIndustryTile : public NIHelper {
uint GetParent(uint index) const override { return GetInspectWindowNumber(GSF_INDUSTRIES, GetIndustryIndex(index)); }
const void *GetInstance(uint)const override { return nullptr; }
const void *GetSpec(uint index) const override { return GetIndustryTileSpec(GetIndustryGfx(index)); }
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_INDUSTRY_NAME, GetIndustryIndex(index), TileIndex{index}); }
std::string GetName(uint index) const override { return GetString(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT, STR_INDUSTRY_NAME, GetIndustryIndex(index), index); }
uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? GetIndustryTileSpec(GetIndustryGfx(index))->grf_prop.grfid : 0; }
std::span<const BadgeID> GetBadges(uint index) const override { return GetIndustryTileSpec(GetIndustryGfx(index))->badges; }
@@ -361,7 +361,7 @@ class NIHIndustry : public NIHelper {
uint GetParent(uint index) const override { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Industry::Get(index)->town->index); }
const void *GetInstance(uint index)const override { return Industry::Get(index); }
const void *GetSpec(uint index) const override { return GetIndustrySpec(Industry::Get(index)->type); }
void SetStringParameters(uint index) const override { this->SetSimpleStringParameters(STR_INDUSTRY_NAME, index); }
std::string GetName(uint index) const override { return GetString(STR_INDUSTRY_NAME, index); }
uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? GetIndustrySpec(Industry::Get(index)->type)->grf_prop.grfid : 0; }
std::span<const BadgeID> GetBadges(uint index) const override { return GetIndustrySpec(Industry::Get(index)->type)->badges; }
@@ -423,7 +423,7 @@ class NIHObject : public NIHelper {
uint GetParent(uint index) const override { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Object::GetByTile(TileIndex{index})->town->index); }
const void *GetInstance(uint index)const override { return Object::GetByTile(TileIndex{index}); }
const void *GetSpec(uint index) const override { return ObjectSpec::GetByTile(TileIndex{index}); }
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_OBJECT, INVALID_STRING_ID, TileIndex{index}); }
std::string GetName(uint index) const override { return GetString(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT, STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_OBJECT, INVALID_STRING_ID, index); }
uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? ObjectSpec::GetByTile(TileIndex{index})->grf_prop.grfid : 0; }
std::span<const BadgeID> GetBadges(uint index) const override { return ObjectSpec::GetByTile(TileIndex{index})->badges; }
@@ -458,7 +458,7 @@ class NIHRailType : public NIHelper {
uint GetParent(uint) const override { return UINT32_MAX; }
const void *GetInstance(uint) const override { return nullptr; }
const void *GetSpec(uint) const override { return nullptr; }
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_RAIL_TYPE, INVALID_STRING_ID, TileIndex{index}); }
std::string GetName(uint index) const override { return GetString(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT, STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_RAIL_TYPE, INVALID_STRING_ID, index); }
uint32_t GetGRFID(uint) const override { return 0; }
std::span<const BadgeID> GetBadges(uint index) const override { return GetRailTypeInfo(GetRailType(TileIndex{index}))->badges; }
@@ -494,7 +494,7 @@ class NIHAirportTile : public NIHelper {
uint GetParent(uint index) const override { return GetInspectWindowNumber(GSF_AIRPORTS, GetStationIndex(index)); }
const void *GetInstance(uint)const override { return nullptr; }
const void *GetSpec(uint index) const override { return AirportTileSpec::Get(GetAirportGfx(index)); }
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), TileIndex{index}); }
std::string GetName(uint index) const override { return GetString(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT, STR_STATION_NAME, GetStationIndex(index), index); }
uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? AirportTileSpec::Get(GetAirportGfx(index))->grf_prop.grfid : 0; }
std::span<const BadgeID> GetBadges(uint index) const override { return AirportTileSpec::Get(GetAirportGfx(index))->badges; }
@@ -536,7 +536,7 @@ class NIHAirport : public NIHelper {
uint GetParent(uint index) const override { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Station::Get(index)->town->index); }
const void *GetInstance(uint index)const override { return Station::Get(index); }
const void *GetSpec(uint index) const override { return AirportSpec::Get(Station::Get(index)->airport.type); }
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_STATION_NAME, index, Station::Get(index)->airport.tile); }
std::string GetName(uint index) const override { return GetString(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT, STR_STATION_NAME, index, Station::Get(index)->airport.tile); }
uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? AirportSpec::Get(Station::Get(index)->airport.type)->grf_prop.grfid : 0; }
std::span<const BadgeID> GetBadges(uint index) const override { return AirportSpec::Get(Station::Get(index)->airport.type)->badges; }
@@ -582,7 +582,7 @@ class NIHTown : public NIHelper {
uint GetParent(uint) const override { return UINT32_MAX; }
const void *GetInstance(uint index)const override { return Town::Get(index); }
const void *GetSpec(uint) const override { return nullptr; }
void SetStringParameters(uint index) const override { this->SetSimpleStringParameters(STR_TOWN_NAME, index); }
std::string GetName(uint index) const override { return GetString(STR_TOWN_NAME, index); }
uint32_t GetGRFID(uint) const override { return 0; }
bool PSAWithParameter() const override { return true; }
std::span<const BadgeID> GetBadges(uint) const override { return {}; }
@@ -628,7 +628,7 @@ class NIHRoadType : public NIHelper {
uint GetParent(uint) const override { return UINT32_MAX; }
const void *GetInstance(uint) const override { return nullptr; }
const void *GetSpec(uint) const override { return nullptr; }
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_ROAD_TYPE, INVALID_STRING_ID, TileIndex{index}); }
std::string GetName(uint index) const override { return GetString(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT, STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_ROAD_TYPE, INVALID_STRING_ID, index); }
uint32_t GetGRFID(uint) const override { return 0; }
std::span<const BadgeID> GetBadges(uint index) const override
{
@@ -698,7 +698,7 @@ class NIHRoadStop : public NIHelper {
uint GetParent(uint index) const override { return GetInspectWindowNumber(GSF_FAKE_TOWNS, BaseStation::GetByTile(TileIndex{index})->town->index); }
const void *GetInstance(uint)const override { return nullptr; }
const void *GetSpec(uint index) const override { return GetRoadStopSpec(TileIndex{index}); }
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), TileIndex{index}); }
std::string GetName(uint index) const override { return GetString(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT, STR_STATION_NAME, GetStationIndex(index), index); }
uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? GetRoadStopSpec(TileIndex{index})->grf_prop.grfid : 0; }
std::span<const BadgeID> GetBadges(uint index) const override { return this->IsInspectable(index) ? GetRoadStopSpec(TileIndex{index})->badges : std::span<const BadgeID>{}; }