diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp index c3f1b746bb..2293db24ad 100644 --- a/src/newgrf_debug_gui.cpp +++ b/src/newgrf_debug_gui.cpp @@ -11,6 +11,7 @@ #include "stdafx.h" #include +#include #include "window_gui.h" #include "window_func.h" #include "fileio_func.h" @@ -199,6 +200,8 @@ public: return NULL; } + virtual void ExtraInfo(uint index, std::function print) const {} + protected: /** * Helper to make setting the strings easier. @@ -292,6 +295,8 @@ struct NewGRFInspectWindow : Window { Scrollbar *vscroll; + int first_variable_line_index = 0; + /** * Check whether the given variable has a parameter. * @param variable the variable to check. @@ -459,6 +464,17 @@ struct NewGRFInspectWindow : Window { const void *base_spec = nih->GetSpec(index); uint i = 0; + + nih->ExtraInfo(index, [&](const char *buf) { + int offset = i++; + offset -= this->vscroll->GetPosition(); + if (offset < 0 || offset >= this->vscroll->GetCapacity()) return; + + ::DrawString(r.left + LEFT_OFFSET, r.right - RIGHT_OFFSET, r.top + TOP_OFFSET + (offset * this->resize.step_height), buf, TC_BLACK); + }); + + const_cast(this)->first_variable_line_index = i; + if (nif->variables != NULL) { this->DrawString(r, i++, "Variables:"); for (const NIVariable *niv = nif->variables; niv->name != NULL; niv++) { @@ -586,6 +602,8 @@ struct NewGRFInspectWindow : Window { /* Get the line, make sure it's within the boundaries. */ int line = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NGRFI_MAINPANEL, TOP_OFFSET); if (line == INT_MAX) return; + if (line < this->first_variable_line_index) return; + line -= this->first_variable_line_index; /* Find the variable related to the line */ for (const NIVariable *niv = nif->variables; niv->name != NULL; niv++, line--) { diff --git a/src/table/newgrf_debug_data.h b/src/table/newgrf_debug_data.h index afe19bbedb..4a80dbd7b7 100644 --- a/src/table/newgrf_debug_data.h +++ b/src/table/newgrf_debug_data.h @@ -82,6 +82,19 @@ class NIHVehicle : public NIHelper { VehicleResolverObject ro(v->engine_type, v, VehicleResolverObject::WO_CACHED); return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail); } + + /* virtual */ void ExtraInfo(uint index, std::function print) const + { + char buffer[1024]; + Vehicle *v = Vehicle::Get(index); + print("Debug Info:"); + seprintf(buffer, lastof(buffer), " Index: %u", index); + print(buffer); + char *b = buffer; + b += seprintf(b, lastof(buffer), " Flags: "); + b = v->DumpVehicleFlags(b, lastof(buffer)); + print(buffer); + } }; static const NIFeature _nif_vehicle = {