Debug: Add GRF debug window support for new landscape rocks

This commit is contained in:
Jonathan G Rennison
2022-12-12 19:15:19 +00:00
parent 1de38b1ca0
commit 2430a5113e
3 changed files with 70 additions and 2 deletions

View File

@@ -13,6 +13,7 @@
#include "../newgrf_roadstop.h"
#include "../newgrf_cargo.h"
#include "../newgrf_newsignals.h"
#include "../newgrf_newlandscape.h"
#include "../date_func.h"
#include "../timetable.h"
#include "../ship.h"
@@ -22,6 +23,7 @@
#include "../string_func_extra.h"
#include "../newgrf_extension.h"
#include "../animated_tile.h"
#include "../clear_map.h"
/* Helper for filling property tables */
#define NIP(prop, base, variable, type, name) { name, (ptrdiff_t)cpp_offsetof(base, variable), cpp_sizeof(base, variable), prop, type }
@@ -1754,6 +1756,54 @@ static const NIFeature _nif_roadstop = {
new NIHRoadStop(),
};
static const NIVariable _niv_newlandscape[] = {
NIV(0x40, "terrain type"),
NIV(0x41, "tile slope"),
NIV(0x42, "tile height"),
NIV(0x43, "tile hash"),
NIV(0x44, "landscape type"),
NIV(0x60, "land info of nearby tiles"),
NIV_END(),
};
class NIHNewLandscape : public NIHelper {
bool IsInspectable(uint index) const override { return true; }
bool ShowExtraInfoOnly(uint index) const override { return _new_landscape_rocks_grfs.empty(); }
bool ShowSpriteDumpButton(uint index) const override { return true; }
uint GetParent(uint index) const override { return UINT32_MAX; }
const void *GetInstance(uint index)const override { return nullptr; }
const void *GetSpec(uint index) const override { return nullptr; }
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_LAI_CLEAR_DESCRIPTION_ROCKS, INVALID_STRING_ID, index); }
uint32 GetGRFID(uint index) const override { return 0; }
uint Resolve(uint index, uint var, uint param, GetVariableExtra *extra) const override
{
if (!IsTileType(index, MP_CLEAR)) return 0;
TileInfo ti;
ti.x = TileX(index);
ti.y = TileY(index);
ti.tileh = GetTilePixelSlope(index, &ti.z);
ti.tile = index;
NewLandscapeResolverObject ro(nullptr, &ti, NEW_LANDSCAPE_ROCKS);
return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, extra);
}
/* virtual */ void SpriteDump(uint index, DumpSpriteGroupPrinter print) const override
{
extern void DumpNewLandscapeRocksSpriteGroups(DumpSpriteGroupPrinter print);
DumpNewLandscapeRocksSpriteGroups(std::move(print));
}
};
static const NIFeature _nif_newlandscape = {
nullptr,
nullptr,
_niv_newlandscape,
new NIHNewLandscape(),
};
/** Table with all NIFeatures. */
static const NIFeature * const _nifeatures[] = {
&_nif_vehicle, // GSF_TRAINS
@@ -1777,7 +1827,7 @@ static const NIFeature * const _nifeatures[] = {
&_nif_roadtype, // GSF_ROADTYPES
&_nif_roadtype, // GSF_TRAMTYPES
&_nif_roadstop, // GSF_ROADSTOPS
nullptr, // GSF_NEWLANDSCAPE
&_nif_newlandscape, // GSF_NEWLANDSCAPE
&_nif_town, // GSF_FAKE_TOWNS
&_nif_station_struct, // GSF_FAKE_STATION_STRUCT
};