|
|
|
@ -11,6 +11,7 @@
|
|
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
#include <functional>
|
|
|
|
|
#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<void(const char *)> 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<NewGRFInspectWindow*>(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--) {
|
|
|
|
|