OpenTTD Source  12.0-beta2
tree_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 "window_gui.h"
12 #include "gfx_func.h"
13 #include "tilehighlight_func.h"
14 #include "company_func.h"
15 #include "company_base.h"
16 #include "command_func.h"
17 #include "core/random_func.hpp"
18 #include "sound_func.h"
19 #include "strings_func.h"
20 #include "zoom_func.h"
21 #include "tree_map.h"
22 
23 #include "widgets/tree_widget.h"
24 
25 #include "table/sprites.h"
26 #include "table/strings.h"
27 #include "table/tree_land.h"
28 
29 #include "safeguards.h"
30 
31 void PlaceTreesRandomly();
32 uint PlaceTreeGroupAroundTile(TileIndex tile, TreeType treetype, uint radius, uint count);
33 
36  { 1621, PAL_NONE }, { 1635, PAL_NONE }, { 1656, PAL_NONE }, { 1579, PAL_NONE },
37  { 1607, PAL_NONE }, { 1593, PAL_NONE }, { 1614, PAL_NONE }, { 1586, PAL_NONE },
38  { 1663, PAL_NONE }, { 1677, PAL_NONE }, { 1691, PAL_NONE }, { 1705, PAL_NONE },
39  { 1711, PAL_NONE }, { 1746, PAL_NONE }, { 1753, PAL_NONE }, { 1732, PAL_NONE },
40  { 1739, PAL_NONE }, { 1718, PAL_NONE }, { 1725, PAL_NONE }, { 1760, PAL_NONE },
41  { 1838, PAL_NONE }, { 1844, PAL_NONE }, { 1866, PAL_NONE }, { 1871, PAL_NONE },
42  { 1899, PAL_NONE }, { 1935, PAL_NONE }, { 1928, PAL_NONE }, { 1915, PAL_NONE },
43  { 1887, PAL_NONE }, { 1908, PAL_NONE }, { 1824, PAL_NONE }, { 1943, PAL_NONE },
44  { 1950, PAL_NONE }, { 1957, PALETTE_TO_GREEN }, { 1964, PALETTE_TO_RED }, { 1971, PAL_NONE },
45  { 1978, PAL_NONE }, { 1985, PALETTE_TO_RED, }, { 1992, PALETTE_TO_PALE_GREEN }, { 1999, PALETTE_TO_YELLOW }, { 2006, PALETTE_TO_RED }
46 };
47 
53 {
54  const uint16 base = _tree_base_by_landscape[_settings_game.game_creation.landscape];
55  const uint16 count = _tree_count_by_landscape[_settings_game.game_creation.landscape];
56 
57  Dimension size, this_size;
58  Point offset;
59  /* Avoid to use it uninitialized */
60  size.width = 32; // default width - WD_FRAMERECT_LEFT
61  size.height = 39; // default height - BUTTON_BOTTOM_OFFSET
62  offset.x = 0;
63  offset.y = 0;
64 
65  for (int i = base; i < base + count; i++) {
66  if (i >= (int)lengthof(tree_sprites)) return size;
67  this_size = GetSpriteSize(tree_sprites[i].sprite, &offset);
68  size.width = std::max<int>(size.width, 2 * std::max<int>(this_size.width, -offset.x));
69  size.height = std::max<int>(size.height, std::max<int>(this_size.height, -offset.y));
70  }
71 
72  return size;
73 }
74 
75 
79 class BuildTreesWindow : public Window
80 {
82  static const int BUTTON_BOTTOM_OFFSET = 7;
83 
84  enum PlantingMode {
85  PM_NORMAL,
86  PM_FOREST_SM,
87  PM_FOREST_LG,
88  };
89 
91  PlantingMode mode;
92 
96  void UpdateMode()
97  {
98  this->RaiseButtons();
99 
100  const int current_tree = this->tree_to_plant;
101 
102  if (this->tree_to_plant >= 0) {
103  /* Activate placement */
104  if (_settings_client.sound.confirm) SndPlayFx(SND_15_BEEP);
105  SetObjectToPlace(SPR_CURSOR_TREE, PAL_NONE, HT_RECT, this->window_class, this->window_number);
106  this->tree_to_plant = current_tree; // SetObjectToPlace may call ResetObjectToPlace which may reset tree_to_plant to -1
107  } else {
108  /* Deactivate placement */
110  }
111 
112  if (this->tree_to_plant == TREE_INVALID) {
114  } else if (this->tree_to_plant >= 0) {
115  this->LowerWidget(WID_BT_TYPE_BUTTON_FIRST + this->tree_to_plant);
116  }
117 
118  switch (this->mode) {
119  case PM_NORMAL: this->LowerWidget(WID_BT_MODE_NORMAL); break;
120  case PM_FOREST_SM: this->LowerWidget(WID_BT_MODE_FOREST_SM); break;
121  case PM_FOREST_LG: this->LowerWidget(WID_BT_MODE_FOREST_LG); break;
122  default: NOT_REACHED();
123  }
124 
125  this->SetDirty();
126  }
127 
128  void DoPlantForest(TileIndex tile)
129  {
130  TreeType treetype = (TreeType)this->tree_to_plant;
131  if (this->tree_to_plant == TREE_INVALID) {
132  treetype = (TreeType)(InteractiveRandomRange(_tree_count_by_landscape[_settings_game.game_creation.landscape]) + _tree_base_by_landscape[_settings_game.game_creation.landscape]);
133  }
134  const uint radius = this->mode == PM_FOREST_LG ? 12 : 5;
135  const uint count = this->mode == PM_FOREST_LG ? 12 : 5;
136  PlaceTreeGroupAroundTile(tile, treetype, radius, count);
137  }
138 
139 public:
141  {
142  this->InitNested(window_number);
144 
146 
147  /* Show scenario editor tools in editor */
148  auto *se_tools = this->GetWidget<NWidgetStacked>(WID_BT_SE_PANE);
149  if (_game_mode != GM_EDITOR) {
150  se_tools->SetDisplayedPlane(SZSP_HORIZONTAL);
151  this->ReInit();
152  }
153  }
154 
155  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
156  {
157  if (widget >= WID_BT_TYPE_BUTTON_FIRST) {
158  /* Ensure tree type buttons are sized after the largest tree type */
160  size->width = d.width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
161  size->height = d.height + WD_FRAMERECT_RIGHT + WD_FRAMERECT_BOTTOM + ScaleGUITrad(BUTTON_BOTTOM_OFFSET); // we need some more space
162  }
163  }
164 
165  void DrawWidget(const Rect &r, int widget) const override
166  {
167  if (widget >= WID_BT_TYPE_BUTTON_FIRST) {
168  const int index = widget - WID_BT_TYPE_BUTTON_FIRST;
169  /* Trees "grow" in the centre on the bottom line of the buttons */
170  DrawSprite(tree_sprites[index].sprite, tree_sprites[index].pal, (r.left + r.right) / 2 + WD_FRAMERECT_LEFT, r.bottom - ScaleGUITrad(BUTTON_BOTTOM_OFFSET));
171  }
172  }
173 
174  void OnClick(Point pt, int widget, int click_count) override
175  {
176  switch (widget) {
177  case WID_BT_TYPE_RANDOM: // tree of random type.
178  this->tree_to_plant = this->tree_to_plant == TREE_INVALID ? -1 : TREE_INVALID;
179  this->UpdateMode();
180  break;
181 
182  case WID_BT_MANY_RANDOM: // place trees randomly over the landscape
183  if (_settings_client.sound.confirm) SndPlayFx(SND_15_BEEP);
186  break;
187 
188  case WID_BT_MODE_NORMAL:
189  this->mode = PM_NORMAL;
190  this->UpdateMode();
191  break;
192 
194  assert(_game_mode == GM_EDITOR);
195  this->mode = PM_FOREST_SM;
196  this->UpdateMode();
197  break;
198 
200  assert(_game_mode == GM_EDITOR);
201  this->mode = PM_FOREST_LG;
202  this->UpdateMode();
203  break;
204 
205  default:
206  if (widget >= WID_BT_TYPE_BUTTON_FIRST) {
207  const int index = widget - WID_BT_TYPE_BUTTON_FIRST;
208  this->tree_to_plant = this->tree_to_plant == index ? -1 : index;
209  this->UpdateMode();
210  }
211  break;
212  }
213  }
214 
215  void OnPlaceObject(Point pt, TileIndex tile) override
216  {
217  if (_game_mode != GM_EDITOR && this->mode == PM_NORMAL) {
219  } else {
221  }
222  }
223 
224  void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override
225  {
226  if (_game_mode != GM_EDITOR && this->mode == PM_NORMAL) {
227  VpSelectTilesWithMethod(pt.x, pt.y, select_method);
228  } else {
229  TileIndex tile = TileVirtXY(pt.x, pt.y);
230 
231  if (this->mode == PM_NORMAL) {
232  DoCommandP(tile, this->tree_to_plant, tile, CMD_PLANT_TREE);
233  } else {
234  this->DoPlantForest(tile);
235  }
236  }
237  }
238 
239  void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) override
240  {
241  if (_game_mode != GM_EDITOR && this->mode == PM_NORMAL && pt.x != -1 && select_proc == DDSP_PLANT_TREES) {
242  DoCommandP(end_tile, this->tree_to_plant, start_tile, CMD_PLANT_TREE | CMD_MSG(STR_ERROR_CAN_T_PLANT_TREE_HERE));
243  }
244  }
245 
246  void OnPlaceObjectAbort() override
247  {
248  this->tree_to_plant = -1;
249  this->UpdateMode();
250  }
251 };
252 
259 static NWidgetBase *MakeTreeTypeButtons(int *biggest_index)
260 {
261  const byte type_base = _tree_base_by_landscape[_settings_game.game_creation.landscape];
262  const byte type_count = _tree_count_by_landscape[_settings_game.game_creation.landscape];
263 
264  /* Toyland has 9 tree types, which look better in 3x3 than 4x3 */
265  const int num_columns = type_count == 9 ? 3 : 4;
266  const int num_rows = CeilDiv(type_count, num_columns);
267  byte cur_type = type_base;
268 
270  vstack->SetPIP(0, 1, 0);
271 
272  for (int row = 0; row < num_rows; row++) {
274  hstack->SetPIP(0, 1, 0);
275  vstack->Add(hstack);
276  for (int col = 0; col < num_columns; col++) {
277  if (cur_type > type_base + type_count) break;
278  NWidgetBackground *button = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, WID_BT_TYPE_BUTTON_FIRST + cur_type);
279  button->SetDataTip(0x0, STR_PLANT_TREE_TOOLTIP);
280  hstack->Add(button);
281  *biggest_index = WID_BT_TYPE_BUTTON_FIRST + cur_type;
282  cur_type++;
283  }
284  }
285 
286  return vstack;
287 }
288 
289 static const NWidgetPart _nested_build_trees_widgets[] = {
291  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
292  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_PLANT_TREE_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
293  NWidget(WWT_SHADEBOX, COLOUR_DARK_GREEN),
294  NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
295  EndContainer(),
296  NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
300  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BT_TYPE_RANDOM), SetDataTip(STR_TREES_RANDOM_TYPE, STR_TREES_RANDOM_TYPE_TOOLTIP),
301  NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BT_SE_PANE),
305  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BT_MODE_NORMAL), SetFill(1, 0), SetDataTip(STR_TREES_MODE_NORMAL_BUTTON, STR_TREES_MODE_NORMAL_TOOLTIP),
306  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BT_MODE_FOREST_SM), SetFill(1, 0), SetDataTip(STR_TREES_MODE_FOREST_SM_BUTTON, STR_TREES_MODE_FOREST_SM_TOOLTIP),
307  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BT_MODE_FOREST_LG), SetFill(1, 0), SetDataTip(STR_TREES_MODE_FOREST_LG_BUTTON, STR_TREES_MODE_FOREST_LG_TOOLTIP),
308  EndContainer(),
310  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_BT_MANY_RANDOM), SetDataTip(STR_TREES_RANDOM_TREES_BUTTON, STR_TREES_RANDOM_TREES_TOOLTIP),
311  EndContainer(),
312  EndContainer(),
313  EndContainer(),
314  EndContainer(),
315 };
316 
317 static WindowDesc _build_trees_desc(
318  WDP_AUTO, "build_tree", 0, 0,
321  _nested_build_trees_widgets, lengthof(_nested_build_trees_widgets)
322 );
323 
324 void ShowBuildTreesToolbar()
325 {
326  if (_game_mode != GM_EDITOR && !Company::IsValidID(_local_company)) return;
327  AllocateWindowDescFront<BuildTreesWindow>(&_build_trees_desc, 0);
328 }
BuildTreesWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: tree_gui.cpp:165
CMD_MSG
#define CMD_MSG(x)
Used to combine a StringID with the command.
Definition: command_type.h:372
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:83
sound_func.h
NWidgetFunction
static NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr)
Obtain a nested widget (sub)tree from an external source.
Definition: widget_type.h:1239
WID_BT_SE_PANE
@ WID_BT_SE_PANE
Selection pane to show/hide scenario editor tools.
Definition: tree_widget.h:16
BuildTreesWindow::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: tree_gui.cpp:174
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:27
command_func.h
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:1139
WDF_CONSTRUCTION
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Definition: window_gui.h:210
GameCreationSettings::landscape
byte landscape
the landscape we're currently in
Definition: settings_type.h:320
Window::ReInit
void ReInit(int rx=0, int ry=0)
Re-initialize a window, and optionally change its size.
Definition: window.cpp:1004
company_base.h
NWidgetPIPContainer::SetPIP
void SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post)
Set additional pre/inter/post space for the container.
Definition: widget.cpp:1222
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:115
NWidgetContainer::Add
void Add(NWidgetBase *wid)
Append widget wid to container.
Definition: widget.cpp:1047
WID_BT_MANY_RANDOM
@ WID_BT_MANY_RANDOM
Button to build many random trees.
Definition: tree_widget.h:20
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:59
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:73
BuildTreesWindow::BUTTON_BOTTOM_OFFSET
static const int BUTTON_BOTTOM_OFFSET
Visual Y offset of tree root from the bottom of the tree type buttons.
Definition: tree_gui.cpp:82
SND_15_BEEP
@ SND_15_BEEP
19 == 0x13 GUI button click
Definition: sound_type.h:58
zoom_func.h
Window::RaiseButtons
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
Definition: window.cpp:584
WC_BUILD_TREES
@ WC_BUILD_TREES
Build trees toolbar; Window numbers:
Definition: window_type.h:78
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:52
SZSP_HORIZONTAL
@ SZSP_HORIZONTAL
Display plane with zero size vertically, and filling and resizing horizontally.
Definition: widget_type.h:422
WindowNumber
int32 WindowNumber
Number to differentiate different windows of the same class.
Definition: window_type.h:711
ViewportPlaceMethod
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
Definition: viewport_type.h:96
BuildTreesWindow::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: tree_gui.cpp:215
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:971
tree_land.h
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1107
GameSettings::game_creation
GameCreationSettings game_creation
settings used during the creation of a game (map)
Definition: settings_type.h:576
BuildTreesWindow::mode
PlantingMode mode
Current mode for planting.
Definition: tree_gui.cpp:91
BuildTreesWindow::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: tree_gui.cpp:224
gfx_func.h
WindowDesc
High level window description.
Definition: window_gui.h:168
window_gui.h
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:463
WDP_AUTO
@ WDP_AUTO
Find a place automatically.
Definition: window_gui.h:156
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:317
tilehighlight_func.h
PlaceTreesRandomly
void PlaceTreesRandomly()
Place some trees randomly.
Definition: tree_cmd.cpp:247
ClientSettings::sound
SoundSettings sound
sound effect settings
Definition: settings_type.h:596
DoCommandP
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
Definition: command.cpp:541
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1789
VpStartPlaceSizing
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
highlighting tiles while only going over them with the mouse
Definition: viewport.cpp:2654
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:993
WID_BT_TYPE_BUTTON_FIRST
@ WID_BT_TYPE_BUTTON_FIRST
First tree type selection button. (This must be last in the enum.)
Definition: tree_widget.h:21
WD_FRAMERECT_LEFT
@ WD_FRAMERECT_LEFT
Offset at left to draw the frame rectangular area.
Definition: window_gui.h:62
WD_FRAMERECT_RIGHT
@ WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
Definition: window_gui.h:63
WD_FRAMERECT_BOTTOM
@ WD_FRAMERECT_BOTTOM
Offset at bottom to draw the frame rectangular area.
Definition: window_gui.h:65
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:104
NWidgetBase
Baseclass for nested widgets.
Definition: widget_type.h:126
VpSelectTilesWithMethod
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
Definition: viewport.cpp:3139
TREE_INVALID
@ TREE_INVALID
An invalid tree.
Definition: tree_map.h:32
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:53
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:46
safeguards.h
VpStartDragging
void VpStartDragging(ViewportDragDropSelectionProcess process)
Drag over the map while holding the left mouse down.
Definition: viewport.cpp:2688
DrawSprite
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Definition: gfx.cpp:1041
sprites.h
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
PlaceTreeGroupAroundTile
uint PlaceTreeGroupAroundTile(TileIndex tile, TreeType treetype, uint radius, uint count)
Place some trees in a radius around a tile.
Definition: tree_cmd.cpp:306
stdafx.h
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition: window_gui.h:307
tree_sprites
const PalSpriteID tree_sprites[]
Tree Sprites with their palettes.
Definition: tree_gui.cpp:35
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:37
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:75
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:976
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:67
WID_BT_TYPE_RANDOM
@ WID_BT_TYPE_RANDOM
Button to build random type of tree.
Definition: tree_widget.h:15
SoundSettings::confirm
bool confirm
Play sound effect on successful constructions or other actions.
Definition: settings_type.h:208
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1092
strings_func.h
NWidgetCore::SetDataTip
void SetDataTip(uint32 widget_data, StringID tool_tip)
Set data and tool tip of the nested widget.
Definition: widget.cpp:962
NWidgetHorizontal
Horizontal container.
Definition: widget_type.h:493
ScaleGUITrad
static int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
Definition: zoom_func.h:76
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1207
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1010
tree_map.h
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:48
GetMaxTreeSpriteSize
static Dimension GetMaxTreeSpriteSize()
Calculate the maximum size of all tree sprites.
Definition: tree_gui.cpp:52
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:100
NWidgetVertical
Vertical container.
Definition: widget_type.h:516
BuildTreesWindow::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: tree_gui.cpp:239
Window::window_class
WindowClass window_class
Window class.
Definition: window_gui.h:306
PalSpriteID
Combination of a palette sprite and a 'real' sprite.
Definition: gfx_type.h:22
NWID_SPACER
@ NWID_SPACER
Invisible widget that takes some space.
Definition: widget_type.h:77
company_func.h
WID_BT_MODE_FOREST_LG
@ WID_BT_MODE_FOREST_LG
Select large forest planting mode.
Definition: tree_widget.h:19
BuildTreesWindow::UpdateMode
void UpdateMode()
Update the GUI and enable/disable planting to reflect selected options.
Definition: tree_gui.cpp:96
WID_BT_MODE_FOREST_SM
@ WID_BT_MODE_FOREST_SM
Select small forest planting mode.
Definition: tree_widget.h:18
BuildTreesWindow::OnPlaceObjectAbort
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
Definition: tree_gui.cpp:246
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:378
MarkWholeScreenDirty
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition: gfx.cpp:1689
random_func.hpp
CMD_PLANT_TREE
@ CMD_PLANT_TREE
plant a tree
Definition: command_type.h:212
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1076
CeilDiv
static uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
Definition: math_func.hpp:254
Window
Data structure for an opened window.
Definition: window_gui.h:279
tree_widget.h
Pool::PoolItem<&_company_pool >::IsValidID
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition: pool_type.hpp:326
DDSP_PLANT_TREES
@ DDSP_PLANT_TREES
Plant trees.
Definition: viewport_type.h:124
SetObjectToPlace
void SetObjectToPlace(CursorID icon, PaletteID pal, HighLightStyle mode, WindowClass window_class, WindowNumber window_num)
Change the cursor and mouse click/drag handling to a mode for performing special operations like tile...
Definition: viewport.cpp:3375
NWidgetBackground
Nested widget with a child.
Definition: widget_type.h:584
BuildTreesWindow::tree_to_plant
int tree_to_plant
Tree number to plant, TREE_INVALID for a random tree.
Definition: tree_gui.cpp:90
NWID_SELECTION
@ NWID_SELECTION
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition: widget_type.h:78
WID_BT_MODE_NORMAL
@ WID_BT_MODE_NORMAL
Select normal/rectangle planting mode.
Definition: tree_widget.h:17
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:47
Window::LowerWidget
void LowerWidget(byte widget_index)
Marks a widget as lowered.
Definition: window_gui.h:468
BuildTreesWindow
The build trees window.
Definition: tree_gui.cpp:79
ResetObjectToPlace
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
Definition: viewport.cpp:3423
MakeTreeTypeButtons
static NWidgetBase * MakeTreeTypeButtons(int *biggest_index)
Make widgets for the current available tree types.
Definition: tree_gui.cpp:259
BuildTreesWindow::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: tree_gui.cpp:155
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:53
TreeType
TreeType
List of tree types along all landscape types.
Definition: tree_map.h:25
TileVirtXY
static TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
Definition: map_func.h:194
WWT_SHADEBOX
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition: widget_type.h:62