Add NewGRF debug window info for stations and industries
This commit is contained in:
@@ -89,6 +89,7 @@ enum GrfSpecFeature {
|
||||
GSF_END,
|
||||
|
||||
GSF_FAKE_TOWNS = GSF_END, ///< Fake town GrfSpecFeature for NewGRF debugging (parent scope)
|
||||
GSF_FAKE_STATION_STRUCT, ///< Fake station struct GrfSpecFeature for NewGRF debugging
|
||||
GSF_FAKE_END, ///< End of the fake features
|
||||
|
||||
GSF_INVALID = 0xFF, ///< An invalid spec feature
|
||||
|
@@ -31,6 +31,7 @@
|
||||
#include "linkgraph/linkgraph.h"
|
||||
#include "linkgraph/linkgraphschedule.h"
|
||||
#include "tracerestrict.h"
|
||||
#include "newgrf_debug.h"
|
||||
|
||||
#include "table/strings.h"
|
||||
|
||||
@@ -152,6 +153,7 @@ Station::~Station()
|
||||
}
|
||||
|
||||
DeleteWindowById(WC_STATION_VIEW, index);
|
||||
DeleteNewGRFInspectWindow(GSF_FAKE_STATION_STRUCT, this->index);
|
||||
|
||||
/* Now delete all orders that go to the station */
|
||||
RemoveOrderFromAllVehicles(OT_GOTO_STATION, this->index);
|
||||
|
@@ -35,6 +35,7 @@
|
||||
#include "zoom_func.h"
|
||||
#include "departures_gui.h"
|
||||
#include "zoning.h"
|
||||
#include "newgrf_debug.h"
|
||||
|
||||
#include "widgets/station_widget.h"
|
||||
|
||||
@@ -747,6 +748,7 @@ static const NWidgetPart _nested_station_view_widgets[] = {
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
||||
NWidget(WWT_CAPTION, COLOUR_GREY, WID_SV_CAPTION), SetDataTip(STR_STATION_VIEW_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
||||
NWidget(WWT_DEBUGBOX, COLOUR_GREY),
|
||||
NWidget(WWT_SHADEBOX, COLOUR_GREY),
|
||||
NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
|
||||
NWidget(WWT_STICKYBOX, COLOUR_GREY),
|
||||
@@ -2070,6 +2072,16 @@ struct StationViewWindow : public Window {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool IsNewGRFInspectable() const override
|
||||
{
|
||||
return ::IsNewGRFInspectable(GSF_FAKE_STATION_STRUCT, this->window_number);
|
||||
}
|
||||
|
||||
void ShowNewGRFInspectWindow() const override
|
||||
{
|
||||
::ShowNewGRFInspectWindow(GSF_FAKE_STATION_STRUCT, this->window_number);
|
||||
}
|
||||
};
|
||||
|
||||
const StringID StationViewWindow::_sort_names[] = {
|
||||
|
@@ -394,6 +394,27 @@ class NIHIndustry : public NIHelper {
|
||||
if (i->psa == nullptr) return nullptr;
|
||||
return (int32 *)(&i->psa->storage);
|
||||
}
|
||||
|
||||
void ExtraInfo(uint index, std::function<void(const char *)> print) const override
|
||||
{
|
||||
char buffer[1024];
|
||||
print("Debug Info:");
|
||||
seprintf(buffer, lastof(buffer), " Index: %u", index);
|
||||
print(buffer);
|
||||
const Industry *ind = Industry::GetIfValid(index);
|
||||
if (ind) {
|
||||
if (ind->neutral_station) {
|
||||
seprintf(buffer, lastof(buffer), " Neutral station: %u: %s", ind->neutral_station->index, ind->neutral_station->GetCachedName());
|
||||
print(buffer);
|
||||
}
|
||||
seprintf(buffer, lastof(buffer), " Nearby stations: %u", (uint) ind->stations_near.size());
|
||||
print(buffer);
|
||||
for (const Station *st : ind->stations_near) {
|
||||
seprintf(buffer, lastof(buffer), " %u: %s", st->index, st->GetCachedName());
|
||||
print(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static const NIFeature _nif_industry = {
|
||||
@@ -602,6 +623,49 @@ static const NIFeature _nif_town = {
|
||||
new NIHTown(),
|
||||
};
|
||||
|
||||
class NIHStationStruct : public NIHelper {
|
||||
bool IsInspectable(uint index) const override { return BaseStation::IsValidID(index); }
|
||||
bool ShowExtraInfoOnly(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->SetSimpleStringParameters(STR_STATION_NAME, index); }
|
||||
uint32 GetGRFID(uint index) const override { return 0; }
|
||||
|
||||
uint Resolve(uint index, uint var, uint param, bool *avail) const override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ExtraInfo(uint index, std::function<void(const char *)> print) const override
|
||||
{
|
||||
char buffer[1024];
|
||||
print("Debug Info:");
|
||||
seprintf(buffer, lastof(buffer), " Index: %u", index);
|
||||
print(buffer);
|
||||
const Station *st = Station::GetIfValid(index);
|
||||
if (st) {
|
||||
if (st->industry) {
|
||||
seprintf(buffer, lastof(buffer), " Neutral industry: %u: %s", st->industry->index, st->industry->GetCachedName());
|
||||
print(buffer);
|
||||
}
|
||||
seprintf(buffer, lastof(buffer), " Nearby industries: %u", (uint) st->industries_near.size());
|
||||
print(buffer);
|
||||
for (const Industry *ind : st->industries_near) {
|
||||
seprintf(buffer, lastof(buffer), " %u: %s", ind->index, ind->GetCachedName());
|
||||
print(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static const NIFeature _nif_station_struct = {
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
new NIHStationStruct(),
|
||||
};
|
||||
|
||||
/** Table with all NIFeatures. */
|
||||
static const NIFeature * const _nifeatures[] = {
|
||||
&_nif_vehicle, // GSF_TRAINS
|
||||
@@ -623,5 +687,6 @@ static const NIFeature * const _nifeatures[] = {
|
||||
&_nif_railtype, // GSF_RAILTYPES
|
||||
&_nif_airporttile, // GSF_AIRPORTTILES
|
||||
&_nif_town, // GSF_FAKE_TOWNS
|
||||
&_nif_station_struct, // GSF_FAKE_STATION_STRUCT
|
||||
};
|
||||
assert_compile(lengthof(_nifeatures) == GSF_FAKE_END);
|
||||
|
Reference in New Issue
Block a user