OpenTTD Source  13.2.1
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 _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 
95  {
96  const NWidgetBase *matrix = this->GetWidget<NWidgetBase>(WID_BO_SELECT_MATRIX);
97  return 1 + (matrix->current_x - matrix->smallest_x) / matrix->resize_x;
98  }
99 
100 public:
102  {
103  this->CreateNestedTree();
104 
105  this->vscroll = this->GetScrollbar(WID_BO_SCROLLBAR);
106 
107  this->querystrings[WID_BO_FILTER] = &this->filter_editbox;
108 
109  this->object_classes.SetListing(this->last_sorting);
110  this->object_classes.SetFiltering(this->last_filtering);
111  this->object_classes.SetSortFuncs(this->sorter_funcs);
112  this->object_classes.SetFilterFuncs(this->filter_funcs);
113  this->object_classes.ForceRebuild();
114 
117 
118  this->FinishInitNested(number);
119 
120  NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BO_SELECT_MATRIX);
122  matrix->SetCount(ObjectClass::Get(_selected_object_class)->GetUISpecCount());
123 
124  this->GetWidget<NWidgetMatrix>(WID_BO_OBJECT_MATRIX)->SetCount(4);
125 
127 
128  this->vscroll->SetCount((int)this->object_classes.size());
129 
131 
132  this->InvalidateData();
133  }
134 
136  static bool ObjectClassIDSorter(ObjectClassID const &a, ObjectClassID const &b)
137  {
138  return a < b;
139  }
140 
142  static bool CDECL TagNameFilter(ObjectClassID const *oc, StringFilter &filter)
143  {
144  ObjectClass *objclass = ObjectClass::Get(*oc);
145  char buffer[DRAW_STRING_BUFFER];
146  GetString(buffer, objclass->name, lastof(buffer));
147 
148  filter.ResetState();
149  filter.AddLine(buffer);
150  return filter.GetState();
151  }
152 
155  {
156  if (!this->object_classes.NeedRebuild()) return;
157 
158  this->object_classes.clear();
159 
160  for (uint i = 0; i < ObjectClass::GetClassCount(); i++) {
162  if (objclass->GetUISpecCount() == 0) continue; // Is this needed here?
163  object_classes.push_back((ObjectClassID)i);
164  }
165 
166  this->object_classes.Filter(this->string_filter);
167  this->object_classes.shrink_to_fit();
168  this->object_classes.RebuildDone();
169  this->object_classes.Sort();
170 
171  this->vscroll->SetCount((uint)this->object_classes.size());
172  }
173 
179  {
180  assert(!this->object_classes.empty()); // object GUI should be disabled elsewise
182  /* This happens during the first time the window is open during the game life cycle. */
183  this->SelectOtherClass(this->object_classes[0]);
184  } else {
185  /* Check if the previously selected object class is not available anymore as a
186  * result of starting a new game without the corresponding NewGRF. */
187  bool available = false;
188  for (uint i = 0; ObjectClass::GetClassCount(); ++i) {
190  available = true;
191  break;
192  }
193  }
194 
195  if (available) {
197  } else {
198  this->SelectOtherClass(this->object_classes[0]);
199  }
200  }
201 
202  if (this->CanRestoreSelectedObject()) {
204  } else {
205  this->SelectFirstAvailableObject(true);
206  }
207  assert(ObjectClass::Get(_selected_object_class)->GetUISpecCount() > 0); // object GUI should be disabled elsewise
208  }
209 
210  void SetStringParameters(int widget) const override
211  {
212  switch (widget) {
213  case WID_BO_OBJECT_NAME: {
215  const ObjectSpec *spec = objclass->GetSpec(_selected_object_index);
216  SetDParam(0, spec != nullptr ? spec->name : STR_EMPTY);
217  break;
218  }
219 
220  case WID_BO_OBJECT_SIZE: {
222  const ObjectSpec *spec = objclass->GetSpec(_selected_object_index);
223  int size = spec == nullptr ? 0 : spec->size;
224  SetDParam(0, GB(size, HasBit(_selected_object_view, 0) ? 4 : 0, 4));
225  SetDParam(1, GB(size, HasBit(_selected_object_view, 0) ? 0 : 4, 4));
226  break;
227  }
228 
229  default: break;
230  }
231  }
232 
233  void OnInit() override
234  {
235  this->object_margin = ScaleGUITrad(4);
236  }
237 
238  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
239  {
240  switch (widget) {
241  case WID_BO_CLASS_LIST: {
242  for (auto object_class_id : this->object_classes) {
243  ObjectClass *objclass = ObjectClass::Get(object_class_id);
244  if (objclass->GetUISpecCount() == 0) continue;
245  size->width = std::max(size->width, GetStringBoundingBox(objclass->name).width);
246  }
247  size->width += padding.width;
248  this->line_height = FONT_HEIGHT_NORMAL + padding.height;
249  resize->height = this->line_height;
250  size->height = 5 * this->line_height;
251  break;
252  }
253 
254  case WID_BO_OBJECT_NAME:
255  case WID_BO_OBJECT_SIZE:
256  /* We do not want the window to resize when selecting objects; better clip texts */
257  size->width = 0;
258  break;
259 
260  case WID_BO_OBJECT_MATRIX: {
261  /* Get the right amount of buttons based on the current spec. */
263  const ObjectSpec *spec = objclass->GetSpec(_selected_object_index);
264  if (spec != nullptr) {
265  if (spec->views >= 2) size->width += resize->width;
266  if (spec->views >= 4) size->height += resize->height;
267  }
268  resize->width = 0;
269  resize->height = 0;
270  break;
271  }
272 
273  case WID_BO_OBJECT_SPRITE: {
274  bool two_wide = false; // Whether there will be two widgets next to each other in the matrix or not.
275  uint height[2] = {0, 0}; // The height for the different views; in this case views 1/2 and 4.
276 
277  /* Get the height and view information. */
278  for (int i = 0; i < NUM_OBJECTS; i++) {
279  const ObjectSpec *spec = ObjectSpec::Get(i);
280  if (!spec->IsEverAvailable()) continue;
281  two_wide |= spec->views >= 2;
282  height[spec->views / 4] = std::max<int>(ObjectSpec::Get(i)->height, height[spec->views / 4]);
283  }
284 
285  /* Determine the pixel heights. */
286  for (size_t i = 0; i < lengthof(height); i++) {
288  height[i] += ScaleGUITrad(TILE_PIXELS) + 2 * this->object_margin;
289  }
290 
291  /* Now determine the size of the minimum widgets. When there are two columns, then
292  * we want these columns to be slightly less wide. When there are two rows, then
293  * determine the size of the widgets based on the maximum size for a single row
294  * of widgets, or just the twice the widget height of the two row ones. */
295  size->height = std::max(height[0], height[1] * 2);
296  if (two_wide) {
297  size->width = (3 * ScaleGUITrad(TILE_PIXELS) + 2 * this->object_margin) * 2;
298  } else {
299  size->width = 4 * ScaleGUITrad(TILE_PIXELS) + 2 * this->object_margin;
300  }
301 
302  /* Get the right size for the single widget based on the current spec. */
304  const ObjectSpec *spec = objclass->GetSpec(_selected_object_index);
305  if (spec != nullptr) {
306  if (spec->views <= 1) size->width += WidgetDimensions::scaled.hsep_normal;
307  if (spec->views <= 2) size->height += WidgetDimensions::scaled.vsep_normal;
308  if (spec->views >= 2) size->width /= 2;
309  if (spec->views >= 4) size->height /= 2;
310  }
311  break;
312  }
313 
314  case WID_BO_INFO:
315  size->height = this->info_height;
316  break;
317 
319  fill->height = 1;
320  resize->height = 1;
321  break;
322 
323  case WID_BO_SELECT_IMAGE:
326  break;
327 
328  default: break;
329  }
330  }
331 
332  void DrawWidget(const Rect &r, int widget) const override
333  {
334  switch (GB(widget, 0, 16)) {
335  case WID_BO_CLASS_LIST: {
336  Rect mr = r.Shrink(WidgetDimensions::scaled.matrix);
337  uint pos = 0;
338  for (auto object_class_id : this->object_classes) {
339  ObjectClass *objclass = ObjectClass::Get(object_class_id);
340  if (objclass->GetUISpecCount() == 0) continue;
341  if (!this->vscroll->IsVisible(pos++)) continue;
342  DrawString(mr, objclass->name,
343  (object_class_id == _selected_object_class) ? TC_WHITE : TC_BLACK);
344  mr.top += this->line_height;
345  }
346  break;
347  }
348 
349  case WID_BO_OBJECT_SPRITE: {
350  if (_selected_object_index == -1) break;
351 
353  const ObjectSpec *spec = objclass->GetSpec(_selected_object_index);
354  if (spec == nullptr) break;
355 
356  /* Height of the selection matrix.
357  * Depending on the number of views, the matrix has a 1x1, 1x2, 2x1 or 2x2 layout. To make the previews
358  * look nice in all layouts, we use the 4x4 layout (smallest previews) as starting point. For the bigger
359  * previews in the layouts with less views we add space homogeneously on all sides, so the 4x4 preview-rectangle
360  * is centered in the 2x1, 1x2 resp. 1x1 buttons. */
361  uint matrix_height = this->GetWidget<NWidgetMatrix>(WID_BO_OBJECT_MATRIX)->current_y;
362 
363  DrawPixelInfo tmp_dpi;
364  /* Set up a clipping area for the preview. */
365  if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
366  DrawPixelInfo *old_dpi = _cur_dpi;
367  _cur_dpi = &tmp_dpi;
368  if (spec->grf_prop.grffile == nullptr) {
369  extern const DrawTileSprites _objects[];
370  const DrawTileSprites *dts = &_objects[spec->grf_prop.local_id];
371  DrawOrigTileSeqInGUI(r.Width() / 2 - 1, (r.Height() + matrix_height / 2) / 2 - this->object_margin - ScaleSpriteTrad(TILE_PIXELS), dts, PAL_NONE);
372  } else {
373  DrawNewObjectTileInGUI(r.Width() / 2 - 1, (r.Height() + matrix_height / 2) / 2 - this->object_margin - ScaleSpriteTrad(TILE_PIXELS), spec, GB(widget, 16, 16));
374  }
375  _cur_dpi = old_dpi;
376  }
377  break;
378  }
379 
380  case WID_BO_SELECT_IMAGE: {
382  int obj_index = objclass->GetIndexFromUI(GB(widget, 16, 16));
383  if (obj_index < 0) break;
384  const ObjectSpec *spec = objclass->GetSpec(obj_index);
385  if (spec == nullptr) break;
386 
387  if (!spec->IsAvailable()) {
389  }
390  DrawPixelInfo tmp_dpi;
391  /* Set up a clipping area for the preview. */
392  if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
393  DrawPixelInfo *old_dpi = _cur_dpi;
394  _cur_dpi = &tmp_dpi;
395  if (spec->grf_prop.grffile == nullptr) {
396  extern const DrawTileSprites _objects[];
397  const DrawTileSprites *dts = &_objects[spec->grf_prop.local_id];
398  DrawOrigTileSeqInGUI(r.Width() / 2 - 1, r.Height() - this->object_margin - ScaleSpriteTrad(TILE_PIXELS), dts, PAL_NONE);
399  } else {
400  DrawNewObjectTileInGUI(r.Width() / 2 - 1, r.Height() - this->object_margin - ScaleSpriteTrad(TILE_PIXELS), spec,
401  std::min<int>(_selected_object_view, spec->views - 1));
402  }
403  _cur_dpi = old_dpi;
404  }
405  break;
406  }
407 
408  case WID_BO_INFO: {
410  const ObjectSpec *spec = objclass->GetSpec(_selected_object_index);
411  if (spec == nullptr) break;
412 
413  /* Get the extra message for the GUI */
415  uint16 callback_res = GetObjectCallback(CBID_OBJECT_FUND_MORE_TEXT, 0, 0, spec, nullptr, INVALID_TILE, _selected_object_view);
416  if (callback_res != CALLBACK_FAILED && callback_res != 0x400) {
417  if (callback_res > 0x400) {
419  } else {
420  StringID message = GetGRFStringID(spec->grf_prop.grffile->grfid, 0xD000 + callback_res);
421  if (message != STR_NULL && message != STR_UNDEFINED) {
423  /* Use all the available space left from where we stand up to the
424  * end of the window. We ALSO enlarge the window if needed, so we
425  * can 'go' wild with the bottom of the window. */
426  int y = DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, message, TC_ORANGE) - r.top - 1;
428  if (y > this->info_height) {
429  BuildObjectWindow *bow = const_cast<BuildObjectWindow *>(this);
430  bow->info_height = y;
431  bow->ReInit();
432  }
433  }
434  }
435  }
436  }
437  }
438  }
439  }
440 
445  void SelectOtherClass(ObjectClassID object_class)
446  {
447  _selected_object_class = object_class;
448  ObjectClass *objclass = ObjectClass::Get(object_class);
449  this->GetWidget<NWidgetMatrix>(WID_BO_SELECT_MATRIX)->SetCount(objclass->GetUISpecCount());
450  }
451 
456  void SelectOtherObject(int object_index)
457  {
458  _selected_object_index = object_index;
459  if (_selected_object_index != -1) {
461  const ObjectSpec *spec = objclass->GetSpec(_selected_object_index);
462  _selected_object_view = std::min<int>(_selected_object_view, spec->views - 1);
463  this->ReInit();
464  } else {
466  }
467 
468  if (_selected_object_index != -1) {
469  SetObjectToPlaceWnd(SPR_CURSOR_TRANSMITTER, PAL_NONE, HT_RECT | HT_DIAGONAL, this);
470  }
471 
473  }
474 
475  void UpdateSelectSize()
476  {
477  if (_selected_object_index == -1) {
478  SetTileSelectSize(1, 1);
479  } else {
481  const ObjectSpec *spec = objclass->GetSpec(_selected_object_index);
482  int w = GB(spec->size, HasBit(_selected_object_view, 0) ? 4 : 0, 4);
483  int h = GB(spec->size, HasBit(_selected_object_view, 0) ? 0 : 4, 4);
484  SetTileSelectSize(w, h);
485  }
486  }
487 
494  void UpdateButtons(ObjectClassID object_class, int sel_index, uint sel_view)
495  {
496  int view_number, object_number;
497  if (sel_index == -1) {
498  view_number = -1; // If no object selected, also hide the selected view.
499  object_number = -1;
500  } else {
501  view_number = sel_view;
503  object_number = objclass->GetUIFromIndex(sel_index);
504  }
505 
506  this->GetWidget<NWidgetMatrix>(WID_BO_OBJECT_MATRIX)->SetClicked(view_number);
507  this->GetWidget<NWidgetMatrix>(WID_BO_SELECT_MATRIX)->SetClicked(object_number);
508  this->UpdateSelectSize();
509  this->SetDirty();
510  }
511 
512  void OnInvalidateData(int data = 0, bool gui_scope = true) override
513  {
514  if (!gui_scope) return;
515 
517  }
518 
519  void OnResize() override
520  {
521  this->vscroll->SetCapacityFromWidget(this, WID_BO_CLASS_LIST);
522  }
523 
524  void OnClick(Point pt, int widget, int click_count) override
525  {
526  switch (GB(widget, 0, 16)) {
527  case WID_BO_CLASS_LIST: {
528  int num_clicked = this->vscroll->GetPosition() + (pt.y - this->GetWidget<NWidgetBase>(widget)->pos_y) / this->line_height;
529  if (num_clicked >= (int)this->object_classes.size()) break;
530 
531  this->SelectOtherClass(this->object_classes[num_clicked]);
532  this->SelectFirstAvailableObject(false);
533  break;
534  }
535 
536  case WID_BO_SELECT_IMAGE: {
538  int num_clicked = objclass->GetIndexFromUI(GB(widget, 16, 16));
539  if (num_clicked >= 0 && objclass->GetSpec(num_clicked)->IsAvailable()) this->SelectOtherObject(num_clicked);
540  break;
541  }
542 
544  if (_selected_object_index != -1) {
545  _selected_object_view = GB(widget, 16, 16);
546  this->SelectOtherObject(_selected_object_index); // Re-select the object for a different view.
547  }
548  break;
549  }
550  }
551 
552  void OnPlaceObject(Point pt, TileIndex tile) override
553  {
555 
556  if (spec->size == OBJECT_SIZE_1X1) {
558  } else {
559  Command<CMD_BUILD_OBJECT>::Post(STR_ERROR_CAN_T_BUILD_OBJECT, CcPlaySound_CONSTRUCTION_OTHER, tile, spec->Index(), _selected_object_view);
560  }
561  }
562 
563  void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override
564  {
565  VpSelectTilesWithMethod(pt.x, pt.y, select_method);
566  }
567 
568  void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) override
569  {
570  if (pt.x == -1) return;
571 
572  switch (select_proc) {
573  default: NOT_REACHED();
574  case DDSP_BUILD_OBJECT:
576  /* When end_tile is MP_VOID, the error tile will not be visible to the
577  * user. This happens when terraforming at the southern border. */
578  if (TileX(end_tile) == MapMaxX()) end_tile += TileDiffXY(-1, 0);
579  if (TileY(end_tile) == MapMaxY()) end_tile += TileDiffXY(0, -1);
580  }
582  Command<CMD_BUILD_OBJECT_AREA>::Post(STR_ERROR_CAN_T_BUILD_OBJECT, CcPlaySound_CONSTRUCTION_OTHER,
583  end_tile, start_tile, spec->Index(), _selected_object_view, (_ctrl_pressed ? true : false));
584  break;
585  }
586  }
587 
588  void OnPlaceObjectAbort() override
589  {
591  }
592 
593  EventState OnHotkey(int hotkey) override
594  {
595  switch (hotkey) {
598  SetFocusedWindow(this); // The user has asked to give focus to the text box, so make sure this window is focused.
599  break;
600 
601  default:
602  return ES_NOT_HANDLED;
603  }
604 
605  return ES_HANDLED;
606  }
607 
608  void OnEditboxChanged(int wid) override
609  {
610  string_filter.SetFilterTerm(this->filter_editbox.text.buf);
611  this->object_classes.SetFilterState(!string_filter.IsEmpty());
612  this->object_classes.ForceRebuild();
613  this->InvalidateData();
614  }
615 
621  void SelectFirstAvailableObject(bool change_class)
622  {
624 
625  /* First try to select an object in the selected class. */
626  for (uint i = 0; i < objclass->GetSpecCount(); i++) {
627  const ObjectSpec *spec = objclass->GetSpec(i);
628  if (spec->IsAvailable()) {
629  this->SelectOtherObject(i);
630  return;
631  }
632  }
633  if (change_class) {
634  /* If that fails, select the first available object
635  * from a random class. */
636  for (auto object_class_id : this->object_classes) {
637  ObjectClass *objclass = ObjectClass::Get(object_class_id);
638  for (uint i = 0; i < objclass->GetSpecCount(); i++) {
639  const ObjectSpec *spec = objclass->GetSpec(i);
640  if (spec->IsAvailable()) {
641  this->SelectOtherClass(object_class_id);
642  this->SelectOtherObject(i);
643  return;
644  }
645  }
646  }
647  }
648  /* If all objects are unavailable, select nothing... */
649  if (objclass->GetUISpecCount() == 0) {
650  /* ... but make sure that the class is not empty. */
651  for (auto object_class_id : this->object_classes) {
652  ObjectClass *objclass = ObjectClass::Get(object_class_id);
653  if (objclass->GetUISpecCount() > 0) {
654  this->SelectOtherClass(object_class_id);
655  break;
656  }
657  }
658  }
659  this->SelectOtherObject(-1);
660  }
661 
662  static HotkeyList hotkeys;
663 };
664 
671 {
672  if (_game_mode == GM_MENU) return ES_NOT_HANDLED;
674  if (w == nullptr) return ES_NOT_HANDLED;
675  return w->OnHotkey(hotkey);
676 }
677 
678 static Hotkey buildobject_hotkeys[] = {
679  Hotkey('F', "focus_filter_box", BOHK_FOCUS_FILTER_BOX),
680  HOTKEY_LIST_END
681 };
682 HotkeyList BuildObjectWindow::hotkeys("buildobject", buildobject_hotkeys, BuildObjectGlobalHotkeys);
683 
686 
688  &ObjectClassIDSorter,
689 };
690 
692  &TagNameFilter,
693 };
694 
695 static const NWidgetPart _nested_build_object_widgets[] = {
697  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
698  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_OBJECT_BUILD_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
699  NWidget(WWT_SHADEBOX, COLOUR_DARK_GREEN),
700  NWidget(WWT_DEFSIZEBOX, COLOUR_DARK_GREEN),
701  NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
702  EndContainer(),
703  NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
704  NWidget(NWID_HORIZONTAL), SetPadding(2, 0, 0, 2),
705  NWidget(NWID_VERTICAL), SetPadding(0, 5, 2, 0), SetPIP(0, 2, 0),
707  NWidget(WWT_TEXT, COLOUR_DARK_GREEN), SetFill(0, 1), SetDataTip(STR_LIST_FILTER_TITLE, STR_NULL),
708  NWidget(WWT_EDITBOX, COLOUR_GREY, WID_BO_FILTER), SetFill(1, 0), SetResize(1, 0),
709  SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
710  EndContainer(),
712  NWidget(WWT_MATRIX, COLOUR_GREY, WID_BO_CLASS_LIST), SetFill(1, 0), SetMatrixDataTip(1, 0, STR_OBJECT_BUILD_CLASS_TOOLTIP), SetScrollbar(WID_BO_SCROLLBAR),
714  EndContainer(),
716  NWidget(NWID_MATRIX, COLOUR_DARK_GREEN, WID_BO_OBJECT_MATRIX), SetPIP(0, 2, 0),
717  NWidget(WWT_PANEL, COLOUR_GREY, WID_BO_OBJECT_SPRITE), SetDataTip(0x0, STR_OBJECT_BUILD_PREVIEW_TOOLTIP), EndContainer(),
718  EndContainer(),
719  EndContainer(),
720  NWidget(WWT_TEXT, COLOUR_DARK_GREEN, WID_BO_OBJECT_NAME), SetDataTip(STR_ORANGE_STRING, STR_NULL),
721  NWidget(WWT_TEXT, COLOUR_DARK_GREEN, WID_BO_OBJECT_SIZE), SetDataTip(STR_OBJECT_BUILD_SIZE, STR_NULL),
722  EndContainer(),
723  NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetScrollbar(WID_BO_SELECT_SCROLL),
725  NWidget(NWID_MATRIX, COLOUR_DARK_GREEN, WID_BO_SELECT_MATRIX), SetFill(0, 1), SetPIP(0, 2, 0),
726  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BO_SELECT_IMAGE), SetMinimalSize(66, 60), SetDataTip(0x0, STR_OBJECT_BUILD_TOOLTIP),
728  EndContainer(),
729  EndContainer(),
730  NWidget(NWID_VSCROLLBAR, COLOUR_DARK_GREEN, WID_BO_SELECT_SCROLL),
731  EndContainer(),
732  EndContainer(),
733  EndContainer(),
735  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_BO_INFO), SetPadding(0, 5, 2, 2), SetFill(1, 0), SetResize(1, 0),
737  NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetFill(0, 1), EndContainer(),
738  NWidget(WWT_RESIZEBOX, COLOUR_DARK_GREEN),
739  EndContainer(),
740  EndContainer(),
741  EndContainer(),
742 };
743 
744 static WindowDesc _build_object_desc(
745  WDP_AUTO, "build_object", 0, 0,
748  _nested_build_object_widgets, lengthof(_nested_build_object_widgets),
749  &BuildObjectWindow::hotkeys
750 );
751 
754 {
755  /* Don't show the place object button when there are no objects to place. */
756  if (ObjectClass::GetUIClassCount() > 0) {
757  return AllocateWindowDescFront<BuildObjectWindow>(&_build_object_desc, 0);
758  }
759  return nullptr;
760 }
761 
764 {
766 }
ES_HANDLED
@ ES_HANDLED
The passed event is handled.
Definition: window_type.h:720
OBJECT_CLASS_BEGIN
@ OBJECT_CLASS_BEGIN
The lowest valid value.
Definition: newgrf_object.h:49
_selected_object_index
static int _selected_object_index
Index of the currently selected object if existing, else -1.
Definition: object_gui.cpp:38
WID_BO_FILTER
@ WID_BO_FILTER
The filter text box for the object list.
Definition: object_widget.h:15
BuildObjectWindow::ObjectClassIDSorter
static bool ObjectClassIDSorter(ObjectClassID const &a, ObjectClassID const &b)
Sort object classes by ObjectClassID.
Definition: object_gui.cpp:136
SetTileSelectSize
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
Definition: viewport.cpp:2483
BuildObjectWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: object_gui.cpp:512
BuildObjectWindow::CanRestoreSelectedObject
bool CanRestoreSelectedObject()
Tests whether the previously selected object can be selected.
Definition: object_gui.cpp:80
Rect::Height
int Height() const
Get height of Rect.
Definition: geometry_type.hpp:85
WC_BUILD_TOOLBAR
@ WC_BUILD_TOOLBAR
Build toolbar; Window numbers:
Definition: window_type.h:66
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
SetScrollbar
static NWidgetPart SetScrollbar(int index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1210
NewGRFClass::GetUISpecCount
uint GetUISpecCount() const
Get the number of potentially user-available specs within the class.
Definition: newgrf_class.h:46
BuildObjectWindow::OnPlaceMouseUp
void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) override
The user has dragged over the map when the tile highlight mode has been set.
Definition: object_gui.cpp:568
HotkeyList
List of hotkeys for a window.
Definition: hotkeys.h:40
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
SetFocusedWindow
void SetFocusedWindow(Window *w)
Set the window that has the focus.
Definition: window.cpp:455
BuildObjectHotkeys
BuildObjectHotkeys
Enum referring to the Hotkeys in the build object window.
Definition: object_gui.cpp:42
DrawOrigTileSeqInGUI
static void DrawOrigTileSeqInGUI(int x, int y, const DrawTileSprites *dts, PaletteID default_palette)
Draw TTD sprite sequence in GUI.
Definition: sprite.h:115
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:27
BuildObjectWindow::GetMatrixColumnCount
uint GetMatrixColumnCount()
Calculate the number of columns of the WID_BO_SELECT_MATRIX widget.
Definition: object_gui.cpp:94
command_func.h
ObjectSpec
Allow incrementing of ObjectClassID variables.
Definition: newgrf_object.h:60
ObjectSpec::grf_prop
GRFFilePropsBase< 2 > grf_prop
Properties related the the grf file.
Definition: newgrf_object.h:62
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
GUIList::Sort
bool Sort(Comp compare)
Sort the list.
Definition: sortlist_type.h:247
Window::GetScrollbar
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
Definition: window.cpp:319
WDF_CONSTRUCTION
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Definition: window_gui.h:144
Rect::Shrink
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Definition: geometry_type.hpp:92
StringFilter::IsEmpty
bool IsEmpty() const
Check whether any filter words were entered.
Definition: stringfilter_type.h:59
terraform_cmd.h
Window::ReInit
void ReInit(int rx=0, int ry=0)
Re-initialize a window, and optionally change its size.
Definition: window.cpp:1019
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
BuildObjectWindow::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: object_gui.cpp:524
StringFilter::SetFilterTerm
void SetFilterTerm(const char *str)
Set the term to filter on.
Definition: stringfilter.cpp:27
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:59
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:780
NewGRFClass::GetSpecCount
uint GetSpecCount() const
Get the number of allocated specs within the class.
Definition: newgrf_class.h:44
NWidgetMatrix
Matrix container with implicitly equal sized (virtual) sub-widgets.
Definition: widget_type.h:539
GUIList< ObjectClassID, StringFilter & >
BuildObjectWindow::OnInit
void OnInit() override
Notification that the nested widget tree gets initialized.
Definition: object_gui.cpp:233
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
BuildObjectWindow
The window used for building objects.
Definition: object_gui.cpp:47
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:73
ObjectSpec::IsAvailable
bool IsAvailable() const
Check whether the object is available at this time.
Definition: newgrf_object.cpp:78
object_widget.h
WWT_MATRIX
@ WWT_MATRIX
Grid of rows and columns.
Definition: widget_type.h:57
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
INVALID_TILE
static constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:108
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
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:38
FILLRECT_CHECKER
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
Definition: gfx_type.h:294
DrawNewObjectTileInGUI
void DrawNewObjectTileInGUI(int x, int y, const ObjectSpec *spec, uint8 view)
Draw representation of an object (tile) for GUI purposes.
Definition: newgrf_object.cpp:464
NUM_OBJECTS
static const ObjectType NUM_OBJECTS
Number of supported objects overall.
Definition: object_type.h:25
SetResize
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:997
zoom_func.h
WID_BO_INFO
@ WID_BO_INFO
Other information about the object (from the NewGRF).
Definition: object_widget.h:22
StartTextRefStackUsage
void StartTextRefStackUsage(const GRFFile *grffile, byte numEntries, const uint32 *values)
Start using the TTDP compatible string code parsing.
Definition: newgrf_text.cpp:821
NWidgetMatrix::SetScrollbar
void SetScrollbar(Scrollbar *sb)
Assign a scrollbar to this matrix.
Definition: widget.cpp:1905
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
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget array.
Definition: widget_type.h:46
TileY
static uint TileY(TileIndex tile)
Get the Y component of a tile.
Definition: map_func.h:215
StringFilter::AddLine
void AddLine(const char *str)
Pass another text line from the current item to the filter.
Definition: stringfilter.cpp:104
WindowNumber
int32 WindowNumber
Number to differentiate different windows of the same class.
Definition: window_type.h:713
StopTextRefStackUsage
void StopTextRefStackUsage()
Stop using the TTDP compatible string code parsing.
Definition: newgrf_text.cpp:838
InitializeObjectGui
void InitializeObjectGui()
Reset all data of the object GUI.
Definition: object_gui.cpp:763
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:59
BuildObjectWindow::SelectOtherClass
void SelectOtherClass(ObjectClassID object_class)
Select the specified object class.
Definition: object_gui.cpp:445
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:76
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:636
ObjectSpec::Get
static const ObjectSpec * Get(ObjectType index)
Get the specification associated with a specific ObjectType.
Definition: newgrf_object.cpp:39
Window::OnHotkey
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
Definition: window.cpp:634
ObjectSpec::size
uint8 size
The size of this objects; low nibble for X, high nibble for Y.
Definition: newgrf_object.h:67
ObjectSpec::callback_mask
uint16 callback_mask
Bitmask of requested/allowed callbacks.
Definition: newgrf_object.h:74
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
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:975
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1111
QueryString
Data stored about a string that can be modified in the GUI.
Definition: querystring_gui.h:20
WID_BO_SELECT_MATRIX
@ WID_BO_SELECT_MATRIX
Selection preview matrix of objects of a given class.
Definition: object_widget.h:24
BuildObjectWindow::OnPlaceObject
void OnPlaceObject(Point pt, TileIndex tile) override
The user clicked some place on the map when a tile highlight mode has been set.
Definition: object_gui.cpp:552
BuildObjectWindow::OnResize
void OnResize() override
Called after the window got resized.
Definition: object_gui.cpp:519
GetStringBoundingBox
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:890
GUIList::SetFilterFuncs
void SetFilterFuncs(FilterFunction *const *n_funcs)
Hand the array of filter function pointers to the sort list.
Definition: sortlist_type.h:341
Textbuf::buf
char *const buf
buffer in which text is saved
Definition: textbuf_type.h:32
TileX
static uint TileX(TileIndex tile)
Get the X component of a tile.
Definition: map_func.h:205
Window::querystrings
SmallMap< int, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
Definition: window_gui.h:257
BuildObjectWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: object_gui.cpp:210
DrawStringMultiLine
int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
Definition: gfx.cpp:789
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:178
NWidgetMatrix::SetCount
void SetCount(int count)
Set the number of elements in this matrix.
Definition: widget.cpp:1881
WindowDesc
High level window description.
Definition: window_gui.h:102
CBM_OBJ_FUND_MORE_TEXT
@ CBM_OBJ_FUND_MORE_TEXT
additional text in fund window
Definition: newgrf_callbacks.h:390
window_gui.h
WID_BO_SCROLLBAR
@ WID_BO_SCROLLBAR
The scrollbar associated with the list.
Definition: object_widget.h:17
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:494
BuildObjectWindow::TagNameFilter
static bool CDECL TagNameFilter(ObjectClassID const *oc, StringFilter &filter)
Filter object classes by class name.
Definition: object_gui.cpp:142
_selected_object_view
static uint8 _selected_object_view
the view of the selected object
Definition: object_gui.cpp:39
WDP_AUTO
@ WDP_AUTO
Find a place automatically.
Definition: window_gui.h:90
Listing
Data structure describing how to show the list (what sort direction and criteria).
Definition: sortlist_type.h:30
GUIList::SetFilterState
void SetFilterState(bool state)
Enable or disable the filter.
Definition: sortlist_type.h:302
DRAW_STRING_BUFFER
static const int DRAW_STRING_BUFFER
Size of the buffer used for drawing strings.
Definition: gfx_func.h:86
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:251
tilehighlight_func.h
WidgetDimensions::hsep_normal
int hsep_normal
Normal horizontal spacing.
Definition: window_gui.h:63
WID_BO_SELECT_IMAGE
@ WID_BO_SELECT_IMAGE
Preview image in the WID_BO_SELECT_MATRIX.
Definition: object_widget.h:25
WWT_EDITBOX
@ WWT_EDITBOX
a textbox for typing
Definition: widget_type.h:69
Window::height
int height
Height of the window (number of pixels down in y direction)
Definition: window_gui.h:249
VpStartPlaceSizing
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
highlighting tiles while only going over them with the mouse
Definition: viewport.cpp:2665
ObjectClassID
ObjectClassID
Class IDs for objects.
Definition: newgrf_object.h:48
GUIList< ObjectClassID, StringFilter & >::SortFunction
bool SortFunction(const ObjectClassID &, const ObjectClassID &)
Signature of sort function.
Definition: sortlist_type.h:48
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:1008
BuildObjectWindow::filter_editbox
QueryString filter_editbox
Filter editbox.
Definition: object_gui.cpp:63
GUIList::SetListing
void SetListing(Listing l)
Import sort conditions.
Definition: sortlist_type.h:130
NWidgetBase::smallest_x
uint smallest_x
Smallest horizontal size of the widget in a filled window.
Definition: widget_type.h:193
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
BuildObjectGlobalHotkeys
static EventState BuildObjectGlobalHotkeys(int hotkey)
Handler for global hotkeys of the BuildObjectWindow.
Definition: object_gui.cpp:670
RectPadding::Horizontal
uint Horizontal() const
Get total horizontal padding of RectPadding.
Definition: geometry_type.hpp:59
BOHK_FOCUS_FILTER_BOX
@ BOHK_FOCUS_FILTER_BOX
Focus the edit box for editing the filter string.
Definition: object_gui.cpp:43
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:721
NWidgetBase
Baseclass for nested widgets.
Definition: widget_type.h:126
VpSelectTilesWithMethod
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
Definition: viewport.cpp:3150
ScaleSpriteTrad
static int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.
Definition: zoom_func.h:107
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
NewGRFClass
Struct containing information relating to NewGRF classes for stations and airports.
Definition: newgrf_class.h:19
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:54
Filtering
Data structure describing what to show in the list (filter criteria).
Definition: sortlist_type.h:35
_selected_object_class
static ObjectClassID _selected_object_class
Currently selected available object class.
Definition: object_gui.cpp:37
safeguards.h
WID_BO_OBJECT_SPRITE
@ WID_BO_OBJECT_SPRITE
A preview sprite of the object.
Definition: object_widget.h:19
sortlist_type.h
ConstructionSettings::freeform_edges
bool freeform_edges
allow terraforming the tiles at the map edges
Definition: settings_type.h:354
GetGRFStringID
StringID GetGRFStringID(uint32 grfid, StringID stringid)
Returns the index for this stringid associated with its grfID.
Definition: newgrf_text.cpp:601
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
BuildObjectWindow::GUIObjectClassList
GUIList< ObjectClassID, StringFilter & > GUIObjectClassList
Type definition for the list to hold available object classes.
Definition: object_gui.cpp:48
Window::SetFocusedWidget
bool SetFocusedWidget(int widget_index)
Set focus within this window to the given widget.
Definition: window.cpp:519
stdafx.h
PC_BLACK
static const uint8 PC_BLACK
Black palette colour.
Definition: gfx_func.h:242
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:116
RectPadding::Vertical
uint Vertical() const
Get total vertical padding of RectPadding.
Definition: geometry_type.hpp:65
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
viewport_func.h
object_cmd.h
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:75
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
BuildObjectWindow::BuildObjectClassesAvailable
void BuildObjectClassesAvailable()
Builds the filter list of available object classes.
Definition: object_gui.cpp:154
newgrf_object.h
ObjectSpec::name
StringID name
The name for this object.
Definition: newgrf_object.h:64
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
GUIList::NeedRebuild
bool NeedRebuild() const
Check if a rebuild is needed.
Definition: sortlist_type.h:362
string_func.h
CALLBACK_FAILED
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
Definition: newgrf_callbacks.h:408
ShowBuildObjectPicker
Window * ShowBuildObjectPicker()
Show our object picker.
Definition: object_gui.cpp:753
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
ObjectSpec::Index
uint Index() const
Gets the index of this spec.
Definition: newgrf_object.cpp:88
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1096
strings_func.h
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:82
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:593
MapMaxY
static uint MapMaxY()
Gets the maximum Y coordinate within the map, including MP_VOID.
Definition: map_func.h:111
WWT_TEXT
@ WWT_TEXT
Pure simple text.
Definition: widget_type.h:56
BuildObjectWindow::OnPlaceObjectAbort
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
Definition: object_gui.cpp:588
ObjectSpec::views
uint8 views
The number of views.
Definition: newgrf_object.h:76
FONT_HEIGHT_NORMAL
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:206
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
WidgetDimensions::fullbevel
RectPadding fullbevel
Always-scaled bevel border.
Definition: window_gui.h:46
Scrollbar::IsVisible
bool IsVisible(uint16 item) const
Checks whether given current item is visible in the list.
Definition: widget_type.h:688
GUIList< ObjectClassID, StringFilter & >::FilterFunction
bool CDECL FilterFunction(const ObjectClassID *, StringFilter &)
Signature of filter function.
Definition: sortlist_type.h:49
BuildObjectWindow::object_classes
GUIObjectClassList object_classes
Available object classes.
Definition: object_gui.cpp:61
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1014
StringFilter::ResetState
void ResetState()
Reset the matching state to process a new item.
Definition: stringfilter.cpp:88
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:48
TileDiffXY
static TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
Definition: map_func.h:179
WID_BO_SELECT_SCROLL
@ WID_BO_SELECT_SCROLL
Scrollbar next to the WID_BO_SELECT_MATRIX.
Definition: object_widget.h:26
newgrf.h
EventState
EventState
State of handling an event.
Definition: window_type.h:719
GetObjectCallback
uint16 GetObjectCallback(CallbackID callback, uint32 param1, uint32 param2, const ObjectSpec *spec, Object *o, TileIndex tile, uint8 view)
Perform a callback for an object.
Definition: newgrf_object.cpp:408
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
Scrollbar::GetPosition
uint16 GetPosition() const
Gets the position of the first visible element in the list.
Definition: widget_type.h:678
GUIList::SetFiltering
void SetFiltering(Filtering f)
Import filter conditions.
Definition: sortlist_type.h:181
StringFilter::GetState
bool GetState() const
Get the matching state of the current item.
Definition: stringfilter_type.h:69
WidgetDimensions::bevel
RectPadding bevel
Widths of bevel border.
Definition: window_gui.h:45
NewGRFClass::name
StringID name
Name of this class.
Definition: newgrf_class.h:39
GUIList::Filter
bool Filter(FilterFunction *decide, F filter_data)
Filter the list.
Definition: sortlist_type.h:318
Window::FinishInitNested
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition: window.cpp:1791
WID_BO_CLASS_LIST
@ WID_BO_CLASS_LIST
The list with classes.
Definition: object_widget.h:16
MapMaxX
static uint MapMaxX()
Gets the maximum X coordinate within the map, including MP_VOID.
Definition: map_func.h:102
BuildObjectWindow::object_margin
int object_margin
The margin (in pixels) around an object.
Definition: object_gui.cpp:52
CommandHelper
Definition: command_func.h:94
BuildObjectWindow::SelectFirstAvailableObject
void SelectFirstAvailableObject(bool change_class)
Select the first available object.
Definition: object_gui.cpp:621
window_func.h
GUIList::ForceRebuild
void ForceRebuild()
Force that a rebuild is needed.
Definition: sortlist_type.h:370
BuildObjectWindow::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: object_gui.cpp:238
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:386
stringfilter_type.h
NewGRFClass::Get
static NewGRFClass * Get(Tid cls_id)
Get a particular class.
Definition: newgrf_class_func.h:103
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
WC_BUILD_OBJECT
@ WC_BUILD_OBJECT
Build object; Window numbers:
Definition: window_type.h:369
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
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
WID_BO_OBJECT_NAME
@ WID_BO_OBJECT_NAME
The name of the selected object.
Definition: object_widget.h:20
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:3371
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1080
BuildObjectWindow::OnEditboxChanged
void OnEditboxChanged(int wid) override
The text in an editbox has been edited.
Definition: object_gui.cpp:608
BuildObjectWindow::string_filter
StringFilter string_filter
Filter for available objects.
Definition: object_gui.cpp:62
GRFFilePropsBase::local_id
uint16 local_id
id defined by the grf file for this entity
Definition: newgrf_commons.h:319
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:588
ErrorUnknownCallbackResult
void ErrorUnknownCallbackResult(uint32 grfid, uint16 cbid, uint16 cb_res)
Record that a NewGRF returned an unknown/invalid callback result.
Definition: newgrf_commons.cpp:516
BuildObjectWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: object_gui.cpp:332
Window
Data structure for an opened window.
Definition: window_gui.h:213
GUIList::RebuildDone
void RebuildDone()
Notify the sortlist that the rebuild is done.
Definition: sortlist_type.h:380
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:456
GRFFilePropsBase::grffile
const struct GRFFile * grffile
grf file that introduced this entity
Definition: newgrf_commons.h:320
BuildObjectWindow::last_sorting
static Listing last_sorting
Default sorting of GUIObjectClassList.
Definition: object_gui.cpp:57
OBJECT_SIZE_1X1
static const uint8 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
WID_BO_OBJECT_SIZE
@ WID_BO_OBJECT_SIZE
The size of the selected object.
Definition: object_widget.h:21
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
WID_BO_OBJECT_MATRIX
@ WID_BO_OBJECT_MATRIX
The matrix with preview sprites.
Definition: object_widget.h:18
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:69
NWidgetBase::resize_x
uint resize_x
Horizontal resize step (0 means not resizable).
Definition: widget_type.h:188
NWidgetBase::current_x
uint current_x
Current horizontal size (after resizing).
Definition: widget_type.h:196
lastof
#define lastof(x)
Get the last element of an fixed size array.
Definition: stdafx.h:402
ResetObjectToPlace
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
Definition: viewport.cpp:3434
StringFilter
String filter and state.
Definition: stringfilter_type.h:31
road_cmd.h
object.h
GUIList::SetSortFuncs
void SetSortFuncs(SortFunction *const *n_funcs)
Hand the array of sort function pointers to the sort list.
Definition: sortlist_type.h:270
DrawPixelInfo
Data about how and where to blit pixels.
Definition: gfx_type.h:151
Hotkey
All data for a single hotkey.
Definition: hotkeys.h:22
ScaleGUITrad
static RectPadding ScaleGUITrad(const RectPadding &r)
Scale a RectPadding to GUI zoom level.
Definition: widget.cpp:168
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:62
BuildObjectWindow::OnPlaceDrag
void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override
The user is dragging over the map when the tile highlight mode has been set.
Definition: object_gui.cpp:563
WidgetDimensions::vsep_normal
int vsep_normal
Normal vertical spacing.
Definition: window_gui.h:61