Debug: Allow inspecting industry specs before industry is built
Add debug box to industry chains window
This commit is contained in:
@@ -1887,6 +1887,7 @@ static const NWidgetPart _nested_industry_cargoes_widgets[] = {
|
|||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
|
NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
|
||||||
NWidget(WWT_CAPTION, COLOUR_BROWN, WID_IC_CAPTION), SetDataTip(STR_INDUSTRY_CARGOES_INDUSTRY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
NWidget(WWT_CAPTION, COLOUR_BROWN, WID_IC_CAPTION), SetDataTip(STR_INDUSTRY_CARGOES_INDUSTRY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
||||||
|
NWidget(WWT_DEBUGBOX, COLOUR_BROWN, WID_IC_DEBUG),
|
||||||
NWidget(WWT_SHADEBOX, COLOUR_BROWN),
|
NWidget(WWT_SHADEBOX, COLOUR_BROWN),
|
||||||
NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
|
NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
|
||||||
NWidget(WWT_STICKYBOX, COLOUR_BROWN),
|
NWidget(WWT_STICKYBOX, COLOUR_BROWN),
|
||||||
@@ -2856,6 +2857,7 @@ struct IndustryCargoesWindow : public Window {
|
|||||||
this->vscroll->SetCount(num_indrows);
|
this->vscroll->SetCount(num_indrows);
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
this->NotifySmallmap();
|
this->NotifySmallmap();
|
||||||
|
this->SetWidgetDisabledState(WID_IC_DEBUG, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2927,6 +2929,7 @@ struct IndustryCargoesWindow : public Window {
|
|||||||
this->vscroll->SetCount(num_indrows);
|
this->vscroll->SetCount(num_indrows);
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
this->NotifySmallmap();
|
this->NotifySmallmap();
|
||||||
|
this->SetWidgetDisabledState(WID_IC_DEBUG, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3195,6 +3198,18 @@ struct IndustryCargoesWindow : public Window {
|
|||||||
{
|
{
|
||||||
this->vscroll->SetCapacityFromWidget(this, WID_IC_PANEL, WD_FRAMERECT_TOP + CargoesField::small_height);
|
this->vscroll->SetCapacityFromWidget(this, WID_IC_PANEL, WD_FRAMERECT_TOP + CargoesField::small_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsNewGRFInspectable() const override
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShowNewGRFInspectWindow() const override
|
||||||
|
{
|
||||||
|
if (this->ind_cargo < NUM_INDUSTRYTYPES) {
|
||||||
|
::ShowNewGRFInspectWindow(GSF_INDUSTRIES, this->ind_cargo | (1 << 26));
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const int IndustryCargoesWindow::HOR_TEXT_PADDING = 5; ///< Horizontal padding around the industry type text.
|
const int IndustryCargoesWindow::HOR_TEXT_PADDING = 5; ///< Horizontal padding around the industry type text.
|
||||||
|
@@ -216,6 +216,7 @@ public:
|
|||||||
virtual void ExtraInfo(uint index, NIExtraInfoOutput &output) const {}
|
virtual void ExtraInfo(uint index, NIExtraInfoOutput &output) const {}
|
||||||
virtual void SpriteDump(uint index, DumpSpriteGroupPrinter print) const {}
|
virtual void SpriteDump(uint index, DumpSpriteGroupPrinter print) const {}
|
||||||
virtual bool ShowExtraInfoOnly(uint index) const { return false; };
|
virtual bool ShowExtraInfoOnly(uint index) const { return false; };
|
||||||
|
virtual bool ShowExtraInfoIncludingGRFIDOnly(uint index) const { return false; };
|
||||||
virtual bool ShowSpriteDumpButton(uint index) const { return false; };
|
virtual bool ShowSpriteDumpButton(uint index) const { return false; };
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -618,6 +619,8 @@ struct NewGRFInspectWindow : Window {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nih->ShowExtraInfoIncludingGRFIDOnly(index)) return;
|
||||||
|
|
||||||
const_cast<NewGRFInspectWindow*>(this)->first_variable_line_index = i;
|
const_cast<NewGRFInspectWindow*>(this)->first_variable_line_index = i;
|
||||||
|
|
||||||
if (nif->variables != nullptr) {
|
if (nif->variables != nullptr) {
|
||||||
|
@@ -781,13 +781,40 @@ static const NIVariable _niv_industries[] = {
|
|||||||
|
|
||||||
class NIHIndustry : public NIHelper {
|
class NIHIndustry : public NIHelper {
|
||||||
bool IsInspectable(uint index) const override { return true; }
|
bool IsInspectable(uint index) const override { return true; }
|
||||||
bool ShowExtraInfoOnly(uint index) const override { return GetIndustrySpec(Industry::Get(index)->type)->grf_prop.grffile == nullptr; }
|
|
||||||
bool ShowSpriteDumpButton(uint index) const override { return true; }
|
bool ShowSpriteDumpButton(uint index) const override { return true; }
|
||||||
uint GetParent(uint index) const override { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Industry::Get(index)->town->index); }
|
uint GetParent(uint index) const override { return HasBit(index, 26) ? UINT32_MAX : GetInspectWindowNumber(GSF_FAKE_TOWNS, Industry::Get(index)->town->index); }
|
||||||
const void *GetInstance(uint index)const override { return Industry::Get(index); }
|
const void *GetInstance(uint index)const override { return HasBit(index, 26) ? nullptr : Industry::Get(index); }
|
||||||
const void *GetSpec(uint index) const override { return GetIndustrySpec(Industry::Get(index)->type); }
|
uint32 GetGRFID(uint index) const override { return (!this->ShowExtraInfoOnly(index)) ? ((const IndustrySpec *)this->GetSpec(index))->grf_prop.grffile->grfid : 0; }
|
||||||
void SetStringParameters(uint index) const override { this->SetSimpleStringParameters(STR_INDUSTRY_NAME, index); }
|
|
||||||
uint32 GetGRFID(uint index) const override { return (!this->ShowExtraInfoOnly(index)) ? GetIndustrySpec(Industry::Get(index)->type)->grf_prop.grffile->grfid : 0; }
|
bool ShowExtraInfoOnly(uint index) const override
|
||||||
|
{
|
||||||
|
const IndustrySpec *spec = (const IndustrySpec *)this->GetSpec(index);
|
||||||
|
return spec == nullptr || spec->grf_prop.grffile == nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ShowExtraInfoIncludingGRFIDOnly(uint index) const override
|
||||||
|
{
|
||||||
|
return HasBit(index, 26);
|
||||||
|
}
|
||||||
|
|
||||||
|
const void *GetSpec(uint index) const override
|
||||||
|
{
|
||||||
|
if (HasBit(index, 26)) {
|
||||||
|
return GetIndustrySpec(GB(index, 0, 16));
|
||||||
|
} else {
|
||||||
|
Industry *i = Industry::Get(index);
|
||||||
|
return i != nullptr ? GetIndustrySpec(i->type) : nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetStringParameters(uint index) const override
|
||||||
|
{
|
||||||
|
if (HasBit(index, 26)) {
|
||||||
|
SetDParam(0, GetIndustrySpec(GB(index, 0, 16))->name);
|
||||||
|
} else {
|
||||||
|
this->SetSimpleStringParameters(STR_INDUSTRY_NAME, index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint Resolve(uint index, uint var, uint param, GetVariableExtra *extra) const override
|
uint Resolve(uint index, uint var, uint param, GetVariableExtra *extra) const override
|
||||||
{
|
{
|
||||||
@@ -814,6 +841,8 @@ class NIHIndustry : public NIHelper {
|
|||||||
{
|
{
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
output.print("Debug Info:");
|
output.print("Debug Info:");
|
||||||
|
|
||||||
|
if (!HasBit(index, 26)) {
|
||||||
seprintf(buffer, lastof(buffer), " Index: %u", index);
|
seprintf(buffer, lastof(buffer), " Index: %u", index);
|
||||||
output.print(buffer);
|
output.print(buffer);
|
||||||
const Industry *ind = Industry::GetIfValid(index);
|
const Industry *ind = Industry::GetIfValid(index);
|
||||||
@@ -847,14 +876,17 @@ class NIHIndustry : public NIHelper {
|
|||||||
output.print(buffer);
|
output.print(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
seprintf(buffer, lastof(buffer), " Counter: %u", ind->counter);
|
||||||
|
output.print(buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const IndustrySpec *indsp = GetIndustrySpec(ind->type);
|
const IndustrySpec *indsp = (const IndustrySpec *)this->GetSpec(index);
|
||||||
|
if (indsp) {
|
||||||
seprintf(buffer, lastof(buffer), " CBM_IND_PRODUCTION_CARGO_ARRIVAL: %s", HasBit(indsp->callback_mask, CBM_IND_PRODUCTION_CARGO_ARRIVAL) ? "yes" : "no");
|
seprintf(buffer, lastof(buffer), " CBM_IND_PRODUCTION_CARGO_ARRIVAL: %s", HasBit(indsp->callback_mask, CBM_IND_PRODUCTION_CARGO_ARRIVAL) ? "yes" : "no");
|
||||||
output.print(buffer);
|
output.print(buffer);
|
||||||
seprintf(buffer, lastof(buffer), " CBM_IND_PRODUCTION_256_TICKS: %s", HasBit(indsp->callback_mask, CBM_IND_PRODUCTION_256_TICKS) ? "yes" : "no");
|
seprintf(buffer, lastof(buffer), " CBM_IND_PRODUCTION_256_TICKS: %s", HasBit(indsp->callback_mask, CBM_IND_PRODUCTION_256_TICKS) ? "yes" : "no");
|
||||||
output.print(buffer);
|
output.print(buffer);
|
||||||
seprintf(buffer, lastof(buffer), " Counter: %u", ind->counter);
|
|
||||||
output.print(buffer);
|
|
||||||
if ((_settings_game.economy.industry_cargo_scale_factor != 0) && HasBit(indsp->callback_mask, CBM_IND_PRODUCTION_256_TICKS)) {
|
if ((_settings_game.economy.industry_cargo_scale_factor != 0) && HasBit(indsp->callback_mask, CBM_IND_PRODUCTION_256_TICKS)) {
|
||||||
seprintf(buffer, lastof(buffer), " Counter production interval: %u", ScaleQuantity(INDUSTRY_PRODUCE_TICKS, -_settings_game.economy.industry_cargo_scale_factor));
|
seprintf(buffer, lastof(buffer), " Counter production interval: %u", ScaleQuantity(INDUSTRY_PRODUCE_TICKS, -_settings_game.economy.industry_cargo_scale_factor));
|
||||||
output.print(buffer);
|
output.print(buffer);
|
||||||
@@ -870,10 +902,10 @@ class NIHIndustry : public NIHelper {
|
|||||||
|
|
||||||
/* virtual */ void SpriteDump(uint index, DumpSpriteGroupPrinter print) const override
|
/* virtual */ void SpriteDump(uint index, DumpSpriteGroupPrinter print) const override
|
||||||
{
|
{
|
||||||
const Industry *ind = Industry::GetIfValid(index);
|
const IndustrySpec *spec = (const IndustrySpec *)this->GetSpec(index);
|
||||||
if (ind) {
|
if (spec) {
|
||||||
extern void DumpIndustrySpriteGroup(const IndustrySpec *spec, DumpSpriteGroupPrinter print);
|
extern void DumpIndustrySpriteGroup(const IndustrySpec *spec, DumpSpriteGroupPrinter print);
|
||||||
DumpIndustrySpriteGroup(GetIndustrySpec(ind->type), std::move(print));
|
DumpIndustrySpriteGroup(spec, std::move(print));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -49,6 +49,7 @@ enum IndustryCargoesWidgets {
|
|||||||
WID_IC_SCROLLBAR, ///< Scrollbar of the panel.
|
WID_IC_SCROLLBAR, ///< Scrollbar of the panel.
|
||||||
WID_IC_CARGO_DROPDOWN, ///< Select cargo dropdown.
|
WID_IC_CARGO_DROPDOWN, ///< Select cargo dropdown.
|
||||||
WID_IC_IND_DROPDOWN, ///< Select industry dropdown.
|
WID_IC_IND_DROPDOWN, ///< Select industry dropdown.
|
||||||
|
WID_IC_DEBUG, ///< Debug button
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* WIDGETS_INDUSTRY_WIDGET_H */
|
#endif /* WIDGETS_INDUSTRY_WIDGET_H */
|
||||||
|
Reference in New Issue
Block a user