OpenTTD Source  14.0-beta3
object_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 "command_func.h"
12 #include "hotkeys.h"
13 #include "newgrf.h"
14 #include "newgrf_object.h"
15 #include "newgrf_text.h"
16 #include "object.h"
17 #include "querystring_gui.h"
18 #include "sortlist_type.h"
19 #include "stringfilter_type.h"
20 #include "string_func.h"
21 #include "strings_func.h"
22 #include "viewport_func.h"
23 #include "tilehighlight_func.h"
24 #include "window_gui.h"
25 #include "window_func.h"
26 #include "zoom_func.h"
27 #include "terraform_cmd.h"
28 #include "object_cmd.h"
29 #include "road_cmd.h"
30 
31 #include "widgets/object_widget.h"
32 
33 #include "table/strings.h"
34 
35 #include "safeguards.h"
36 
39 static uint8_t _selected_object_view;
40 
44 };
45 
47 class BuildObjectWindow : public Window {
49 
50  static const uint EDITBOX_MAX_SIZE = 16;
51 
56 
64 
67  {
68  uint pos = 0;
69  for (auto object_class_id : this->object_classes) {
70  if (object_class_id == _selected_object_class) break;
71  pos++;
72  }
73  this->vscroll->ScrollTowards(pos);
74  }
75 
81  {
82  if (_selected_object_index == -1) return false;
83 
85  if ((int)objclass->GetSpecCount() <= _selected_object_index) return false;
86 
87  return objclass->GetSpec(_selected_object_index)->IsAvailable();
88  }
89 
90 public:
92  {
93  this->CreateNestedTree();
94 
95  this->vscroll = this->GetScrollbar(WID_BO_SCROLLBAR);
96 
98 
99  this->object_classes.SetListing(this->last_sorting);
100  this->object_classes.SetFiltering(this->last_filtering);
101  this->object_classes.SetSortFuncs(this->sorter_funcs);
102  this->object_classes.SetFilterFuncs(this->filter_funcs);
103  this->object_classes.ForceRebuild();
104 
107 
108  this->FinishInitNested(number);
109 
110  NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BO_SELECT_MATRIX);
112  matrix->SetCount(ObjectClass::Get(_selected_object_class)->GetUISpecCount());
113 
114  this->GetWidget<NWidgetMatrix>(WID_BO_OBJECT_MATRIX)->SetCount(4);
115 
117 
118  this->vscroll->SetCount(this->object_classes.size());
119 
121 
122  this->InvalidateData();
123  }
124 
126  static bool ObjectClassIDSorter(ObjectClassID const &a, ObjectClassID const &b)
127  {
128  return a < b;
129  }
130 
132  static bool CDECL TagNameFilter(ObjectClassID const *oc, StringFilter &filter)
133  {
134  ObjectClass *objclass = ObjectClass::Get(*oc);
135 
136  filter.ResetState();
137  filter.AddLine(GetString(objclass->name));
138  return filter.GetState();
139  }
140 
143  {
144  if (!this->object_classes.NeedRebuild()) return;
145 
146  this->object_classes.clear();
147 
148  for (uint i = 0; i < ObjectClass::GetClassCount(); i++) {
150  if (objclass->GetUISpecCount() == 0) continue; // Is this needed here?
151  object_classes.push_back((ObjectClassID)i);
152  }
153 
154  this->object_classes.Filter(this->string_filter);
155  this->object_classes.shrink_to_fit();
156  this->object_classes.RebuildDone();
157  this->object_classes.Sort();
158 
159  this->vscroll->SetCount(this->object_classes.size());
160  }
161 
167  {
168  assert(!this->object_classes.empty()); // object GUI should be disabled elsewise
170  /* This happens during the first time the window is open during the game life cycle. */
171  this->SelectOtherClass(this->object_classes[0]);
172  } else {
173  /* Check if the previously selected object class is not available anymore as a
174  * result of starting a new game without the corresponding NewGRF. */
175  bool available = _selected_object_class < ObjectClass::GetClassCount();
176  this->SelectOtherClass(available ? _selected_object_class : this->object_classes[0]);
177  }
178 
179  if (this->CanRestoreSelectedObject()) {
181  } else {
182  this->SelectFirstAvailableObject(true);
183  }
184  assert(ObjectClass::Get(_selected_object_class)->GetUISpecCount() > 0); // object GUI should be disabled elsewise
185  }
186 
187  void SetStringParameters(WidgetID widget) const override
188  {
189  switch (widget) {
190  case WID_BO_OBJECT_NAME: {
192  const ObjectSpec *spec = objclass->GetSpec(_selected_object_index);
193  SetDParam(0, spec != nullptr ? spec->name : STR_EMPTY);
194  break;
195  }
196 
197  case WID_BO_OBJECT_SIZE: {
199  const ObjectSpec *spec = objclass->GetSpec(_selected_object_index);
200  int size = spec == nullptr ? 0 : spec->size;
201  SetDParam(0, GB(size, HasBit(_selected_object_view, 0) ? 4 : 0, 4));
202  SetDParam(1, GB(size, HasBit(_selected_object_view, 0) ? 0 : 4, 4));
203  break;
204  }
205 
206  default: break;
207  }
208  }
209 
210  void OnInit() override
211  {
212  this->object_margin = ScaleGUITrad(4);
213  }
214 
215  void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
216  {
217  switch (widget) {
218  case WID_BO_CLASS_LIST: {
219  for (auto object_class_id : this->object_classes) {
220  ObjectClass *objclass = ObjectClass::Get(object_class_id);
221  if (objclass->GetUISpecCount() == 0) continue;
222  size->width = std::max(size->width, GetStringBoundingBox(objclass->name).width + padding.width);
223  }
224  this->line_height = GetCharacterHeight(FS_NORMAL) + padding.height;
225  resize->height = this->line_height;
226  size->height = 5 * this->line_height;
227  break;
228  }
229 
230  case WID_BO_OBJECT_NAME:
231  case WID_BO_OBJECT_SIZE:
232  /* We do not want the window to resize when selecting objects; better clip texts */
233  size->width = 0;
234  break;
235 
236  case WID_BO_OBJECT_MATRIX: {
237  /* Get the right amount of buttons based on the current spec. */
239  const ObjectSpec *spec = objclass->GetSpec(_selected_object_index);
240  if (spec != nullptr) {
241  if (spec->views >= 2) size->width += resize->width;
242  if (spec->views >= 4) size->height += resize->height;
243  }
244  resize->width = 0;
245  resize->height = 0;
246  break;
247  }
248 
249  case WID_BO_OBJECT_SPRITE: {
250  bool two_wide = false; // Whether there will be two widgets next to each other in the matrix or not.
251  uint height[2] = {0, 0}; // The height for the different views; in this case views 1/2 and 4.
252 
253  /* Get the height and view information. */
254  for (const auto &spec : ObjectSpec::Specs()) {
255  if (!spec.IsEverAvailable()) continue;
256  two_wide |= spec.views >= 2;
257  height[spec.views / 4] = std::max<int>(spec.height, height[spec.views / 4]);
258  }
259 
260  /* Determine the pixel heights. */
261  for (size_t i = 0; i < lengthof(height); i++) {
263  height[i] += ScaleGUITrad(TILE_PIXELS) + 2 * this->object_margin;
264  }
265 
266  /* Now determine the size of the minimum widgets. When there are two columns, then
267  * we want these columns to be slightly less wide. When there are two rows, then
268  * determine the size of the widgets based on the maximum size for a single row
269  * of widgets, or just the twice the widget height of the two row ones. */
270  size->height = std::max(height[0], height[1] * 2);
271  if (two_wide) {
272  size->width = (3 * ScaleGUITrad(TILE_PIXELS) + 2 * this->object_margin) * 2;
273  } else {
274  size->width = 4 * ScaleGUITrad(TILE_PIXELS) + 2 * this->object_margin;
275  }
276 
277  /* Get the right size for the single widget based on the current spec. */
279  const ObjectSpec *spec = objclass->GetSpec(_selected_object_index);
280  if (spec != nullptr) {
281  if (spec->views <= 1) size->width += WidgetDimensions::scaled.hsep_normal;
282  if (spec->views <= 2) size->height += WidgetDimensions::scaled.vsep_normal;
283  if (spec->views >= 2) size->width /= 2;
284  if (spec->views >= 4) size->height /= 2;
285  }
286  break;
287  }
288 
289  case WID_BO_INFO:
290  size->height = this->info_height;
291  break;
292 
294  fill->height = 1;
295  resize->height = 1;
296  break;
297 
298  case WID_BO_SELECT_IMAGE:
301  break;
302 
303  default: break;
304  }
305  }
306 
307  void DrawWidget(const Rect &r, WidgetID widget) const override
308  {
309  switch (widget) {
310  case WID_BO_CLASS_LIST: {
311  Rect mr = r.Shrink(WidgetDimensions::scaled.matrix);
312  uint pos = 0;
313  for (auto object_class_id : this->object_classes) {
314  ObjectClass *objclass = ObjectClass::Get(object_class_id);
315  if (objclass->GetUISpecCount() == 0) continue;
316  if (!this->vscroll->IsVisible(pos++)) continue;
317  DrawString(mr, objclass->name,
318  (object_class_id == _selected_object_class) ? TC_WHITE : TC_BLACK);
319  mr.top += this->line_height;
320  }
321  break;
322  }
323 
324  case WID_BO_OBJECT_SPRITE: {
325  if (_selected_object_index == -1) break;
326 
328  const ObjectSpec *spec = objclass->GetSpec(_selected_object_index);
329  if (spec == nullptr) break;
330 
331  /* Height of the selection matrix.
332  * Depending on the number of views, the matrix has a 1x1, 1x2, 2x1 or 2x2 layout. To make the previews
333  * look nice in all layouts, we use the 4x4 layout (smallest previews) as starting point. For the bigger
334  * previews in the layouts with less views we add space homogeneously on all sides, so the 4x4 preview-rectangle
335  * is centered in the 2x1, 1x2 resp. 1x1 buttons. */
336  const NWidgetMatrix *matrix = this->GetWidget<NWidgetBase>(widget)->GetParentWidget<NWidgetMatrix>();
337  uint matrix_height = matrix->current_y;
338 
339  DrawPixelInfo tmp_dpi;
340  /* Set up a clipping area for the preview. */
341  Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
342  if (FillDrawPixelInfo(&tmp_dpi, ir)) {
343  AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
344  if (spec->grf_prop.grffile == nullptr) {
345  extern const DrawTileSprites _objects[];
346  const DrawTileSprites *dts = &_objects[spec->grf_prop.local_id];
347  DrawOrigTileSeqInGUI(ir.Width() / 2 - 1, (ir.Height() + matrix_height / 2) / 2 - this->object_margin - ScaleSpriteTrad(TILE_PIXELS), dts, PAL_NONE);
348  } else {
349  DrawNewObjectTileInGUI(ir.Width() / 2 - 1, (ir.Height() + matrix_height / 2) / 2 - this->object_margin - ScaleSpriteTrad(TILE_PIXELS), spec, matrix->GetCurrentElement());
350  }
351  }
352  break;
353  }
354 
355  case WID_BO_SELECT_IMAGE: {
357  int obj_index = objclass->GetIndexFromUI(this->GetWidget<NWidgetBase>(widget)->GetParentWidget<NWidgetMatrix>()->GetCurrentElement());
358  if (obj_index < 0) break;
359  const ObjectSpec *spec = objclass->GetSpec(obj_index);
360  if (spec == nullptr) break;
361 
362  DrawPixelInfo tmp_dpi;
363  /* Set up a clipping area for the preview. */
364  Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
365  if (FillDrawPixelInfo(&tmp_dpi, ir)) {
366  AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
367  if (spec->grf_prop.grffile == nullptr) {
368  extern const DrawTileSprites _objects[];
369  const DrawTileSprites *dts = &_objects[spec->grf_prop.local_id];
370  DrawOrigTileSeqInGUI(ir.Width() / 2 - 1, ir.Height() - this->object_margin - ScaleSpriteTrad(TILE_PIXELS), dts, PAL_NONE);
371  } else {
372  DrawNewObjectTileInGUI(ir.Width() / 2 - 1, ir.Height() - this->object_margin - ScaleSpriteTrad(TILE_PIXELS), spec,
373  std::min<int>(_selected_object_view, spec->views - 1));
374  }
375  }
376  if (!spec->IsAvailable()) {
378  }
379  break;
380  }
381 
382  case WID_BO_INFO: {
384  const ObjectSpec *spec = objclass->GetSpec(_selected_object_index);
385  if (spec == nullptr) break;
386 
387  /* Get the extra message for the GUI */
389  uint16_t callback_res = GetObjectCallback(CBID_OBJECT_FUND_MORE_TEXT, 0, 0, spec, nullptr, INVALID_TILE, _selected_object_view);
390  if (callback_res != CALLBACK_FAILED && callback_res != 0x400) {
391  if (callback_res > 0x400) {
393  } else {
394  StringID message = GetGRFStringID(spec->grf_prop.grffile->grfid, 0xD000 + callback_res);
395  if (message != STR_NULL && message != STR_UNDEFINED) {
397  /* Use all the available space left from where we stand up to the
398  * end of the window. We ALSO enlarge the window if needed, so we
399  * can 'go' wild with the bottom of the window. */
400  int y = DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, message, TC_ORANGE) - r.top - 1;
402  if (y > this->info_height) {
403  BuildObjectWindow *bow = const_cast<BuildObjectWindow *>(this);
404  bow->info_height = y;
405  bow->ReInit();
406  }
407  }
408  }
409  }
410  }
411  }
412  }
413  }
414 
419  void SelectOtherClass(ObjectClassID object_class)
420  {
421  _selected_object_class = object_class;
422  ObjectClass *objclass = ObjectClass::Get(object_class);
423  this->GetWidget<NWidgetMatrix>(WID_BO_SELECT_MATRIX)->SetCount(objclass->GetUISpecCount());
424  }
425 
430  void SelectOtherObject(int object_index)
431  {
432  _selected_object_index = object_index;
433  if (_selected_object_index != -1) {
435  const ObjectSpec *spec = objclass->GetSpec(_selected_object_index);
436  _selected_object_view = std::min<int>(_selected_object_view, spec->views - 1);
437  this->ReInit();
438  } else {
440  }
441 
442  if (_selected_object_index != -1) {
443  SetObjectToPlaceWnd(SPR_CURSOR_TRANSMITTER, PAL_NONE, HT_RECT | HT_DIAGONAL, this);
444  }
445 
447  }
448 
449  void UpdateSelectSize()
450  {
451  if (_selected_object_index == -1) {
452  SetTileSelectSize(1, 1);
453  } else {
455  const ObjectSpec *spec = objclass->GetSpec(_selected_object_index);
456  int w = GB(spec->size, HasBit(_selected_object_view, 0) ? 4 : 0, 4);
457  int h = GB(spec->size, HasBit(_selected_object_view, 0) ? 0 : 4, 4);
458  SetTileSelectSize(w, h);
459  }
460  }
461 
468  void UpdateButtons(ObjectClassID object_class, int sel_index, uint sel_view)
469  {
470  int view_number, object_number;
471  if (sel_index == -1) {
472  view_number = -1; // If no object selected, also hide the selected view.
473  object_number = -1;
474  } else {
475  view_number = sel_view;
476  ObjectClass *objclass = ObjectClass::Get(object_class);
477  object_number = objclass->GetUIFromIndex(sel_index);
478  }
479 
480  this->GetWidget<NWidgetMatrix>(WID_BO_OBJECT_MATRIX)->SetClicked(view_number);
481  this->GetWidget<NWidgetMatrix>(WID_BO_SELECT_MATRIX)->SetClicked(object_number);
482  this->UpdateSelectSize();
483  this->SetDirty();
484  }
485 
486  void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
487  {
488  if (!gui_scope) return;
489 
491  }
492 
493  void OnResize() override
494  {
495  this->vscroll->SetCapacityFromWidget(this, WID_BO_CLASS_LIST);
496  }
497 
498  void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
499  {
500  switch (widget) {
501  case WID_BO_CLASS_LIST: {
502  auto it = this->vscroll->GetScrolledItemFromWidget(this->object_classes, pt.y, this, widget);
503  if (it == this->object_classes.end()) break;
504 
505  this->SelectOtherClass(*it);
506  this->SelectFirstAvailableObject(false);
507  break;
508  }
509 
510  case WID_BO_SELECT_IMAGE: {
512  int num_clicked = objclass->GetIndexFromUI(this->GetWidget<NWidgetBase>(widget)->GetParentWidget<NWidgetMatrix>()->GetCurrentElement());
513  if (num_clicked >= 0 && objclass->GetSpec(num_clicked)->IsAvailable()) this->SelectOtherObject(num_clicked);
514  break;
515  }
516 
518  if (_selected_object_index != -1) {
519  _selected_object_view = this->GetWidget<NWidgetBase>(widget)->GetParentWidget<NWidgetMatrix>()->GetCurrentElement();
520  this->SelectOtherObject(_selected_object_index); // Re-select the object for a different view.
521  }
522  break;
523  }
524  }
525 
526  void OnPlaceObject([[maybe_unused]] Point pt, TileIndex tile) override
527  {
529 
530  if (spec->size == OBJECT_SIZE_1X1) {
532  } else {
533  Command<CMD_BUILD_OBJECT>::Post(STR_ERROR_CAN_T_BUILD_OBJECT, CcPlaySound_CONSTRUCTION_OTHER, tile, spec->Index(), _selected_object_view);
534  }
535  }
536 
537  void OnPlaceDrag(ViewportPlaceMethod select_method, [[maybe_unused]] ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt) override
538  {
539  VpSelectTilesWithMethod(pt.x, pt.y, select_method);
540  }
541 
542  void OnPlaceMouseUp([[maybe_unused]] ViewportPlaceMethod select_method, [[maybe_unused]] ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt, TileIndex start_tile, TileIndex end_tile) override
543  {
544  if (pt.x == -1) return;
545 
546  assert(select_proc == DDSP_BUILD_OBJECT);
547 
549  /* When end_tile is MP_VOID, the error tile will not be visible to the
550  * user. This happens when terraforming at the southern border. */
551  if (TileX(end_tile) == Map::MaxX()) end_tile += TileDiffXY(-1, 0);
552  if (TileY(end_tile) == Map::MaxY()) end_tile += TileDiffXY(0, -1);
553  }
555  Command<CMD_BUILD_OBJECT_AREA>::Post(STR_ERROR_CAN_T_BUILD_OBJECT, CcPlaySound_CONSTRUCTION_OTHER,
556  end_tile, start_tile, spec->Index(), _selected_object_view, (_ctrl_pressed ? true : false));
557  }
558 
559  void OnPlaceObjectAbort() override
560  {
562  }
563 
564  EventState OnHotkey(int hotkey) override
565  {
566  switch (hotkey) {
569  SetFocusedWindow(this); // The user has asked to give focus to the text box, so make sure this window is focused.
570  break;
571 
572  default:
573  return ES_NOT_HANDLED;
574  }
575 
576  return ES_HANDLED;
577  }
578 
579  void OnEditboxChanged(WidgetID widget) override
580  {
581  if (widget == WID_BO_FILTER) {
582  string_filter.SetFilterTerm(this->filter_editbox.text.buf);
583  this->object_classes.SetFilterState(!string_filter.IsEmpty());
584  this->object_classes.ForceRebuild();
585  this->InvalidateData();
586  }
587  }
588 
594  void SelectFirstAvailableObject(bool change_class)
595  {
597 
598  /* First try to select an object in the selected class. */
599  for (uint i = 0; i < objclass->GetSpecCount(); i++) {
600  const ObjectSpec *spec = objclass->GetSpec(i);
601  if (spec->IsAvailable()) {
602  this->SelectOtherObject(i);
603  return;
604  }
605  }
606  if (change_class) {
607  /* If that fails, select the first available object
608  * from a random class. */
609  for (auto object_class_id : this->object_classes) {
610  ObjectClass *objclass = ObjectClass::Get(object_class_id);
611  for (uint i = 0; i < objclass->GetSpecCount(); i++) {
612  const ObjectSpec *spec = objclass->GetSpec(i);
613  if (spec->IsAvailable()) {
614  this->SelectOtherClass(object_class_id);
615  this->SelectOtherObject(i);
616  return;
617  }
618  }
619  }
620  }
621  /* If all objects are unavailable, select nothing... */
622  if (objclass->GetUISpecCount() == 0) {
623  /* ... but make sure that the class is not empty. */
624  for (auto object_class_id : this->object_classes) {
625  ObjectClass *objclass = ObjectClass::Get(object_class_id);
626  if (objclass->GetUISpecCount() > 0) {
627  this->SelectOtherClass(object_class_id);
628  break;
629  }
630  }
631  }
632  this->SelectOtherObject(-1);
633  }
634 
641  {
642  if (_game_mode == GM_MENU) return ES_NOT_HANDLED;
644  if (w == nullptr) return ES_NOT_HANDLED;
645  return w->OnHotkey(hotkey);
646  }
647 
648  static inline HotkeyList hotkeys{"buildobject", {
649  Hotkey('F', "focus_filter_box", BOHK_FOCUS_FILTER_BOX),
651 };
652 
653 
656 
658  &ObjectClassIDSorter,
659 };
660 
662  &TagNameFilter,
663 };
664 
665 static constexpr NWidgetPart _nested_build_object_widgets[] = {
667  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
668  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_OBJECT_BUILD_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
669  NWidget(WWT_SHADEBOX, COLOUR_DARK_GREEN),
670  NWidget(WWT_DEFSIZEBOX, COLOUR_DARK_GREEN),
671  NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
672  EndContainer(),
674  NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
678  NWidget(WWT_TEXT, COLOUR_DARK_GREEN), SetFill(0, 1), SetDataTip(STR_LIST_FILTER_TITLE, STR_NULL),
679  NWidget(WWT_EDITBOX, COLOUR_GREY, WID_BO_FILTER), SetFill(1, 0), SetResize(1, 0),
680  SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
681  EndContainer(),
683  NWidget(WWT_MATRIX, COLOUR_GREY, WID_BO_CLASS_LIST), SetFill(1, 0), SetMatrixDataTip(1, 0, STR_OBJECT_BUILD_CLASS_TOOLTIP), SetScrollbar(WID_BO_SCROLLBAR),
685  EndContainer(),
686  NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_ORIENTATION, STR_NULL), SetFill(1, 0),
688  NWidget(NWID_MATRIX, COLOUR_DARK_GREEN, WID_BO_OBJECT_MATRIX), SetPIP(0, 2, 0),
689  NWidget(WWT_PANEL, COLOUR_GREY, WID_BO_OBJECT_SPRITE), SetDataTip(0x0, STR_OBJECT_BUILD_PREVIEW_TOOLTIP), EndContainer(),
690  EndContainer(),
691  EndContainer(),
692  NWidget(WWT_TEXT, COLOUR_DARK_GREEN, WID_BO_OBJECT_NAME), SetDataTip(STR_JUST_STRING, STR_NULL), SetTextStyle(TC_ORANGE), SetAlignment(SA_CENTER),
693  NWidget(WWT_TEXT, COLOUR_DARK_GREEN, WID_BO_OBJECT_SIZE), SetDataTip(STR_OBJECT_BUILD_SIZE, STR_NULL), SetAlignment(SA_CENTER),
694  EndContainer(),
695  NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetScrollbar(WID_BO_SELECT_SCROLL),
696  NWidget(NWID_MATRIX, COLOUR_DARK_GREEN, WID_BO_SELECT_MATRIX), SetPIP(0, 2, 0),
697  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BO_SELECT_IMAGE), SetMinimalSize(66, 60), SetDataTip(0x0, STR_OBJECT_BUILD_TOOLTIP),
699  EndContainer(),
700  EndContainer(),
701  EndContainer(),
702  EndContainer(),
703  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_BO_INFO), SetPadding(WidgetDimensions::unscaled.framerect), SetFill(1, 0), SetResize(1, 0),
704  EndContainer(),
706  NWidget(NWID_VSCROLLBAR, COLOUR_DARK_GREEN, WID_BO_SELECT_SCROLL),
707  NWidget(WWT_RESIZEBOX, COLOUR_DARK_GREEN),
708  EndContainer(),
709  EndContainer(),
710 };
711 
712 static WindowDesc _build_object_desc(__FILE__, __LINE__,
713  WDP_AUTO, "build_object", 0, 0,
716  std::begin(_nested_build_object_widgets), std::end(_nested_build_object_widgets),
717  &BuildObjectWindow::hotkeys
718 );
719 
722 {
723  /* Don't show the place object button when there are no objects to place. */
724  if (ObjectClass::GetUIClassCount() > 0) {
725  return AllocateWindowDescFront<BuildObjectWindow>(&_build_object_desc, 0);
726  }
727  return nullptr;
728 }
729 
732 {
734 }
WID_BO_CLASS_LIST
@ WID_BO_CLASS_LIST
The list with classes.
Definition: object_widget.h:16
ES_HANDLED
@ ES_HANDLED
The passed event is handled.
Definition: window_type.h:739
TileY
static debug_inline uint TileY(TileIndex tile)
Get the Y component of a tile.
Definition: map_func.h:437
_selected_object_index
static int _selected_object_index
Index of the currently selected object if existing, else -1.
Definition: object_gui.cpp:38
OBJECT_SIZE_1X1
static const uint8_t OBJECT_SIZE_1X1
The value of a NewGRF's size property when the object is 1x1 tiles: low nibble for X,...
Definition: newgrf_object.h:43
SetFill
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1141
BuildObjectWindow::ObjectClassIDSorter
static bool ObjectClassIDSorter(ObjectClassID const &a, ObjectClassID const &b)
Sort object classes by ObjectClassID.
Definition: object_gui.cpp:126
SetTileSelectSize
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
Definition: viewport.cpp:2536
BuildObjectWindow::CanRestoreSelectedObject
bool CanRestoreSelectedObject()
Tests whether the previously selected object can be selected.
Definition: object_gui.cpp:80
OBJECT_CLASS_BEGIN
@ OBJECT_CLASS_BEGIN
The lowest valid value.
Definition: newgrf_object.h:49
Rect::Height
int Height() const
Get height of Rect.
Definition: geometry_type.hpp:91
WC_BUILD_TOOLBAR
@ WC_BUILD_TOOLBAR
Build toolbar; Window numbers:
Definition: window_type.h:73
BuildObjectWindow::EnsureSelectedObjectClassIsVisible
void EnsureSelectedObjectClassIsVisible()
Scroll WID_BO_CLASS_LIST so that the selected object class is visible.
Definition: object_gui.cpp:66
querystring_gui.h
BuildObjectWindow::last_filtering
static Filtering last_filtering
Default filtering of GUIObjectClassList.
Definition: object_gui.cpp:58
NewGRFClass::GetUISpecCount
uint GetUISpecCount() const
Get the number of potentially user-available specs within the class.
Definition: newgrf_class.h:46
HotkeyList
List of hotkeys for a window.
Definition: hotkeys.h:37
SetFocusedWindow
void SetFocusedWindow(Window *w)
Set the window that has the focus.
Definition: window.cpp:423
BuildObjectHotkeys
BuildObjectHotkeys
Enum referring to the Hotkeys in the build object window.
Definition: object_gui.cpp:42
NWidgetBase::GetParentWidget
NWID * GetParentWidget()
Get parent widget of type NWID.
Definition: widget_type.h:154
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:30
command_func.h
ObjectSpec
Allow incrementing of ObjectClassID variables.
Definition: newgrf_object.h:60
WidgetDimensions::scaled
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition: window_gui.h:68
ObjectSpec::grf_prop
GRFFilePropsBase< 2 > grf_prop
Properties related the the grf file.
Definition: newgrf_object.h:62
GetObjectCallback
uint16_t GetObjectCallback(CallbackID callback, uint32_t param1, uint32_t param2, const ObjectSpec *spec, Object *o, TileIndex tile, uint8_t view)
Perform a callback for an object.
Definition: newgrf_object.cpp:431
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:68
WDF_CONSTRUCTION
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Definition: window_gui.h:197
Rect::Shrink
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Definition: geometry_type.hpp:98
StringFilter::IsEmpty
bool IsEmpty() const
Check whether any filter words were entered.
Definition: stringfilter_type.h:60
Map::MaxX
static debug_inline uint MaxX()
Gets the maximum X coordinate within the map, including MP_VOID.
Definition: map_func.h:297
terraform_cmd.h
ViewportDragDropSelectionProcess
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you've selected it.
Definition: viewport_type.h:107
StringFilter::SetFilterTerm
void SetFilterTerm(const char *str)
Set the term to filter on.
Definition: stringfilter.cpp:28
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:63
Scrollbar::ScrollTowards
void ScrollTowards(int position)
Scroll towards the given position; if the item is visible nothing happens, otherwise it will be shown...
Definition: widget_type.h:821
NewGRFClass::GetSpecCount
uint GetSpecCount() const
Get the number of allocated specs within the class.
Definition: newgrf_class.h:44
BuildObjectWindow::BuildObjectGlobalHotkeys
static EventState BuildObjectGlobalHotkeys(int hotkey)
Handler for global hotkeys of the BuildObjectWindow.
Definition: object_gui.cpp:640
NWidgetMatrix
Matrix container with implicitly equal sized (virtual) sub-widgets.
Definition: widget_type.h:581
SetAlignment
constexpr NWidgetPart SetAlignment(StringAlignment align)
Widget part function for setting the alignment of text/images.
Definition: widget_type.h:1130
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
GUIList< ObjectClassID, std::nullptr_t, StringFilter & >
WWT_LABEL
@ WWT_LABEL
Centered label.
Definition: widget_type.h:59
BuildObjectWindow::OnInit
void OnInit() override
Notification that the nested widget tree gets initialized.
Definition: object_gui.cpp:210
WWT_DEFSIZEBOX
@ WWT_DEFSIZEBOX
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX)
Definition: widget_type.h:67
GB
constexpr static debug_inline uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
Definition: bitmath_func.hpp:32
BuildObjectWindow
The window used for building objects.
Definition: object_gui.cpp:47
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:77
ObjectSpec::IsAvailable
bool IsAvailable() const
Check whether the object is available at this time.
Definition: newgrf_object.cpp:93
object_widget.h
StartTextRefStackUsage
void StartTextRefStackUsage(const GRFFile *grffile, byte numEntries, const uint32_t *values)
Start using the TTDP compatible string code parsing.
Definition: newgrf_text.cpp:798
WWT_MATRIX
@ WWT_MATRIX
Grid of rows and columns.
Definition: widget_type.h:61
INVALID_TILE
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:95
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1151
SetMatrixDataTip
constexpr NWidgetPart SetMatrixDataTip(uint8_t cols, uint8_t rows, StringID tip)
Widget part function for setting the data and tooltip of WWT_MATRIX widgets.
Definition: widget_type.h:1174
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:37
FILLRECT_CHECKER
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
Definition: gfx_type.h:294
ObjectSpec::height
uint8_t height
The height of this structure, in heightlevels; max MAX_TILE_HEIGHT.
Definition: newgrf_object.h:75
zoom_func.h
Scrollbar::SetCapacityFromWidget
void SetCapacityFromWidget(Window *w, WidgetID widget, int padding=0)
Set capacity of visible elements from the size and resize properties of a widget.
Definition: widget.cpp:2334
NWidgetMatrix::SetScrollbar
void SetScrollbar(Scrollbar *sb)
Assign a scrollbar to this matrix.
Definition: widget.cpp:1804
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget tree.
Definition: widget_type.h:50
RectPadding::Vertical
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Definition: geometry_type.hpp:69
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
StringFilter::AddLine
void AddLine(const char *str)
Pass another text line from the current item to the filter.
Definition: stringfilter.cpp:114
StopTextRefStackUsage
void StopTextRefStackUsage()
Stop using the TTDP compatible string code parsing.
Definition: newgrf_text.cpp:815
InitializeObjectGui
void InitializeObjectGui()
Reset all data of the object GUI.
Definition: object_gui.cpp:731
ObjectSpec::IsEverAvailable
bool IsEverAvailable() const
Check whether the object might be available at some point in this game with the current game mode.
Definition: newgrf_object.cpp:74
BuildObjectWindow::SelectOtherClass
void SelectOtherClass(ObjectClassID object_class)
Select the specified object class.
Definition: object_gui.cpp:419
ViewportPlaceMethod
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
Definition: viewport_type.h:88
NWID_MATRIX
@ NWID_MATRIX
Matrix container.
Definition: widget_type.h:80
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:678
Window::GetScrollbar
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
Definition: window.cpp:315
Window::OnHotkey
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
Definition: window.cpp:566
BuildObjectWindow::filter_funcs
static GUIObjectClassList::FilterFunction *const filter_funcs[]
Filter functions of the GUIObjectClassList.
Definition: object_gui.cpp:60
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:1038
GUIList::NeedRebuild
bool NeedRebuild() const
Check if a rebuild is needed.
Definition: sortlist_type.h:387
QueryString
Data stored about a string that can be modified in the GUI.
Definition: querystring_gui.h:20
BuildObjectWindow::OnResize
void OnResize() override
Called after the window got resized.
Definition: object_gui.cpp:493
Textbuf::buf
char *const buf
buffer in which text is saved
Definition: textbuf_type.h:32
ObjectSpec::callback_mask
uint16_t callback_mask
Bitmask of requested/allowed callbacks.
Definition: newgrf_object.h:74
MAX_CHAR_LENGTH
static const int MAX_CHAR_LENGTH
Max. length of UTF-8 encoded unicode character.
Definition: strings_type.h:18
BuildObjectWindow::SelectClassAndObject
void SelectClassAndObject()
Checks if the previously selected current object class and object can be shown as selected to the use...
Definition: object_gui.cpp:166
NWidgetMatrix::SetCount
void SetCount(int count)
Set the number of elements in this matrix.
Definition: widget.cpp:1780
WindowDesc
High level window description.
Definition: window_gui.h:153
WidgetID
int WidgetID
Widget ID.
Definition: window_type.h:18
RectPadding::Horizontal
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
Definition: geometry_type.hpp:63
ScaleGUITrad
int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
Definition: zoom_func.h:117
CBM_OBJ_FUND_MORE_TEXT
@ CBM_OBJ_FUND_MORE_TEXT
additional text in fund window
Definition: newgrf_callbacks.h:402
window_gui.h
SetPadding
constexpr NWidgetPart SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left)
Widget part function for setting additional space around a widget.
Definition: widget_type.h:1188
ObjectSpec::size
uint8_t size
The size of this objects; low nibble for X, high nibble for Y.
Definition: newgrf_object.h:68
BuildObjectWindow::UpdateButtons
void UpdateButtons(ObjectClassID object_class, int sel_index, uint sel_view)
Update buttons to show the selection to the user.
Definition: object_gui.cpp:468
SetResize
constexpr NWidgetPart SetResize(int16_t dx, int16_t dy)
Widget part function for setting the resize step.
Definition: widget_type.h:1086
BuildObjectWindow::TagNameFilter
static bool CDECL TagNameFilter(ObjectClassID const *oc, StringFilter &filter)
Filter object classes by class name.
Definition: object_gui.cpp:132
WDP_AUTO
@ WDP_AUTO
Find a place automatically.
Definition: window_gui.h:141
Listing
Data structure describing how to show the list (what sort direction and criteria).
Definition: sortlist_type.h:30
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:308
WID_BO_SELECT_IMAGE
@ WID_BO_SELECT_IMAGE
Preview image in the WID_BO_SELECT_MATRIX.
Definition: object_widget.h:25
tilehighlight_func.h
WindowNumber
int32_t WindowNumber
Number to differentiate different windows of the same class.
Definition: window_type.h:732
FS_NORMAL
@ FS_NORMAL
Index of the normal font in the font tables.
Definition: gfx_type.h:203
ObjectClassID
ObjectClassID
Class IDs for objects.
Definition: newgrf_object.h:48
SetScrollbar
constexpr NWidgetPart SetScrollbar(WidgetID index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1244
GUIList::Filter
bool Filter(FilterFunction *decide, F filter_data)
Filter the list.
Definition: sortlist_type.h:343
WWT_EDITBOX
@ WWT_EDITBOX
a textbox for typing
Definition: widget_type.h:73
Window::height
int height
Height of the window (number of pixels down in y direction)
Definition: window_gui.h:306
VpStartPlaceSizing
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
highlighting tiles while only going over them with the mouse
Definition: viewport.cpp:2716
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:941
GUIList::SortFunction
std::conditional_t< std::is_same_v< P, std::nullptr_t >, bool(const T &, const T &), bool(const T &, const T &, const P)> SortFunction
Signature of sort function.
Definition: sortlist_type.h:49
BuildObjectWindow::filter_editbox
QueryString filter_editbox
Filter editbox.
Definition: object_gui.cpp:63
WID_BO_SELECT_SCROLL
@ WID_BO_SELECT_SCROLL
Scrollbar next to the WID_BO_SELECT_MATRIX.
Definition: object_widget.h:26
BuildObjectWindow::info_height
int info_height
The height of the info box.
Definition: object_gui.cpp:54
HT_DIAGONAL
@ HT_DIAGONAL
Also allow 'diagonal rectangles'. Only usable in combination with HT_RECT or HT_POINT.
Definition: tilehighlight_type.h:28
BOHK_FOCUS_FILTER_BOX
@ BOHK_FOCUS_FILTER_BOX
Focus the edit box for editing the filter string.
Definition: object_gui.cpp:43
BuildObjectWindow::GUIObjectClassList
GUIList< ObjectClassID, std::nullptr_t, StringFilter & > GUIObjectClassList
Type definition for the list to hold available object classes.
Definition: object_gui.cpp:48
DDSP_BUILD_OBJECT
@ DDSP_BUILD_OBJECT
Build an object.
Definition: viewport_type.h:118
ES_NOT_HANDLED
@ ES_NOT_HANDLED
The passed event is not handled.
Definition: window_type.h:740
VpSelectTilesWithMethod
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
Definition: viewport.cpp:3201
NewGRFClass
Struct containing information relating to NewGRF classes for stations and airports.
Definition: newgrf_class.h:20
TileDiffXY
TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
Definition: map_func.h:401
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:55
Window::ReInit
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
Definition: window.cpp:953
Filtering
Data structure describing what to show in the list (filter criteria).
Definition: sortlist_type.h:35
BuildObjectWindow::OnInvalidateData
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
Definition: object_gui.cpp:486
WID_BO_INFO
@ WID_BO_INFO
Other information about the object (from the NewGRF).
Definition: object_widget.h:22
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1258
_selected_object_class
static ObjectClassID _selected_object_class
Currently selected available object class.
Definition: object_gui.cpp:37
safeguards.h
sortlist_type.h
ConstructionSettings::freeform_edges
bool freeform_edges
allow terraforming the tiles at the map edges
Definition: settings_type.h:383
DrawTileSprites
Ground palette sprite of a tile, together with its sprite layout.
Definition: sprite.h:58
newgrf_text.h
BuildObjectWindow::line_height
int line_height
The height of a single line.
Definition: object_gui.cpp:53
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
Scrollbar::GetScrolledItemFromWidget
Tcontainer::iterator GetScrolledItemFromWidget(Tcontainer &container, int clickpos, const Window *const w, WidgetID widget, int padding=0, int line_height=-1) const
Return an iterator pointing to the element of a scrolled widget that a user clicked in.
Definition: widget_type.h:845
GetGRFStringID
StringID GetGRFStringID(uint32_t grfid, StringID stringid)
Returns the index for this stringid associated with its grfID.
Definition: newgrf_text.cpp:587
stdafx.h
WID_BO_OBJECT_NAME
@ WID_BO_OBJECT_NAME
The name of the selected object.
Definition: object_widget.h:20
Window::SetFocusedWidget
bool SetFocusedWidget(WidgetID widget_index)
Set focus within this window to the given widget.
Definition: window.cpp:487
GfxFillRect
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
Definition: gfx.cpp:113
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:3140
viewport_func.h
NWidgetBase::current_y
uint current_y
Current vertical size (after resizing).
Definition: widget_type.h:234
object_cmd.h
WID_BO_FILTER
@ WID_BO_FILTER
The filter text box for the object list.
Definition: object_widget.h:15
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:79
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:1571
BuildObjectWindow::BuildObjectClassesAvailable
void BuildObjectClassesAvailable()
Builds the filter list of available object classes.
Definition: object_gui.cpp:142
GRFFilePropsBase::local_id
uint16_t local_id
id defined by the grf file for this entity
Definition: newgrf_commons.h:318
newgrf_object.h
ObjectSpec::name
StringID name
The name for this object.
Definition: newgrf_object.h:65
WidgetDimensions::unscaled
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition: window_gui.h:67
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:71
WWT_RESIZEBOX
@ WWT_RESIZEBOX
Resize box (normally at bottom-right of a window)
Definition: widget_type.h:70
GUIList::ForceRebuild
void ForceRebuild()
Force that a rebuild is needed.
Definition: sortlist_type.h:395
string_func.h
CALLBACK_FAILED
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
Definition: newgrf_callbacks.h:420
ShowBuildObjectPicker
Window * ShowBuildObjectPicker()
Show our object picker.
Definition: object_gui.cpp:721
ObjectSpec::Index
uint Index() const
Gets the index of this spec.
Definition: newgrf_object.cpp:103
Window::querystrings
std::map< WidgetID, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
Definition: window_gui.h:314
DrawStringMultiLine
int DrawStringMultiLine(int left, int right, int top, int bottom, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
Definition: gfx.cpp:775
WID_BO_OBJECT_SIZE
@ WID_BO_OBJECT_SIZE
The size of the selected object.
Definition: object_widget.h:21
Window::CreateNestedTree
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1724
Map::MaxY
static uint MaxY()
Gets the maximum Y coordinate within the map, including MP_VOID.
Definition: map_func.h:306
strings_func.h
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:86
BuildObjectWindow::vscroll
Scrollbar * vscroll
The scrollbar.
Definition: object_gui.cpp:55
BuildObjectWindow::OnHotkey
EventState OnHotkey(int hotkey) override
A hotkey has been pressed.
Definition: object_gui.cpp:564
WID_BO_OBJECT_MATRIX
@ WID_BO_OBJECT_MATRIX
The matrix with preview sprites.
Definition: object_widget.h:18
Scrollbar::IsVisible
bool IsVisible(uint16_t item) const
Checks whether given current item is visible in the list.
Definition: widget_type.h:730
WWT_TEXT
@ WWT_TEXT
Pure simple text.
Definition: widget_type.h:60
SetPIP
constexpr NWidgetPart SetPIP(uint8_t pre, uint8_t inter, uint8_t post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1220
BuildObjectWindow::OnPlaceObjectAbort
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
Definition: object_gui.cpp:559
SetDParam
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings.cpp:104
BuildObjectWindow::object_classes
GUIObjectClassList object_classes
Available object classes.
Definition: object_gui.cpp:61
StringFilter::ResetState
void ResetState()
Reset the matching state to process a new item.
Definition: stringfilter.cpp:98
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:52
WidgetDimensions::vsep_normal
int vsep_normal
Normal vertical spacing.
Definition: window_gui.h:60
AutoRestoreBackup
Class to backup a specific variable and restore it upon destruction of this object to prevent stack v...
Definition: backup_type.hpp:153
newgrf.h
ScaleSpriteTrad
int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.
Definition: zoom_func.h:107
WID_BO_SELECT_MATRIX
@ WID_BO_SELECT_MATRIX
Selection preview matrix of objects of a given class.
Definition: object_widget.h:24
Scrollbar::SetCount
void SetCount(size_t num)
Sets the number of elements in the list.
Definition: widget_type.h:760
GetString
std::string GetString(StringID string)
Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
Definition: strings.cpp:327
EventState
EventState
State of handling an event.
Definition: window_type.h:738
HT_RECT
@ HT_RECT
rectangle (stations, depots, ...)
Definition: tilehighlight_type.h:21
VPM_X_AND_Y
@ VPM_X_AND_Y
area of land in X and Y directions
Definition: viewport_type.h:92
DrawOrigTileSeqInGUI
void DrawOrigTileSeqInGUI(int x, int y, const DrawTileSprites *dts, PaletteID default_palette)
Draw TTD sprite sequence in GUI.
Definition: sprite.h:115
StringFilter::GetState
bool GetState() const
Get the matching state of the current item.
Definition: stringfilter_type.h:71
NewGRFClass::name
StringID name
Name of this class.
Definition: newgrf_class.h:39
Window::FinishInitNested
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition: window.cpp:1734
PC_BLACK
static const uint8_t PC_BLACK
Black palette colour.
Definition: palette_func.h:55
NWidgetMatrix::GetCurrentElement
int GetCurrentElement() const
Get current element.
Definition: widget.cpp:1813
WidgetDimensions::fullbevel
RectPadding fullbevel
Always-scaled bevel thickness.
Definition: window_gui.h:41
BuildObjectWindow::object_margin
int object_margin
The margin (in pixels) around an object.
Definition: object_gui.cpp:52
ErrorUnknownCallbackResult
void ErrorUnknownCallbackResult(uint32_t grfid, uint16_t cbid, uint16_t cb_res)
Record that a NewGRF returned an unknown/invalid callback result.
Definition: newgrf_commons.cpp:499
WID_BO_SCROLLBAR
@ WID_BO_SCROLLBAR
The scrollbar associated with the list.
Definition: object_widget.h:17
CommandHelper
Definition: command_func.h:93
GUIList::SetFilterFuncs
void SetFilterFuncs(FilterFunction *const *n_funcs)
Hand the array of filter function pointers to the sort list.
Definition: sortlist_type.h:366
BuildObjectWindow::SelectFirstAvailableObject
void SelectFirstAvailableObject(bool change_class)
Select the first available object.
Definition: object_gui.cpp:594
window_func.h
SA_CENTER
@ SA_CENTER
Center both horizontally and vertically.
Definition: gfx_type.h:348
GetCharacterHeight
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition: fontcache.cpp:78
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:300
stringfilter_type.h
NewGRFClass::Get
static NewGRFClass * Get(Tid cls_id)
Get a particular class.
Definition: newgrf_class_func.h:98
SetMinimalSize
constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1097
SetPIPRatio
constexpr NWidgetPart SetPIPRatio(uint8_t ratio_pre, uint8_t ratio_inter, uint8_t ratio_post)
Widget part function for setting a pre/inter/post ratio.
Definition: widget_type.h:1232
GUIList::SetSortFuncs
void SetSortFuncs(SortFunction *const *n_funcs)
Hand the array of sort function pointers to the sort list.
Definition: sortlist_type.h:295
GUIList::RebuildDone
void RebuildDone()
Notify the sortlist that the rebuild is done.
Definition: sortlist_type.h:405
WC_BUILD_OBJECT
@ WC_BUILD_OBJECT
Build object; Window numbers:
Definition: window_type.h:376
GUIList< ObjectClassID, std::nullptr_t, StringFilter & >::FilterFunction
bool CDECL FilterFunction(const ObjectClassID *, StringFilter &)
Signature of filter function.
Definition: sortlist_type.h:50
TILE_HEIGHT
static const uint TILE_HEIGHT
Height of a height level in world coordinate AND in pixels in #ZOOM_LVL_BASE.
Definition: tile_type.h:18
DrawString
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition: gfx.cpp:658
SetObjectToPlaceWnd
void SetObjectToPlaceWnd(CursorID icon, PaletteID pal, HighLightStyle mode, Window *w)
Change the cursor and mouse click/drag handling to a mode for performing special operations like tile...
Definition: viewport.cpp:3420
_selected_object_view
static uint8_t _selected_object_view
the view of the selected object
Definition: object_gui.cpp:39
BuildObjectWindow::string_filter
StringFilter string_filter
Filter for available objects.
Definition: object_gui.cpp:62
BuildObjectWindow::EDITBOX_MAX_SIZE
static const uint EDITBOX_MAX_SIZE
The maximum number of characters for the filter edit box.
Definition: object_gui.cpp:50
GameSettings::construction
ConstructionSettings construction
construction of things in-game
Definition: settings_type.h:620
DrawNewObjectTileInGUI
void DrawNewObjectTileInGUI(int x, int y, const ObjectSpec *spec, uint8_t view)
Draw representation of an object (tile) for GUI purposes.
Definition: newgrf_object.cpp:487
Window
Data structure for an opened window.
Definition: window_gui.h:267
TILE_PIXELS
static const uint TILE_PIXELS
Pixel distance between tile columns/rows in #ZOOM_LVL_BASE.
Definition: tile_type.h:17
BuildObjectWindow::SelectOtherObject
void SelectOtherObject(int object_index)
Select the specified object in _selected_object_class class.
Definition: object_gui.cpp:430
GRFFilePropsBase::grffile
const struct GRFFile * grffile
grf file that introduced this entity
Definition: newgrf_commons.h:319
TileX
static debug_inline uint TileX(TileIndex tile)
Get the X component of a tile.
Definition: map_func.h:427
BuildObjectWindow::last_sorting
static Listing last_sorting
Default sorting of GUIObjectClassList.
Definition: object_gui.cpp:57
SetDataTip
constexpr NWidgetPart SetDataTip(uint32_t data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1162
Rect::Width
int Width() const
Get width of Rect.
Definition: geometry_type.hpp:85
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:75
GUIList::Sort
bool Sort(Comp compare)
Sort the list.
Definition: sortlist_type.h:268
WidgetDimensions::hsep_normal
int hsep_normal
Normal horizontal spacing.
Definition: window_gui.h:63
ResetObjectToPlace
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
Definition: viewport.cpp:3483
WID_BO_OBJECT_SPRITE
@ WID_BO_OBJECT_SPRITE
A preview sprite of the object.
Definition: object_widget.h:19
GUIList::SetFiltering
void SetFiltering(Filtering f)
Import filter conditions.
Definition: sortlist_type.h:202
SetTextStyle
constexpr NWidgetPart SetTextStyle(TextColour colour, FontSize size=FS_NORMAL)
Widget part function for setting the text style.
Definition: widget_type.h:1120
GetStringBoundingBox
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:852
StringFilter
String filter and state.
Definition: stringfilter_type.h:30
road_cmd.h
object.h
DrawPixelInfo
Data about how and where to blit pixels.
Definition: gfx_type.h:151
GUIList::SetListing
void SetListing(Listing l)
Import sort conditions.
Definition: sortlist_type.h:151
Hotkey
All data for a single hotkey.
Definition: hotkeys.h:21
BuildObjectWindow::sorter_funcs
static GUIObjectClassList::SortFunction *const sorter_funcs[]
Sort functions of the GUIObjectClassList.
Definition: object_gui.cpp:59
hotkeys.h
CBID_OBJECT_FUND_MORE_TEXT
@ CBID_OBJECT_FUND_MORE_TEXT
Called to determine more text in the fund object window.
Definition: newgrf_callbacks.h:269
WWT_SHADEBOX
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition: widget_type.h:66
ObjectSpec::views
uint8_t views
The number of views.
Definition: newgrf_object.h:76
HasBit
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103