OpenTTD Source  13.2.1
newgrf_debug_gui.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #include "stdafx.h"
11 #include <stdarg.h>
12 #include "window_gui.h"
13 #include "window_func.h"
15 #include "spritecache.h"
16 #include "string_func.h"
17 #include "strings_func.h"
18 #include "textbuf_gui.h"
19 #include "vehicle_gui.h"
20 #include "zoom_func.h"
21 
22 #include "engine_base.h"
23 #include "industry.h"
24 #include "object_base.h"
25 #include "station_base.h"
26 #include "town.h"
27 #include "vehicle_base.h"
28 #include "train.h"
29 #include "roadveh.h"
30 
31 #include "newgrf_airporttiles.h"
32 #include "newgrf_debug.h"
33 #include "newgrf_object.h"
34 #include "newgrf_spritegroup.h"
35 #include "newgrf_station.h"
36 #include "newgrf_town.h"
37 #include "newgrf_railtype.h"
38 #include "newgrf_industries.h"
39 #include "newgrf_industrytiles.h"
40 
42 
43 #include "table/strings.h"
44 
45 #include "safeguards.h"
46 
48 NewGrfDebugSpritePicker _newgrf_debug_sprite_picker = { SPM_NONE, nullptr, std::vector<SpriteID>() };
49 
55 static inline uint GetFeatureIndex(uint window_number)
56 {
57  return GB(window_number, 0, 24);
58 }
59 
67 static inline uint GetInspectWindowNumber(GrfSpecFeature feature, uint index)
68 {
69  assert((index >> 24) == 0);
70  return (feature << 24) | index;
71 }
72 
77 enum NIType {
80 };
81 
82 typedef const void *NIOffsetProc(const void *b);
83 
85 struct NIProperty {
86  const char *name;
87  NIOffsetProc *offset_proc;
88  byte read_size;
89  byte prop;
90  byte type;
91 };
92 
93 
98 struct NICallback {
99  const char *name;
100  NIOffsetProc *offset_proc;
101  byte read_size;
102  byte cb_bit;
103  uint16 cb_id;
104 };
106 static const int CBM_NO_BIT = UINT8_MAX;
107 
109 struct NIVariable {
110  const char *name;
111  byte var;
112 };
113 
115 class NIHelper {
116 public:
118  virtual ~NIHelper() {}
119 
125  virtual bool IsInspectable(uint index) const = 0;
126 
132  virtual uint GetParent(uint index) const = 0;
133 
139  virtual const void *GetInstance(uint index) const = 0;
140 
146  virtual const void *GetSpec(uint index) const = 0;
147 
152  virtual void SetStringParameters(uint index) const = 0;
153 
159  virtual uint32 GetGRFID(uint index) const = 0;
160 
169  virtual uint Resolve(uint index, uint var, uint param, bool *avail) const = 0;
170 
175  virtual bool PSAWithParameter() const
176  {
177  return false;
178  }
179 
186  virtual uint GetPSASize(uint index, uint32 grfid) const
187  {
188  return 0;
189  }
190 
197  virtual const int32 *GetPSAFirstPosition(uint index, uint32 grfid) const
198  {
199  return nullptr;
200  }
201 
202 protected:
208  void SetSimpleStringParameters(StringID string, uint32 index) const
209  {
210  SetDParam(0, string);
211  SetDParam(1, index);
212  }
213 
214 
221  void SetObjectAtStringParameters(StringID string, uint32 index, TileIndex tile) const
222  {
223  SetDParam(0, STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT);
224  SetDParam(1, string);
225  SetDParam(2, index);
226  SetDParam(3, tile);
227  }
228 };
229 
230 
232 struct NIFeature {
236  const NIHelper *helper;
237 };
238 
239 /* Load all the NewGRF debug data; externalised as it is just a huge bunch of tables. */
240 #include "table/newgrf_debug_data.h"
241 
247 static inline GrfSpecFeature GetFeatureNum(uint window_number)
248 {
249  return (GrfSpecFeature)GB(window_number, 24, 8);
250 }
251 
257 static inline const NIFeature *GetFeature(uint window_number)
258 {
259  GrfSpecFeature idx = GetFeatureNum(window_number);
260  return idx < GSF_FAKE_END ? _nifeatures[idx] : nullptr;
261 }
262 
269 static inline const NIHelper *GetFeatureHelper(uint window_number)
270 {
271  return GetFeature(window_number)->helper;
272 }
273 
277  static uint32 var60params[GSF_FAKE_END][0x20];
278 
280  uint32 caller_grfid;
281 
284 
287 
288  Scrollbar *vscroll;
289 
295  static bool HasVariableParameter(uint variable)
296  {
297  return IsInsideBS(variable, 0x60, 0x20);
298  }
299 
304  void SetCallerGRFID(uint32 grfid)
305  {
306  this->caller_grfid = grfid;
307  this->SetDirty();
308  }
309 
313  bool HasChainIndex() const
314  {
316  return f == GSF_TRAINS || f == GSF_ROADVEHICLES;
317  }
318 
323  uint GetFeatureIndex() const
324  {
325  uint index = ::GetFeatureIndex(this->window_number);
326  if (this->chain_index > 0) {
327  assert(this->HasChainIndex());
328  const Vehicle *v = Vehicle::Get(index);
329  v = v->Move(this->chain_index);
330  if (v != nullptr) index = v->index;
331  }
332  return index;
333  }
334 
339  {
340  if (this->chain_index == 0) return;
341 
342  assert(this->HasChainIndex());
343 
344  const Vehicle *v = Vehicle::Get(::GetFeatureIndex(this->window_number));
345  v = v->Move(this->chain_index);
346  if (v == nullptr) this->chain_index = 0;
347  }
348 
350  {
351  this->CreateNestedTree();
352  this->vscroll = this->GetScrollbar(WID_NGRFI_SCROLLBAR);
353  this->FinishInitNested(wno);
354 
355  this->vscroll->SetCount(0);
356  this->SetWidgetDisabledState(WID_NGRFI_PARENT, GetFeatureHelper(this->window_number)->GetParent(this->GetFeatureIndex()) == UINT32_MAX);
357 
358  this->OnInvalidateData(0, true);
359  }
360 
361  void SetStringParameters(int widget) const override
362  {
363  if (widget != WID_NGRFI_CAPTION) return;
364 
366  }
367 
368  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
369  {
370  switch (widget) {
371  case WID_NGRFI_VEH_CHAIN: {
372  assert(this->HasChainIndex());
374  size->height = std::max(size->height, GetVehicleImageCellSize((VehicleType)(VEH_TRAIN + (f - GSF_TRAINS)), EIT_IN_DEPOT).height + 2 + WidgetDimensions::scaled.bevel.Vertical());
375  break;
376  }
377 
378  case WID_NGRFI_MAINPANEL:
379  resize->height = std::max(11, FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal);
380  resize->width = 1;
381 
382  size->height = 5 * resize->height + WidgetDimensions::scaled.frametext.Vertical();
383  break;
384  }
385  }
386 
393  void WARN_FORMAT(4, 5) DrawString(const Rect &r, int offset, const char *format, ...) const
394  {
395  char buf[1024];
396 
397  va_list va;
398  va_start(va, format);
399  vseprintf(buf, lastof(buf), format, va);
400  va_end(va);
401 
402  offset -= this->vscroll->GetPosition();
403  if (offset < 0 || offset >= this->vscroll->GetCapacity()) return;
404 
405  ::DrawString(r.Shrink(WidgetDimensions::scaled.frametext).Shrink(0, offset * this->resize.step_height, 0, 0), buf, TC_BLACK);
406  }
407 
408  void DrawWidget(const Rect &r, int widget) const override
409  {
410  switch (widget) {
411  case WID_NGRFI_VEH_CHAIN: {
412  const Vehicle *v = Vehicle::Get(this->GetFeatureIndex());
413  int total_width = 0;
414  int sel_start = 0;
415  int sel_end = 0;
416  for (const Vehicle *u = v->First(); u != nullptr; u = u->Next()) {
417  if (u == v) sel_start = total_width;
418  switch (u->type) {
419  case VEH_TRAIN: total_width += Train ::From(u)->GetDisplayImageWidth(); break;
420  case VEH_ROAD: total_width += RoadVehicle::From(u)->GetDisplayImageWidth(); break;
421  default: NOT_REACHED();
422  }
423  if (u == v) sel_end = total_width;
424  }
425 
426  Rect br = r.Shrink(WidgetDimensions::scaled.bevel);
427  int width = br.Width();
428  int skip = 0;
429  if (total_width > width) {
430  int sel_center = (sel_start + sel_end) / 2;
431  if (sel_center > width / 2) skip = std::min(total_width - width, sel_center - width / 2);
432  }
433 
435  int h = GetVehicleImageCellSize((VehicleType)(VEH_TRAIN + (f - GSF_TRAINS)), EIT_IN_DEPOT).height;
436  int y = CenterBounds(br.top, br.bottom, h);
438 
439  /* Highlight the articulated part (this is different to the whole-vehicle highlighting of DrawVehicleImage */
440  if (_current_text_dir == TD_RTL) {
441  DrawFrameRect(r.right - sel_end + skip, y, r.right - sel_start + skip, y + h, COLOUR_WHITE, FR_BORDERONLY);
442  } else {
443  DrawFrameRect(r.left + sel_start - skip, y, r.left + sel_end - skip, y + h, COLOUR_WHITE, FR_BORDERONLY);
444  }
445  break;
446  }
447  }
448 
449  if (widget != WID_NGRFI_MAINPANEL) return;
450 
451  uint index = this->GetFeatureIndex();
452  const NIFeature *nif = GetFeature(this->window_number);
453  const NIHelper *nih = nif->helper;
454  const void *base = nih->GetInstance(index);
455  const void *base_spec = nih->GetSpec(index);
456 
457  uint i = 0;
458  if (nif->variables != nullptr) {
459  this->DrawString(r, i++, "Variables:");
460  for (const NIVariable *niv = nif->variables; niv->name != nullptr; niv++) {
461  bool avail = true;
462  uint param = HasVariableParameter(niv->var) ? NewGRFInspectWindow::var60params[GetFeatureNum(this->window_number)][niv->var - 0x60] : 0;
463  uint value = nih->Resolve(index, niv->var, param, &avail);
464 
465  if (!avail) continue;
466 
467  if (HasVariableParameter(niv->var)) {
468  this->DrawString(r, i++, " %02x[%02x]: %08x (%s)", niv->var, param, value, niv->name);
469  } else {
470  this->DrawString(r, i++, " %02x: %08x (%s)", niv->var, value, niv->name);
471  }
472  }
473  }
474 
475  uint psa_size = nih->GetPSASize(index, this->caller_grfid);
476  const int32 *psa = nih->GetPSAFirstPosition(index, this->caller_grfid);
477  if (psa_size != 0 && psa != nullptr) {
478  if (nih->PSAWithParameter()) {
479  this->DrawString(r, i++, "Persistent storage [%08X]:", BSWAP32(this->caller_grfid));
480  } else {
481  this->DrawString(r, i++, "Persistent storage:");
482  }
483  assert(psa_size % 4 == 0);
484  for (uint j = 0; j < psa_size; j += 4, psa += 4) {
485  this->DrawString(r, i++, " %i: %i %i %i %i", j, psa[0], psa[1], psa[2], psa[3]);
486  }
487  }
488 
489  if (nif->properties != nullptr) {
490  this->DrawString(r, i++, "Properties:");
491  for (const NIProperty *nip = nif->properties; nip->name != nullptr; nip++) {
492  const void *ptr = nip->offset_proc(base);
493  uint value;
494  switch (nip->read_size) {
495  case 1: value = *(const uint8 *)ptr; break;
496  case 2: value = *(const uint16 *)ptr; break;
497  case 4: value = *(const uint32 *)ptr; break;
498  default: NOT_REACHED();
499  }
500 
501  StringID string;
502  SetDParam(0, value);
503  switch (nip->type) {
504  case NIT_INT:
505  string = STR_JUST_INT;
506  break;
507 
508  case NIT_CARGO:
509  string = value != INVALID_CARGO ? CargoSpec::Get(value)->name : STR_QUANTITY_N_A;
510  break;
511 
512  default:
513  NOT_REACHED();
514  }
515 
516  char buffer[64];
517  GetString(buffer, string, lastof(buffer));
518  this->DrawString(r, i++, " %02x: %s (%s)", nip->prop, buffer, nip->name);
519  }
520  }
521 
522  if (nif->callbacks != nullptr) {
523  this->DrawString(r, i++, "Callbacks:");
524  for (const NICallback *nic = nif->callbacks; nic->name != nullptr; nic++) {
525  if (nic->cb_bit != CBM_NO_BIT) {
526  const void *ptr = nic->offset_proc(base_spec);
527  uint value;
528  switch (nic->read_size) {
529  case 1: value = *(const uint8 *)ptr; break;
530  case 2: value = *(const uint16 *)ptr; break;
531  case 4: value = *(const uint32 *)ptr; break;
532  default: NOT_REACHED();
533  }
534 
535  if (!HasBit(value, nic->cb_bit)) continue;
536  this->DrawString(r, i++, " %03x: %s", nic->cb_id, nic->name);
537  } else {
538  this->DrawString(r, i++, " %03x: %s (unmasked)", nic->cb_id, nic->name);
539  }
540  }
541  }
542 
543  /* Not nice and certainly a hack, but it beats duplicating
544  * this whole function just to count the actual number of
545  * elements. Especially because they need to be redrawn. */
546  const_cast<NewGRFInspectWindow*>(this)->vscroll->SetCount(i);
547  }
548 
549  void OnClick(Point pt, int widget, int click_count) override
550  {
551  switch (widget) {
552  case WID_NGRFI_PARENT: {
553  const NIHelper *nih = GetFeatureHelper(this->window_number);
554  uint index = nih->GetParent(this->GetFeatureIndex());
555  ::ShowNewGRFInspectWindow(GetFeatureNum(index), ::GetFeatureIndex(index), nih->GetGRFID(this->GetFeatureIndex()));
556  break;
557  }
558 
559  case WID_NGRFI_VEH_PREV:
560  if (this->chain_index > 0) {
561  this->chain_index--;
562  this->InvalidateData();
563  }
564  break;
565 
566  case WID_NGRFI_VEH_NEXT:
567  if (this->HasChainIndex()) {
568  uint index = this->GetFeatureIndex();
569  Vehicle *v = Vehicle::Get(index);
570  if (v != nullptr && v->Next() != nullptr) {
571  this->chain_index++;
572  this->InvalidateData();
573  }
574  }
575  break;
576 
577  case WID_NGRFI_MAINPANEL: {
578  /* Does this feature have variables? */
579  const NIFeature *nif = GetFeature(this->window_number);
580  if (nif->variables == nullptr) return;
581 
582  /* Get the line, make sure it's within the boundaries. */
583  int line = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NGRFI_MAINPANEL, WidgetDimensions::scaled.frametext.top);
584  if (line == INT_MAX) return;
585 
586  /* Find the variable related to the line */
587  for (const NIVariable *niv = nif->variables; niv->name != nullptr; niv++, line--) {
588  if (line != 1) continue; // 1 because of the "Variables:" line
589 
590  if (!HasVariableParameter(niv->var)) break;
591 
592  this->current_edit_param = niv->var;
593  ShowQueryString(STR_EMPTY, STR_NEWGRF_INSPECT_QUERY_CAPTION, 9, this, CS_HEXADECIMAL, QSF_NONE);
594  }
595  }
596  }
597  }
598 
599  void OnQueryTextFinished(char *str) override
600  {
601  if (StrEmpty(str)) return;
602 
603  NewGRFInspectWindow::var60params[GetFeatureNum(this->window_number)][this->current_edit_param - 0x60] = strtol(str, nullptr, 16);
604  this->SetDirty();
605  }
606 
607  void OnResize() override
608  {
609  this->vscroll->SetCapacityFromWidget(this, WID_NGRFI_MAINPANEL, WidgetDimensions::scaled.frametext.Vertical());
610  }
611 
617  void OnInvalidateData(int data = 0, bool gui_scope = true) override
618  {
619  if (!gui_scope) return;
620  if (this->HasChainIndex()) {
621  this->ValidateChainIndex();
622  this->SetWidgetDisabledState(WID_NGRFI_VEH_PREV, this->chain_index == 0);
623  Vehicle *v = Vehicle::Get(this->GetFeatureIndex());
624  this->SetWidgetDisabledState(WID_NGRFI_VEH_NEXT, v == nullptr || v->Next() == nullptr);
625  }
626  }
627 };
628 
629 /* static */ uint32 NewGRFInspectWindow::var60params[GSF_FAKE_END][0x20] = { {0} }; // Use spec to have 0s in whole array
630 
631 static const NWidgetPart _nested_newgrf_inspect_chain_widgets[] = {
633  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
634  NWidget(WWT_CAPTION, COLOUR_GREY, WID_NGRFI_CAPTION), SetDataTip(STR_NEWGRF_INSPECT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
635  NWidget(WWT_SHADEBOX, COLOUR_GREY),
636  NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
637  NWidget(WWT_STICKYBOX, COLOUR_GREY),
638  EndContainer(),
639  NWidget(WWT_PANEL, COLOUR_GREY),
643  NWidget(WWT_EMPTY, COLOUR_GREY, WID_NGRFI_VEH_CHAIN), SetFill(1, 0), SetResize(1, 0),
644  EndContainer(),
645  EndContainer(),
650  NWidget(WWT_RESIZEBOX, COLOUR_GREY),
651  EndContainer(),
652  EndContainer(),
653 };
654 
655 static const NWidgetPart _nested_newgrf_inspect_widgets[] = {
657  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
658  NWidget(WWT_CAPTION, COLOUR_GREY, WID_NGRFI_CAPTION), SetDataTip(STR_NEWGRF_INSPECT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
659  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_NGRFI_PARENT), SetDataTip(STR_NEWGRF_INSPECT_PARENT_BUTTON, STR_NEWGRF_INSPECT_PARENT_TOOLTIP),
660  NWidget(WWT_SHADEBOX, COLOUR_GREY),
661  NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
662  NWidget(WWT_STICKYBOX, COLOUR_GREY),
663  EndContainer(),
668  NWidget(WWT_RESIZEBOX, COLOUR_GREY),
669  EndContainer(),
670  EndContainer(),
671 };
672 
673 static WindowDesc _newgrf_inspect_chain_desc(
674  WDP_AUTO, "newgrf_inspect_chain", 400, 300,
676  0,
677  _nested_newgrf_inspect_chain_widgets, lengthof(_nested_newgrf_inspect_chain_widgets)
678 );
679 
680 static WindowDesc _newgrf_inspect_desc(
681  WDP_AUTO, "newgrf_inspect", 400, 300,
683  0,
684  _nested_newgrf_inspect_widgets, lengthof(_nested_newgrf_inspect_widgets)
685 );
686 
696 void ShowNewGRFInspectWindow(GrfSpecFeature feature, uint index, const uint32 grfid)
697 {
698  if (!IsNewGRFInspectable(feature, index)) return;
699 
700  WindowNumber wno = GetInspectWindowNumber(feature, index);
701  WindowDesc *desc = (feature == GSF_TRAINS || feature == GSF_ROADVEHICLES) ? &_newgrf_inspect_chain_desc : &_newgrf_inspect_desc;
702  NewGRFInspectWindow *w = AllocateWindowDescFront<NewGRFInspectWindow>(desc, wno, true);
703  w->SetCallerGRFID(grfid);
704 }
705 
715 {
716  if (feature == GSF_INVALID) return;
717 
718  WindowNumber wno = GetInspectWindowNumber(feature, index);
720 }
721 
730 void DeleteNewGRFInspectWindow(GrfSpecFeature feature, uint index)
731 {
732  if (feature == GSF_INVALID) return;
733 
734  WindowNumber wno = GetInspectWindowNumber(feature, index);
736 
737  /* Reinitialise the land information window to remove the "debug" sprite if needed.
738  * Note: Since we might be called from a command here, it is important to not execute
739  * the invalidation immediately. The landinfo window tests commands itself. */
741 }
742 
752 bool IsNewGRFInspectable(GrfSpecFeature feature, uint index)
753 {
754  const NIFeature *nif = GetFeature(GetInspectWindowNumber(feature, index));
755  if (nif == nullptr) return false;
756  return nif->helper->IsInspectable(index);
757 }
758 
765 {
766  switch (GetTileType(tile)) {
767  default: return GSF_INVALID;
768  case MP_RAILWAY: return GSF_RAILTYPES;
769  case MP_ROAD: return IsLevelCrossing(tile) ? GSF_RAILTYPES : GSF_INVALID;
770  case MP_HOUSE: return GSF_HOUSES;
771  case MP_INDUSTRY: return GSF_INDUSTRYTILES;
772  case MP_OBJECT: return GSF_OBJECTS;
773 
774  case MP_STATION:
775  switch (GetStationType(tile)) {
776  case STATION_RAIL: return GSF_STATIONS;
777  case STATION_AIRPORT: return GSF_AIRPORTTILES;
778  default: return GSF_INVALID;
779  }
780  }
781 }
782 
789 {
790  switch (type) {
791  case VEH_TRAIN: return GSF_TRAINS;
792  case VEH_ROAD: return GSF_ROADVEHICLES;
793  case VEH_SHIP: return GSF_SHIPS;
794  case VEH_AIRCRAFT: return GSF_AIRCRAFT;
795  default: return GSF_INVALID;
796  }
797 }
798 
799 
800 
801 /**** Sprite Aligner ****/
802 
805  typedef std::pair<int16, int16> XyOffs;
806 
808  Scrollbar *vscroll;
810 
811  static bool centre;
812  static bool crosshair;
813 
815  {
816  this->CreateNestedTree();
817  this->vscroll = this->GetScrollbar(WID_SA_SCROLLBAR);
818  this->FinishInitNested(wno);
819 
820  this->SetWidgetLoweredState(WID_SA_CENTRE, SpriteAlignerWindow::centre);
821  this->SetWidgetLoweredState(WID_SA_CROSSHAIR, SpriteAlignerWindow::crosshair);
822 
823  /* Oh yes, we assume there is at least one normal sprite! */
824  while (GetSpriteType(this->current_sprite) != ST_NORMAL) this->current_sprite++;
825  }
826 
827  void SetStringParameters(int widget) const override
828  {
829  const Sprite *spr = GetSprite(this->current_sprite, ST_NORMAL);
830  switch (widget) {
831  case WID_SA_CAPTION:
832  SetDParam(0, this->current_sprite);
833  SetDParamStr(1, GetOriginFile(this->current_sprite)->GetSimplifiedFilename());
834  break;
835 
836  case WID_SA_OFFSETS_ABS:
837  SetDParam(0, spr->x_offs);
838  SetDParam(1, spr->y_offs);
839  break;
840 
841  case WID_SA_OFFSETS_REL: {
842  /* Relative offset is new absolute offset - starting absolute offset.
843  * Show 0, 0 as the relative offsets if entry is not in the map (meaning they have not been changed yet).
844  */
845  const auto key_offs_pair = this->offs_start_map.Find(this->current_sprite);
846  if (key_offs_pair != this->offs_start_map.end()) {
847  SetDParam(0, spr->x_offs - key_offs_pair->second.first);
848  SetDParam(1, spr->y_offs - key_offs_pair->second.second);
849  } else {
850  SetDParam(0, 0);
851  SetDParam(1, 0);
852  }
853  break;
854  }
855 
856  default:
857  break;
858  }
859  }
860 
861  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
862  {
863  switch (widget) {
864  case WID_SA_SPRITE:
865  size->height = ScaleGUITrad(200);
866  break;
867  case WID_SA_LIST:
868  SetDParamMaxDigits(0, 6);
869  size->width = GetStringBoundingBox(STR_BLACK_COMMA).width + padding.width;
870  resize->height = FONT_HEIGHT_NORMAL + padding.height;
871  resize->width = 1;
872  fill->height = resize->height;
873  break;
874  default:
875  break;
876  }
877  }
878 
879  void DrawWidget(const Rect &r, int widget) const override
880  {
881  switch (widget) {
882  case WID_SA_SPRITE: {
883  /* Center the sprite ourselves */
884  const Sprite *spr = GetSprite(this->current_sprite, ST_NORMAL);
885  Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
886  int x;
887  int y;
888  if (SpriteAlignerWindow::centre) {
889  x = -UnScaleGUI(spr->x_offs) + (ir.Width() - UnScaleGUI(spr->width)) / 2;
890  y = -UnScaleGUI(spr->y_offs) + (ir.Height() - UnScaleGUI(spr->height)) / 2;
891  } else {
892  x = ir.Width() / 2;
893  y = ir.Height() / 2;
894  }
895 
896  DrawPixelInfo new_dpi;
897  if (!FillDrawPixelInfo(&new_dpi, ir.left, ir.top, ir.Width(), ir.Height())) break;
898  DrawPixelInfo *old_dpi = _cur_dpi;
899  _cur_dpi = &new_dpi;
900 
901  DrawSprite(this->current_sprite, PAL_NONE, x, y, nullptr, ZOOM_LVL_GUI);
902  if (this->crosshair) {
903  GfxDrawLine(x, 0, x, ir.Height() - 1, PC_WHITE, 1, 1);
904  GfxDrawLine(0, y, ir.Width() - 1, y, PC_WHITE, 1, 1);
905  }
906 
907  _cur_dpi = old_dpi;
908 
909  break;
910  }
911 
912  case WID_SA_LIST: {
913  const NWidgetBase *nwid = this->GetWidget<NWidgetBase>(widget);
914  int step_size = nwid->resize_y;
915 
916  std::vector<SpriteID> &list = _newgrf_debug_sprite_picker.sprites;
917  int max = std::min<int>(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), (uint)list.size());
918 
919  Rect ir = r.Shrink(WidgetDimensions::scaled.matrix);
920  for (int i = this->vscroll->GetPosition(); i < max; i++) {
921  SetDParam(0, list[i]);
922  DrawString(ir, STR_BLACK_COMMA, TC_FROMSTRING, SA_RIGHT | SA_FORCE);
923  ir.top += step_size;
924  }
925  break;
926  }
927  }
928  }
929 
930  void OnClick(Point pt, int widget, int click_count) override
931  {
932  switch (widget) {
933  case WID_SA_PREVIOUS:
934  do {
935  this->current_sprite = (this->current_sprite == 0 ? GetMaxSpriteID() : this->current_sprite) - 1;
936  } while (GetSpriteType(this->current_sprite) != ST_NORMAL);
937  this->SetDirty();
938  break;
939 
940  case WID_SA_GOTO:
941  ShowQueryString(STR_EMPTY, STR_SPRITE_ALIGNER_GOTO_CAPTION, 7, this, CS_NUMERAL, QSF_NONE);
942  break;
943 
944  case WID_SA_NEXT:
945  do {
946  this->current_sprite = (this->current_sprite + 1) % GetMaxSpriteID();
947  } while (GetSpriteType(this->current_sprite) != ST_NORMAL);
948  this->SetDirty();
949  break;
950 
951  case WID_SA_PICKER:
952  this->LowerWidget(WID_SA_PICKER);
953  _newgrf_debug_sprite_picker.mode = SPM_WAIT_CLICK;
954  this->SetDirty();
955  break;
956 
957  case WID_SA_LIST: {
958  const NWidgetBase *nwid = this->GetWidget<NWidgetBase>(widget);
959  int step_size = nwid->resize_y;
960 
961  uint i = this->vscroll->GetPosition() + (pt.y - nwid->pos_y) / step_size;
962  if (i < _newgrf_debug_sprite_picker.sprites.size()) {
964  if (GetSpriteType(spr) == ST_NORMAL) this->current_sprite = spr;
965  }
966  this->SetDirty();
967  break;
968  }
969 
970  case WID_SA_UP:
971  case WID_SA_DOWN:
972  case WID_SA_LEFT:
973  case WID_SA_RIGHT: {
974  /*
975  * Yes... this is a hack.
976  *
977  * No... I don't think it is useful to make this less of a hack.
978  *
979  * If you want to align sprites, you just need the number. Generally
980  * the sprite caches are big enough to not remove the sprite from the
981  * cache. If that's not the case, just let the NewGRF developer
982  * increase the cache size instead of storing thousands of offsets
983  * for the incredibly small chance that it's actually going to be
984  * used by someone and the sprite cache isn't big enough for that
985  * particular NewGRF developer.
986  */
987  Sprite *spr = const_cast<Sprite *>(GetSprite(this->current_sprite, ST_NORMAL));
988 
989  /* Remember the original offsets of the current sprite, if not already in mapping. */
990  if (!(this->offs_start_map.Contains(this->current_sprite))) {
991  this->offs_start_map.Insert(this->current_sprite, XyOffs(spr->x_offs, spr->y_offs));
992  }
993  switch (widget) {
994  /* Move eight units at a time if ctrl is pressed. */
995  case WID_SA_UP: spr->y_offs -= _ctrl_pressed ? 8 : 1; break;
996  case WID_SA_DOWN: spr->y_offs += _ctrl_pressed ? 8 : 1; break;
997  case WID_SA_LEFT: spr->x_offs -= _ctrl_pressed ? 8 : 1; break;
998  case WID_SA_RIGHT: spr->x_offs += _ctrl_pressed ? 8 : 1; break;
999  }
1000  /* Of course, we need to redraw the sprite, but where is it used?
1001  * Everywhere is a safe bet. */
1003  break;
1004  }
1005 
1006  case WID_SA_RESET_REL:
1007  /* Reset the starting offsets for the current sprite. */
1008  this->offs_start_map.Erase(this->current_sprite);
1009  this->SetDirty();
1010  break;
1011 
1012  case WID_SA_CENTRE:
1013  SpriteAlignerWindow::centre = !SpriteAlignerWindow::centre;
1014  this->SetWidgetLoweredState(widget, SpriteAlignerWindow::centre);
1015  this->SetDirty();
1016  break;
1017 
1018  case WID_SA_CROSSHAIR:
1019  SpriteAlignerWindow::crosshair = !SpriteAlignerWindow::crosshair;
1020  this->SetWidgetLoweredState(widget, SpriteAlignerWindow::crosshair);
1021  this->SetDirty();
1022  break;
1023  }
1024  }
1025 
1026  void OnQueryTextFinished(char *str) override
1027  {
1028  if (StrEmpty(str)) return;
1029 
1030  this->current_sprite = atoi(str);
1031  if (this->current_sprite >= GetMaxSpriteID()) this->current_sprite = 0;
1032  while (GetSpriteType(this->current_sprite) != ST_NORMAL) {
1033  this->current_sprite = (this->current_sprite + 1) % GetMaxSpriteID();
1034  }
1035  this->SetDirty();
1036  }
1037 
1043  void OnInvalidateData(int data = 0, bool gui_scope = true) override
1044  {
1045  if (!gui_scope) return;
1046  if (data == 1) {
1047  /* Sprite picker finished */
1048  this->RaiseWidget(WID_SA_PICKER);
1049  this->vscroll->SetCount((uint)_newgrf_debug_sprite_picker.sprites.size());
1050  }
1051  }
1052 
1053  void OnResize() override
1054  {
1055  this->vscroll->SetCapacityFromWidget(this, WID_SA_LIST);
1056  }
1057 };
1058 
1059 bool SpriteAlignerWindow::centre = true;
1060 bool SpriteAlignerWindow::crosshair = true;
1061 
1062 static const NWidgetPart _nested_sprite_aligner_widgets[] = {
1064  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
1065  NWidget(WWT_CAPTION, COLOUR_GREY, WID_SA_CAPTION), SetDataTip(STR_SPRITE_ALIGNER_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1066  NWidget(WWT_SHADEBOX, COLOUR_GREY),
1067  NWidget(WWT_STICKYBOX, COLOUR_GREY),
1068  EndContainer(),
1069  NWidget(WWT_PANEL, COLOUR_GREY),
1070  NWidget(NWID_HORIZONTAL), SetPIP(0, 0, 10),
1071  NWidget(NWID_VERTICAL), SetPIP(10, 5, 10),
1073  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SA_PREVIOUS), SetDataTip(STR_SPRITE_ALIGNER_PREVIOUS_BUTTON, STR_SPRITE_ALIGNER_PREVIOUS_TOOLTIP), SetFill(1, 0),
1074  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SA_GOTO), SetDataTip(STR_SPRITE_ALIGNER_GOTO_BUTTON, STR_SPRITE_ALIGNER_GOTO_TOOLTIP), SetFill(1, 0),
1075  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SA_NEXT), SetDataTip(STR_SPRITE_ALIGNER_NEXT_BUTTON, STR_SPRITE_ALIGNER_NEXT_TOOLTIP), SetFill(1, 0),
1076  EndContainer(),
1077  NWidget(NWID_HORIZONTAL), SetPIP(10, 5, 10),
1078  NWidget(NWID_SPACER), SetFill(1, 1),
1079  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_SA_UP), SetDataTip(SPR_ARROW_UP, STR_SPRITE_ALIGNER_MOVE_TOOLTIP), SetResize(0, 0), SetMinimalSize(11, 11),
1080  NWidget(NWID_SPACER), SetFill(1, 1),
1081  EndContainer(),
1082  NWidget(NWID_HORIZONTAL_LTR), SetPIP(10, 5, 10),
1084  NWidget(NWID_SPACER), SetFill(1, 1),
1085  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_SA_LEFT), SetDataTip(SPR_ARROW_LEFT, STR_SPRITE_ALIGNER_MOVE_TOOLTIP), SetResize(0, 0), SetMinimalSize(11, 11),
1086  NWidget(NWID_SPACER), SetFill(1, 1),
1087  EndContainer(),
1088  NWidget(WWT_PANEL, COLOUR_DARK_BLUE, WID_SA_SPRITE), SetDataTip(STR_NULL, STR_SPRITE_ALIGNER_SPRITE_TOOLTIP),
1089  EndContainer(),
1091  NWidget(NWID_SPACER), SetFill(1, 1),
1092  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_SA_RIGHT), SetDataTip(SPR_ARROW_RIGHT, STR_SPRITE_ALIGNER_MOVE_TOOLTIP), SetResize(0, 0), SetMinimalSize(11, 11),
1093  NWidget(NWID_SPACER), SetFill(1, 1),
1094  EndContainer(),
1095  EndContainer(),
1096  NWidget(NWID_HORIZONTAL), SetPIP(10, 5, 10),
1097  NWidget(NWID_SPACER), SetFill(1, 1),
1098  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_SA_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_SPRITE_ALIGNER_MOVE_TOOLTIP), SetResize(0, 0), SetMinimalSize(11, 11),
1099  NWidget(NWID_SPACER), SetFill(1, 1),
1100  EndContainer(),
1101  NWidget(WWT_LABEL, COLOUR_GREY, WID_SA_OFFSETS_ABS), SetDataTip(STR_SPRITE_ALIGNER_OFFSETS_ABS, STR_NULL), SetFill(1, 0), SetPadding(0, 10, 0, 10),
1102  NWidget(WWT_LABEL, COLOUR_GREY, WID_SA_OFFSETS_REL), SetDataTip(STR_SPRITE_ALIGNER_OFFSETS_REL, STR_NULL), SetFill(1, 0), SetPadding(0, 10, 0, 10),
1104  NWidget(WWT_TEXTBTN_2, COLOUR_GREY, WID_SA_CENTRE), SetDataTip(STR_SPRITE_ALIGNER_CENTRE_OFFSET, STR_NULL), SetFill(1, 0),
1105  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SA_RESET_REL), SetDataTip(STR_SPRITE_ALIGNER_RESET_BUTTON, STR_SPRITE_ALIGNER_RESET_TOOLTIP), SetFill(1, 0),
1106  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_SA_CROSSHAIR), SetDataTip(STR_SPRITE_ALIGNER_CROSSHAIR, STR_NULL), SetFill(1, 0),
1107  EndContainer(),
1108  EndContainer(),
1109  NWidget(NWID_VERTICAL), SetPIP(10, 5, 10),
1110  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_SA_PICKER), SetDataTip(STR_SPRITE_ALIGNER_PICKER_BUTTON, STR_SPRITE_ALIGNER_PICKER_TOOLTIP), SetFill(1, 0),
1112  NWidget(WWT_MATRIX, COLOUR_GREY, WID_SA_LIST), SetResize(1, 1), SetMatrixDataTip(1, 0, STR_NULL), SetFill(1, 1), SetScrollbar(WID_SA_SCROLLBAR),
1113  NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_SA_SCROLLBAR),
1114  EndContainer(),
1115  EndContainer(),
1116  EndContainer(),
1117  EndContainer(),
1118 };
1119 
1120 static WindowDesc _sprite_aligner_desc(
1121  WDP_AUTO, "sprite_aligner", 400, 300,
1123  0,
1124  _nested_sprite_aligner_widgets, lengthof(_nested_sprite_aligner_widgets)
1125 );
1126 
1131 {
1132  AllocateWindowDescFront<SpriteAlignerWindow>(&_sprite_aligner_desc, 0);
1133 }
VEH_AIRCRAFT
@ VEH_AIRCRAFT
Aircraft vehicle type.
Definition: vehicle_type.h:27
Train::GetDisplayImageWidth
int GetDisplayImageWidth(Point *offset=nullptr) const
Get the width of a train vehicle image in the GUI.
Definition: train_cmd.cpp:457
PC_WHITE
static const uint8 PC_WHITE
White palette colour.
Definition: gfx_func.h:245
SpriteAlignerWindow::OnResize
void OnResize() override
Called after the window got resized.
Definition: newgrf_debug_gui.cpp:1053
MP_HOUSE
@ MP_HOUSE
A house by a town.
Definition: tile_type.h:51
WID_SA_DOWN
@ WID_SA_DOWN
Move the sprite down.
Definition: newgrf_debug_widget.h:33
INVALID_CARGO
static const byte INVALID_CARGO
Constant representing invalid cargo.
Definition: cargotype.h:54
WID_SA_RESET_REL
@ WID_SA_RESET_REL
Reset relative sprite offset.
Definition: newgrf_debug_widget.h:40
WID_NGRFI_MAINPANEL
@ WID_NGRFI_MAINPANEL
Panel widget containing the actual data.
Definition: newgrf_debug_widget.h:20
InvalidateWindowData
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data, bool gui_scope)
Mark window data of the window of a given class and specific window number as invalid (in need of re-...
Definition: window.cpp:3254
newgrf_station.h
VehicleCellSize::height
uint height
Vehicle cell height.
Definition: vehicle_gui.h:83
Rect::Height
int Height() const
Get height of Rect.
Definition: geometry_type.hpp:85
Pool::PoolItem<&_vehicle_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:337
vehicle_gui.h
NewGRFInspectWindow::chain_index
uint chain_index
For ground vehicles: Index in vehicle chain.
Definition: newgrf_debug_gui.cpp:283
WID_NGRFI_VEH_CHAIN
@ WID_NGRFI_VEH_CHAIN
Display for vehicle chain.
Definition: newgrf_debug_widget.h:19
SetScrollbar
static NWidgetPart SetScrollbar(int index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1210
GB
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
Definition: bitmath_func.hpp:32
train.h
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:27
Scrollbar::GetCapacity
uint16 GetCapacity() const
Gets the number of visible elements of the scrollbar.
Definition: widget_type.h:669
newgrf_debug_widget.h
WID_NGRFI_VEH_PREV
@ WID_NGRFI_VEH_PREV
Go to previous vehicle in chain.
Definition: newgrf_debug_widget.h:17
CBM_NO_BIT
static const int CBM_NO_BIT
Mask to show no bit needs to be enabled for the callback.
Definition: newgrf_debug_gui.cpp:106
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:64
SetPadding
static NWidgetPart SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
Widget part function for setting additional space around a widget.
Definition: widget_type.h:1143
Window::GetScrollbar
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
Definition: window.cpp:319
WC_LAND_INFO
@ WC_LAND_INFO
Land info window; Window numbers:
Definition: window_type.h:143
Rect::Shrink
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Definition: geometry_type.hpp:92
NIT_INT
@ NIT_INT
The property is a simple integer.
Definition: newgrf_debug_gui.cpp:78
NewGRFInspectWindow::var60params
static uint32 var60params[GSF_FAKE_END][0x20]
The value for the variable 60 parameters.
Definition: newgrf_debug_gui.cpp:277
WID_SA_SCROLLBAR
@ WID_SA_SCROLLBAR
Scrollbar for sprite list.
Definition: newgrf_debug_widget.h:39
SpriteAlignerWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: newgrf_debug_gui.cpp:930
Vehicle::Next
Vehicle * Next() const
Get the next vehicle of this vehicle.
Definition: vehicle_base.h:610
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:59
WID_NGRFI_PARENT
@ WID_NGRFI_PARENT
Inspect the parent.
Definition: newgrf_debug_widget.h:16
NewGRFInspectWindow::HasChainIndex
bool HasChainIndex() const
Check whether this feature has chain index, i.e.
Definition: newgrf_debug_gui.cpp:313
WWT_LABEL
@ WWT_LABEL
Centered label.
Definition: widget_type.h:55
NICallback
Representation of the available callbacks with information on when they actually apply.
Definition: newgrf_debug_gui.cpp:98
WWT_DEFSIZEBOX
@ WWT_DEFSIZEBOX
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX)
Definition: widget_type.h:63
Window::CreateNestedTree
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1775
NIType
NIType
The type of a property to show.
Definition: newgrf_debug_gui.cpp:77
NewGrfDebugSpritePicker::sprites
std::vector< SpriteID > sprites
Sprites found.
Definition: newgrf_debug.h:29
WID_SA_LEFT
@ WID_SA_LEFT
Move the sprite to the left.
Definition: newgrf_debug_widget.h:31
NewGrfDebugSpritePicker::mode
NewGrfDebugSpritePickerMode mode
Current state.
Definition: newgrf_debug.h:27
WID_SA_LIST
@ WID_SA_LIST
Queried sprite list.
Definition: newgrf_debug_widget.h:38
Pool::PoolItem::index
Tindex index
Index of this pool item.
Definition: pool_type.hpp:235
InvalidateNewGRFInspectWindow
void InvalidateNewGRFInspectWindow(GrfSpecFeature feature, uint index)
Invalidate the inspect window for a given feature and index.
Definition: newgrf_debug_gui.cpp:714
CargoSpec::Get
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
Definition: cargotype.h:118
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:73
NewGRFInspectWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: newgrf_debug_gui.cpp:408
WWT_MATRIX
@ WWT_MATRIX
Grid of rows and columns.
Definition: widget_type.h:57
NWID_HORIZONTAL_LTR
@ NWID_HORIZONTAL_LTR
Horizontal container that doesn't change the order of the widgets for RTL languages.
Definition: widget_type.h:74
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
UnScaleGUI
static int UnScaleGUI(int value)
Short-hand to apply GUI zoom level.
Definition: zoom_func.h:77
TileIndex
The index/ID of a Tile.
Definition: tile_type.h:85
Scrollbar::SetCount
void SetCount(int num)
Sets the number of elements in the list.
Definition: widget_type.h:717
Sprite::height
uint16 height
Height of the sprite.
Definition: spritecache.h:18
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:38
MP_RAILWAY
@ MP_RAILWAY
A railway.
Definition: tile_type.h:49
vehicle_base.h
SetResize
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:997
zoom_func.h
Sprite::x_offs
int16 x_offs
Number of pixels to shift the sprite to the right.
Definition: spritecache.h:20
GetFeatureHelper
static const NIHelper * GetFeatureHelper(uint window_number)
Get the NIHelper related to the window number.
Definition: newgrf_debug_gui.cpp:269
NIFeature::properties
const NIProperty * properties
The properties associated with this feature.
Definition: newgrf_debug_gui.cpp:233
NIHelper::Resolve
virtual uint Resolve(uint index, uint var, uint param, bool *avail) const =0
Resolve (action2) variable for a given index.
DrawString
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition: gfx.cpp:644
EIT_IN_DETAILS
@ EIT_IN_DETAILS
Vehicle drawn in vehicle details, refit window, ...
Definition: vehicle_type.h:89
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget array.
Definition: widget_type.h:46
MP_INDUSTRY
@ MP_INDUSTRY
Part of an industry.
Definition: tile_type.h:56
newgrf_debug.h
town.h
WWT_PUSHARROWBTN
@ WWT_PUSHARROWBTN
Normal push-button (no toggle button) with arrow caption.
Definition: widget_type.h:106
ST_NORMAL
@ ST_NORMAL
The most basic (normal) sprite.
Definition: gfx_type.h:308
WindowNumber
int32 WindowNumber
Number to differentiate different windows of the same class.
Definition: window_type.h:713
NewGRFInspectWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: newgrf_debug_gui.cpp:617
NICallback::cb_id
uint16 cb_id
The number of the callback.
Definition: newgrf_debug_gui.cpp:103
NICallback::name
const char * name
The human readable name of the callback.
Definition: newgrf_debug_gui.cpp:99
GSF_INVALID
@ GSF_INVALID
An invalid spec feature.
Definition: newgrf.h:92
SA_RIGHT
@ SA_RIGHT
Right align the text (must be a single bit).
Definition: gfx_type.h:336
VEH_ROAD
@ VEH_ROAD
Road vehicle type.
Definition: vehicle_type.h:25
Vehicle
Vehicle data structure.
Definition: vehicle_base.h:224
GetSpriteType
SpriteType GetSpriteType(SpriteID sprite)
Get the sprite type of a given sprite.
Definition: spritecache.cpp:163
NewGRFInspectWindow::current_edit_param
byte current_edit_param
The currently edited parameter, to update the right one.
Definition: newgrf_debug_gui.cpp:286
Scrollbar::GetScrolledRowFromWidget
int GetScrolledRowFromWidget(int clickpos, const Window *const w, int widget, int padding=0) const
Compute the row of a scrolled widget that a user clicked in.
Definition: widget.cpp:2353
WID_SA_SPRITE
@ WID_SA_SPRITE
The actual sprite.
Definition: newgrf_debug_widget.h:34
NIFeature::variables
const NIVariable * variables
The variables associated with this feature.
Definition: newgrf_debug_gui.cpp:235
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:636
SmallMap::Insert
bool Insert(const T &key, const U &data)
Adds new item to this map.
Definition: smallmap_type.hpp:127
NewGRFInspectWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: newgrf_debug_gui.cpp:361
MP_ROAD
@ MP_ROAD
A tile with road (or tram tracks)
Definition: tile_type.h:50
NIHelper
Helper class to wrap some functionality/queries in.
Definition: newgrf_debug_gui.cpp:115
SetDParam
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings_func.h:196
GetVehicleImageCellSize
VehicleCellSize GetVehicleImageCellSize(VehicleType type, EngineImageType image_type)
Get the GUI cell size for a vehicle image.
Definition: depot_gui.cpp:162
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:975
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1111
IsLevelCrossing
static bool IsLevelCrossing(TileIndex t)
Return whether a tile is a level crossing.
Definition: road_map.h:85
IsNewGRFInspectable
bool IsNewGRFInspectable(GrfSpecFeature feature, uint index)
Can we inspect the data given a certain feature and index.
Definition: newgrf_debug_gui.cpp:752
NIProperty
Representation of the data from a NewGRF property.
Definition: newgrf_debug_gui.cpp:85
NIProperty::read_size
byte read_size
Number of bytes (i.e. byte, word, dword etc)
Definition: newgrf_debug_gui.cpp:88
DeleteNewGRFInspectWindow
void DeleteNewGRFInspectWindow(GrfSpecFeature feature, uint index)
Delete inspect window for a given feature and index.
Definition: newgrf_debug_gui.cpp:730
GetStringBoundingBox
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:890
textbuf_gui.h
object_base.h
SmallMap< SpriteID, XyOffs >
random_access_file_type.h
SpriteAlignerWindow::XyOffs
std::pair< int16, int16 > XyOffs
Pair for x and y offsets of the sprite before alignment. First value contains the x offset,...
Definition: newgrf_debug_gui.cpp:805
SpriteID
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition: gfx_type.h:17
WID_SA_RIGHT
@ WID_SA_RIGHT
Move the sprite to the right.
Definition: newgrf_debug_widget.h:32
SpriteAlignerWindow::offs_start_map
SmallMap< SpriteID, XyOffs > offs_start_map
Mapping of starting offsets for the sprites which have been aligned in the sprite aligner window.
Definition: newgrf_debug_gui.cpp:809
WindowDesc
High level window description.
Definition: window_gui.h:102
ShowNewGRFInspectWindow
void ShowNewGRFInspectWindow(GrfSpecFeature feature, uint index, const uint32 grfid)
Show the inspect window for a given feature and index.
Definition: newgrf_debug_gui.cpp:696
window_gui.h
newgrf_airporttiles.h
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:469
NIHelper::IsInspectable
virtual bool IsInspectable(uint index) const =0
Is the item with the given index inspectable?
GetFeature
static const NIFeature * GetFeature(uint window_number)
Get the NIFeature related to the window number.
Definition: newgrf_debug_gui.cpp:257
WDP_AUTO
@ WDP_AUTO
Find a place automatically.
Definition: window_gui.h:90
NIHelper::GetGRFID
virtual uint32 GetGRFID(uint index) const =0
Get the GRFID of the file that includes this item.
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:251
NIHelper::SetStringParameters
virtual void SetStringParameters(uint index) const =0
Set the string parameters to write the right data for a STRINGn.
NICallback::read_size
byte read_size
The number of bytes (i.e. byte, word, dword etc) to read.
Definition: newgrf_debug_gui.cpp:101
_newgrf_debug_sprite_picker
NewGrfDebugSpritePicker _newgrf_debug_sprite_picker
The sprite picker.
Definition: newgrf_debug_gui.cpp:48
Window::height
int height
Height of the window (number of pixels down in y direction)
Definition: window_gui.h:249
NIHelper::GetPSASize
virtual uint GetPSASize(uint index, uint32 grfid) const
Allows to know the size of the persistent storage.
Definition: newgrf_debug_gui.cpp:186
INVALID_VEHICLE
static const VehicleID INVALID_VEHICLE
Constant representing a non-existing vehicle.
Definition: vehicle_type.h:55
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:1008
_nifeatures
static const NIFeature *const _nifeatures[]
Table with all NIFeatures.
Definition: newgrf_debug_data.h:611
MP_OBJECT
@ MP_OBJECT
Contains objects such as transmitters and owned land.
Definition: tile_type.h:58
NIT_CARGO
@ NIT_CARGO
The property is a cargo.
Definition: newgrf_debug_gui.cpp:79
IsInsideBS
static bool IsInsideBS(const T x, const size_t base, const size_t size)
Checks if a value is between a window started at some base point.
Definition: math_func.hpp:214
WID_SA_NEXT
@ WID_SA_NEXT
Skip to the next sprite.
Definition: newgrf_debug_widget.h:29
GetStationType
static StationType GetStationType(TileIndex t)
Get the station type of this tile.
Definition: station_map.h:44
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:104
NWidgetBase
Baseclass for nested widgets.
Definition: widget_type.h:126
SpriteAlignerWindow::current_sprite
SpriteID current_sprite
The currently shown sprite.
Definition: newgrf_debug_gui.cpp:807
GSF_FAKE_END
@ GSF_FAKE_END
End of the fake features.
Definition: newgrf.h:90
SetMatrixDataTip
static NWidgetPart SetMatrixDataTip(uint8 cols, uint8 rows, StringID tip)
Widget part function for setting the data and tooltip of WWT_MATRIX widgets.
Definition: widget_type.h:1129
WID_SA_CAPTION
@ WID_SA_CAPTION
Caption of the window.
Definition: newgrf_debug_widget.h:26
SA_FORCE
@ SA_FORCE
Force the alignment, i.e. don't swap for RTL languages.
Definition: gfx_type.h:346
NICallback::offset_proc
NIOffsetProc * offset_proc
Callback proc to get the actual variable address in memory.
Definition: newgrf_debug_gui.cpp:100
Window::SetWidgetDisabledState
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:321
WID_SA_OFFSETS_REL
@ WID_SA_OFFSETS_REL
The sprite offsets (relative).
Definition: newgrf_debug_widget.h:36
industry.h
safeguards.h
ShowQueryString
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
Definition: misc_gui.cpp:1115
Sprite::width
uint16 width
Width of the sprite.
Definition: spritecache.h:19
StrEmpty
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
Definition: string_func.h:67
Window::ShowNewGRFInspectWindow
virtual void ShowNewGRFInspectWindow() const
Show the NewGRF inspection window.
Definition: window_gui.h:751
NIFeature
Container for all information for a given feature.
Definition: newgrf_debug_gui.cpp:232
SpriteAlignerWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: newgrf_debug_gui.cpp:861
SmallMap::Erase
void Erase(Pair *pair)
Removes given pair from this map.
Definition: smallmap_type.hpp:99
DrawSprite
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Definition: gfx.cpp:1058
NIHelper::GetSpec
virtual const void * GetSpec(uint index) const =0
Get (NewGRF) specs given an index.
NewGRFInspectWindow::caller_grfid
uint32 caller_grfid
GRFID of the caller of this window, 0 if it has no caller.
Definition: newgrf_debug_gui.cpp:280
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
NIHelper::~NIHelper
virtual ~NIHelper()
Silence a warning.
Definition: newgrf_debug_gui.cpp:118
NewGRFInspectWindow::GetFeatureIndex
uint GetFeatureIndex() const
Get the feature index.
Definition: newgrf_debug_gui.cpp:323
stdafx.h
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition: window_gui.h:241
VehicleType
VehicleType
Available vehicle types.
Definition: vehicle_type.h:21
RectPadding::Vertical
uint Vertical() const
Get total vertical padding of RectPadding.
Definition: geometry_type.hpp:65
NewGRFInspectWindow::OnResize
void OnResize() override
Called after the window got resized.
Definition: newgrf_debug_gui.cpp:607
BSWAP32
static uint32 BSWAP32(uint32 x)
Perform a 32 bits endianness bitswap on x.
Definition: bitmath_func.hpp:390
GetInspectWindowNumber
static uint GetInspectWindowNumber(GrfSpecFeature feature, uint index)
Get the window number for the inspect window given a feature and index.
Definition: newgrf_debug_gui.cpp:67
NIHelper::SetObjectAtStringParameters
void SetObjectAtStringParameters(StringID string, uint32 index, TileIndex tile) const
Helper to make setting the strings easier for objects at a specific tile.
Definition: newgrf_debug_gui.cpp:221
Window::InvalidateData
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
Definition: window.cpp:3194
NewGRFInspectWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: newgrf_debug_gui.cpp:549
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:38
EIT_IN_DEPOT
@ EIT_IN_DEPOT
Vehicle drawn in depot.
Definition: vehicle_type.h:88
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:75
WID_NGRFI_VEH_NEXT
@ WID_NGRFI_VEH_NEXT
Go to next vehicle in chain.
Definition: newgrf_debug_widget.h:18
FillDrawPixelInfo
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
Set up a clipping area for only drawing into a certain area.
Definition: gfx.cpp:1786
NIHelper::GetInstance
virtual const void * GetInstance(uint index) const =0
Get the instance given an index.
newgrf_object.h
WWT_TEXTBTN_2
@ WWT_TEXTBTN_2
(Toggle) Button with diff text when clicked
Definition: widget_type.h:54
newgrf_spritegroup.h
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:67
WWT_RESIZEBOX
@ WWT_RESIZEBOX
Resize box (normally at bottom-right of a window)
Definition: widget_type.h:66
NIFeature::callbacks
const NICallback * callbacks
The callbacks associated with this feature.
Definition: newgrf_debug_gui.cpp:234
GetFeatureIndex
static uint GetFeatureIndex(uint window_number)
Get the feature index related to the window number.
Definition: newgrf_debug_gui.cpp:55
newgrf_town.h
GrfSpecFeature
GrfSpecFeature
Definition: newgrf.h:66
string_func.h
spritecache.h
NIHelper::PSAWithParameter
virtual bool PSAWithParameter() const
Used to decide if the PSA needs a parameter or not.
Definition: newgrf_debug_gui.cpp:175
Vehicle::Move
Vehicle * Move(int n)
Get the vehicle at offset n of this vehicle chain.
Definition: vehicle_base.h:652
NewGRFInspectWindow::HasVariableParameter
static bool HasVariableParameter(uint variable)
Check whether the given variable has a parameter.
Definition: newgrf_debug_gui.cpp:295
NIHelper::GetPSAFirstPosition
virtual const int32 * GetPSAFirstPosition(uint index, uint32 grfid) const
Gets the first position of the array containing the persistent storage.
Definition: newgrf_debug_gui.cpp:197
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
WWT_PUSHIMGBTN
@ WWT_PUSHIMGBTN
Normal push-button (no toggle button) with image caption.
Definition: widget_type.h:105
SpriteAlignerWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: newgrf_debug_gui.cpp:1043
NewGrfDebugSpritePicker
Spritepicker of SpriteAligner.
Definition: newgrf_debug.h:26
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1096
newgrf_debug_data.h
station_base.h
strings_func.h
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:82
GetFeatureNum
static GrfSpecFeature GetFeatureNum(uint window_number)
Get the feature number related to the window number.
Definition: newgrf_debug_gui.cpp:247
Vehicle::First
Vehicle * First() const
Get the first vehicle of this vehicle chain.
Definition: vehicle_base.h:623
SpriteAlignerWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: newgrf_debug_gui.cpp:879
GetOriginFile
SpriteFile * GetOriginFile(SpriteID sprite)
Get the SpriteFile of a given sprite.
Definition: spritecache.cpp:174
newgrf_industrytiles.h
RoadVehicle::GetDisplayImageWidth
int GetDisplayImageWidth(Point *offset=nullptr) const
Get the width of a road vehicle image in the GUI.
Definition: roadveh_cmd.cpp:92
SpecializedVehicle< Train, Type >::From
static Train * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
Definition: vehicle_base.h:1183
SpriteAlignerWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: newgrf_debug_gui.cpp:827
WID_NGRFI_SCROLLBAR
@ WID_NGRFI_SCROLLBAR
Scrollbar.
Definition: newgrf_debug_widget.h:21
FONT_HEIGHT_NORMAL
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:206
ShowSpriteAlignerWindow
void ShowSpriteAlignerWindow()
Show the window for aligning sprites.
Definition: newgrf_debug_gui.cpp:1130
GetMaxSpriteID
uint GetMaxSpriteID()
Get a reasonable (upper bound) estimate of the maximum SpriteID used in OpenTTD; there will be no spr...
Definition: spritecache.cpp:221
NIFeature::helper
const NIHelper * helper
The class container all helper functions.
Definition: newgrf_debug_gui.cpp:236
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1229
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1014
NIHelper::GetParent
virtual uint GetParent(uint index) const =0
Get the parent "window_number" of a given instance.
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:48
SpriteAlignerWindow
Window used for aligning sprites.
Definition: newgrf_debug_gui.cpp:804
NWidgetBase::resize_y
uint resize_y
Vertical resize step (0 means not resizable).
Definition: widget_type.h:189
NIProperty::name
const char * name
A (human readable) name for the property.
Definition: newgrf_debug_gui.cpp:86
MP_STATION
@ MP_STATION
A tile of a station.
Definition: tile_type.h:53
Scrollbar::GetPosition
uint16 GetPosition() const
Gets the position of the first visible element in the list.
Definition: widget_type.h:678
WID_SA_GOTO
@ WID_SA_GOTO
Go to a given sprite.
Definition: newgrf_debug_widget.h:28
Sprite::y_offs
int16 y_offs
Number of pixels to shift the sprite downwards.
Definition: spritecache.h:21
CargoSpec::name
StringID name
Name of this type of cargo.
Definition: cargotype.h:71
Window::FinishInitNested
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition: window.cpp:1791
NWID_SPACER
@ NWID_SPACER
Invisible widget that takes some space.
Definition: widget_type.h:77
DrawFrameRect
void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags)
Draw frame rectangle.
Definition: widget.cpp:414
SmallMap::Find
std::vector< Pair >::const_iterator Find(const T &key) const
Finds given key in this map.
Definition: smallmap_type.hpp:41
window_func.h
CenterBounds
static int CenterBounds(int min, int max, int size)
Determine where to draw a centred object inside a widget.
Definition: gfx_func.h:178
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:386
Window::width
int width
width of the window (number of pixels to the right in x direction)
Definition: window_gui.h:248
Scrollbar::SetCapacityFromWidget
void SetCapacityFromWidget(Window *w, int widget, int padding=0)
Set capacity of visible elements from the size and resize properties of a widget.
Definition: widget.cpp:2427
MarkWholeScreenDirty
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition: gfx.cpp:1767
SetPIP
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1191
NIVariable
Representation on the NewGRF variables.
Definition: newgrf_debug_gui.cpp:109
WID_SA_CROSSHAIR
@ WID_SA_CROSSHAIR
Toggle crosshair.
Definition: newgrf_debug_widget.h:42
CloseWindowById
void CloseWindowById(WindowClass cls, WindowNumber number, bool force)
Close a window by its class and window number (if it is open).
Definition: window.cpp:1191
NWidgetBase::pos_y
int pos_y
Vertical position of top-left corner of the widget in the window.
Definition: widget_type.h:200
DrawVehicleImage
void DrawVehicleImage(const Vehicle *v, const Rect &r, VehicleID selection, EngineImageType image_type, int skip)
Draws an image of a vehicle chain.
Definition: vehicle_gui.cpp:1608
engine_base.h
WC_NEWGRF_INSPECT
@ WC_NEWGRF_INSPECT
NewGRF inspect (debug); Window numbers:
Definition: window_type.h:662
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1080
newgrf_industries.h
Window
Data structure for an opened window.
Definition: window_gui.h:213
GetTileType
static TileType GetTileType(TileIndex tile)
Get the tiletype of a given tile.
Definition: tile_map.h:96
VEH_TRAIN
@ VEH_TRAIN
Train vehicle type.
Definition: vehicle_type.h:24
Window::RaiseWidget
void RaiseWidget(byte widget_index)
Marks a widget as raised.
Definition: window_gui.h:412
NIProperty::offset_proc
NIOffsetProc * offset_proc
Callback proc to get the actual variable address in memory.
Definition: newgrf_debug_gui.cpp:87
WID_SA_UP
@ WID_SA_UP
Move the sprite up.
Definition: newgrf_debug_widget.h:30
WID_SA_OFFSETS_ABS
@ WID_SA_OFFSETS_ABS
The sprite offsets (absolute).
Definition: newgrf_debug_widget.h:35
WidgetDimensions::frametext
RectPadding frametext
Offsets within a text frame area.
Definition: window_gui.h:48
GetGrfSpecFeature
GrfSpecFeature GetGrfSpecFeature(TileIndex tile)
Get the GrfSpecFeature associated with the tile.
Definition: newgrf_debug_gui.cpp:764
Rect::Width
int Width() const
Get width of Rect.
Definition: geometry_type.hpp:79
WidgetDimensions::scaled
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition: window_gui.h:68
CS_HEXADECIMAL
@ CS_HEXADECIMAL
Only hexadecimal characters.
Definition: string_type.h:32
NewGRFInspectWindow
Window used for inspecting NewGRFs.
Definition: newgrf_debug_gui.cpp:275
WID_SA_PREVIOUS
@ WID_SA_PREVIOUS
Skip to the previous sprite.
Definition: newgrf_debug_widget.h:27
VEH_SHIP
@ VEH_SHIP
Ship vehicle type.
Definition: vehicle_type.h:26
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:69
Window::LowerWidget
void LowerWidget(byte widget_index)
Marks a widget as lowered.
Definition: window_gui.h:403
SpriteAlignerWindow::OnQueryTextFinished
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
Definition: newgrf_debug_gui.cpp:1026
WC_SPRITE_ALIGNER
@ WC_SPRITE_ALIGNER
Sprite aligner (debug); Window numbers:
Definition: window_type.h:668
NewGRFInspectWindow::WARN_FORMAT
void WARN_FORMAT(4, 5) DrawString(const Rect &r
Helper function to draw a string (line) in the window.
AWV_INCREASE
@ AWV_INCREASE
Arrow to the right or in case of RTL to the left.
Definition: widget_type.h:36
Sprite
Data structure describing a sprite.
Definition: spritecache.h:17
NIHelper::SetSimpleStringParameters
void SetSimpleStringParameters(StringID string, uint32 index) const
Helper to make setting the strings easier.
Definition: newgrf_debug_gui.cpp:208
lastof
#define lastof(x)
Get the last element of an fixed size array.
Definition: stdafx.h:402
SetDParamMaxDigits
void SetDParamMaxDigits(uint n, uint count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
Definition: strings.cpp:111
Window::SetWidgetLoweredState
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:382
NICallback::cb_bit
byte cb_bit
The bit that needs to be set for this callback to be enabled.
Definition: newgrf_debug_gui.cpp:102
TD_RTL
@ TD_RTL
Text is written right-to-left by default.
Definition: strings_type.h:24
_current_text_dir
TextDirection _current_text_dir
Text direction of the currently selected language.
Definition: strings.cpp:49
CS_NUMERAL
@ CS_NUMERAL
Only numeric ones.
Definition: string_type.h:28
SetDParamStr
void SetDParamStr(uint n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
Definition: strings.cpp:297
newgrf_railtype.h
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:53
NewGRFInspectWindow::ValidateChainIndex
void ValidateChainIndex()
Ensure that this->chain_index is in range.
Definition: newgrf_debug_gui.cpp:338
WID_SA_PICKER
@ WID_SA_PICKER
Sprite picker.
Definition: newgrf_debug_widget.h:37
FR_BORDERONLY
@ FR_BORDERONLY
Draw border only, no background.
Definition: window_gui.h:33
NewGRFInspectWindow::OnQueryTextFinished
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
Definition: newgrf_debug_gui.cpp:599
AWV_DECREASE
@ AWV_DECREASE
Arrow to the left or in case of RTL to the right.
Definition: widget_type.h:35
DrawPixelInfo
Data about how and where to blit pixels.
Definition: gfx_type.h:151
NewGRFInspectWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: newgrf_debug_gui.cpp:368
ScaleGUITrad
static RectPadding ScaleGUITrad(const RectPadding &r)
Scale a RectPadding to GUI zoom level.
Definition: widget.cpp:168
roadveh.h
WID_NGRFI_CAPTION
@ WID_NGRFI_CAPTION
The caption bar of course.
Definition: newgrf_debug_widget.h:15
WID_SA_CENTRE
@ WID_SA_CENTRE
Toggle centre sprite.
Definition: newgrf_debug_widget.h:41
NewGRFInspectWindow::SetCallerGRFID
void SetCallerGRFID(uint32 grfid)
Set the GRFID of the item opening this window.
Definition: newgrf_debug_gui.cpp:304
WWT_SHADEBOX
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition: widget_type.h:62
NIProperty::prop
byte prop
The number of the property.
Definition: newgrf_debug_gui.cpp:89
SmallMap::Contains
bool Contains(const T &key) const
Tests whether a key is assigned in this map.
Definition: smallmap_type.hpp:79