OpenTTD Source  13.2.1
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 #include "tree_cmd.h"
23 
24 #include "widgets/tree_widget.h"
25 
26 #include "table/sprites.h"
27 #include "table/strings.h"
28 #include "table/tree_land.h"
29 
30 #include "safeguards.h"
31 
32 void PlaceTreesRandomly();
33 uint PlaceTreeGroupAroundTile(TileIndex tile, TreeType treetype, uint radius, uint count, bool set_zone);
34 
37  { 1621, PAL_NONE }, { 1635, PAL_NONE }, { 1656, PAL_NONE }, { 1579, PAL_NONE },
38  { 1607, PAL_NONE }, { 1593, PAL_NONE }, { 1614, PAL_NONE }, { 1586, PAL_NONE },
39  { 1663, PAL_NONE }, { 1677, PAL_NONE }, { 1691, PAL_NONE }, { 1705, PAL_NONE },
40  { 1711, PAL_NONE }, { 1746, PAL_NONE }, { 1753, PAL_NONE }, { 1732, PAL_NONE },
41  { 1739, PAL_NONE }, { 1718, PAL_NONE }, { 1725, PAL_NONE }, { 1760, PAL_NONE },
42  { 1838, PAL_NONE }, { 1844, PAL_NONE }, { 1866, PAL_NONE }, { 1871, PAL_NONE },
43  { 1899, PAL_NONE }, { 1935, PAL_NONE }, { 1928, PAL_NONE }, { 1915, PAL_NONE },
44  { 1887, PAL_NONE }, { 1908, PAL_NONE }, { 1824, PAL_NONE }, { 1943, PAL_NONE },
45  { 1950, PAL_NONE }, { 1957, PALETTE_TO_GREEN }, { 1964, PALETTE_TO_RED }, { 1971, PAL_NONE },
46  { 1978, PAL_NONE }, { 1985, PALETTE_TO_RED, }, { 1992, PALETTE_TO_PALE_GREEN }, { 1999, PALETTE_TO_YELLOW }, { 2006, PALETTE_TO_RED }
47 };
48 
54 {
55  const uint16 base = _tree_base_by_landscape[_settings_game.game_creation.landscape];
56  const uint16 count = _tree_count_by_landscape[_settings_game.game_creation.landscape];
57 
58  Dimension size, this_size;
59  Point offset;
60  /* Avoid to use it uninitialized */
61  size.width = ScaleGUITrad(32); // default width - WD_FRAMERECT_LEFT
62  size.height = ScaleGUITrad(39); // default height - BUTTON_BOTTOM_OFFSET
63  offset.x = 0;
64  offset.y = 0;
65 
66  for (int i = base; i < base + count; i++) {
67  if (i >= (int)lengthof(tree_sprites)) return size;
68  this_size = GetSpriteSize(tree_sprites[i].sprite, &offset);
69  size.width = std::max<int>(size.width, 2 * std::max<int>(this_size.width, -offset.x));
70  size.height = std::max<int>(size.height, std::max<int>(this_size.height, -offset.y));
71  }
72 
73  return size;
74 }
75 
76 
80 class BuildTreesWindow : public Window
81 {
83  static const int BUTTON_BOTTOM_OFFSET = 7;
84 
85  enum PlantingMode {
86  PM_NORMAL,
87  PM_FOREST_SM,
88  PM_FOREST_LG,
89  };
90 
92  PlantingMode mode;
93 
97  void UpdateMode()
98  {
99  this->RaiseButtons();
100 
101  const int current_tree = this->tree_to_plant;
102 
103  if (this->tree_to_plant >= 0) {
104  /* Activate placement */
105  if (_settings_client.sound.confirm) SndPlayFx(SND_15_BEEP);
106  SetObjectToPlace(SPR_CURSOR_TREE, PAL_NONE, HT_RECT | HT_DIAGONAL, this->window_class, this->window_number);
107  this->tree_to_plant = current_tree; // SetObjectToPlace may call ResetObjectToPlace which may reset tree_to_plant to -1
108  } else {
109  /* Deactivate placement */
111  }
112 
113  if (this->tree_to_plant == TREE_INVALID) {
115  } else if (this->tree_to_plant >= 0) {
116  this->LowerWidget(WID_BT_TYPE_BUTTON_FIRST + this->tree_to_plant);
117  }
118 
119  switch (this->mode) {
120  case PM_NORMAL: this->LowerWidget(WID_BT_MODE_NORMAL); break;
121  case PM_FOREST_SM: this->LowerWidget(WID_BT_MODE_FOREST_SM); break;
122  case PM_FOREST_LG: this->LowerWidget(WID_BT_MODE_FOREST_LG); break;
123  default: NOT_REACHED();
124  }
125 
126  this->SetDirty();
127  }
128 
129  void DoPlantForest(TileIndex tile)
130  {
131  TreeType treetype = (TreeType)this->tree_to_plant;
132  if (this->tree_to_plant == TREE_INVALID) {
133  treetype = (TreeType)(InteractiveRandomRange(_tree_count_by_landscape[_settings_game.game_creation.landscape]) + _tree_base_by_landscape[_settings_game.game_creation.landscape]);
134  }
135  const uint radius = this->mode == PM_FOREST_LG ? 12 : 5;
136  const uint count = this->mode == PM_FOREST_LG ? 12 : 5;
137  // Create tropic zones only when the tree type is selected by the user and not picked randomly.
138  PlaceTreeGroupAroundTile(tile, treetype, radius, count, this->tree_to_plant != TREE_INVALID);
139  }
140 
141 public:
143  {
144  this->InitNested(window_number);
146 
148 
149  /* Show scenario editor tools in editor */
150  auto *se_tools = this->GetWidget<NWidgetStacked>(WID_BT_SE_PANE);
151  if (_game_mode != GM_EDITOR) {
152  se_tools->SetDisplayedPlane(SZSP_HORIZONTAL);
153  this->ReInit();
154  }
155  }
156 
157  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
158  {
159  if (widget >= WID_BT_TYPE_BUTTON_FIRST) {
160  /* Ensure tree type buttons are sized after the largest tree type */
162  size->width = d.width + padding.width;
163  size->height = d.height + padding.height + ScaleGUITrad(BUTTON_BOTTOM_OFFSET); // we need some more space
164  }
165  }
166 
167  void DrawWidget(const Rect &r, int widget) const override
168  {
169  if (widget >= WID_BT_TYPE_BUTTON_FIRST) {
170  const int index = widget - WID_BT_TYPE_BUTTON_FIRST;
171  /* Trees "grow" in the centre on the bottom line of the buttons */
172  DrawSprite(tree_sprites[index].sprite, tree_sprites[index].pal, CenterBounds(r.left, r.right, 0), r.bottom - ScaleGUITrad(BUTTON_BOTTOM_OFFSET));
173  }
174  }
175 
176  void OnClick(Point pt, int widget, int click_count) override
177  {
178  switch (widget) {
179  case WID_BT_TYPE_RANDOM: // tree of random type.
180  this->tree_to_plant = this->tree_to_plant == TREE_INVALID ? -1 : TREE_INVALID;
181  this->UpdateMode();
182  break;
183 
184  case WID_BT_MANY_RANDOM: // place trees randomly over the landscape
185  if (_settings_client.sound.confirm) SndPlayFx(SND_15_BEEP);
188  break;
189 
190  case WID_BT_MODE_NORMAL:
191  this->mode = PM_NORMAL;
192  this->UpdateMode();
193  break;
194 
196  assert(_game_mode == GM_EDITOR);
197  this->mode = PM_FOREST_SM;
198  this->UpdateMode();
199  break;
200 
202  assert(_game_mode == GM_EDITOR);
203  this->mode = PM_FOREST_LG;
204  this->UpdateMode();
205  break;
206 
207  default:
208  if (widget >= WID_BT_TYPE_BUTTON_FIRST) {
209  const int index = widget - WID_BT_TYPE_BUTTON_FIRST;
210  this->tree_to_plant = this->tree_to_plant == index ? -1 : index;
211  this->UpdateMode();
212  }
213  break;
214  }
215  }
216 
217  void OnPlaceObject(Point pt, TileIndex tile) override
218  {
219  if (_game_mode != GM_EDITOR && this->mode == PM_NORMAL) {
221  } else {
223  }
224  }
225 
226  void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override
227  {
228  if (_game_mode != GM_EDITOR && this->mode == PM_NORMAL) {
229  VpSelectTilesWithMethod(pt.x, pt.y, select_method);
230  } else {
231  TileIndex tile = TileVirtXY(pt.x, pt.y);
232 
233  if (this->mode == PM_NORMAL) {
234  Command<CMD_PLANT_TREE>::Post(tile, tile, this->tree_to_plant, false);
235  } else {
236  this->DoPlantForest(tile);
237  }
238  }
239  }
240 
241  void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) override
242  {
243  if (_game_mode != GM_EDITOR && this->mode == PM_NORMAL && pt.x != -1 && select_proc == DDSP_PLANT_TREES) {
244  Command<CMD_PLANT_TREE>::Post(STR_ERROR_CAN_T_PLANT_TREE_HERE, end_tile, start_tile, this->tree_to_plant, _ctrl_pressed);
245  }
246  }
247 
248  void OnPlaceObjectAbort() override
249  {
250  this->tree_to_plant = -1;
251  this->UpdateMode();
252  }
253 };
254 
261 static NWidgetBase *MakeTreeTypeButtons(int *biggest_index)
262 {
263  const byte type_base = _tree_base_by_landscape[_settings_game.game_creation.landscape];
264  const byte type_count = _tree_count_by_landscape[_settings_game.game_creation.landscape];
265 
266  /* Toyland has 9 tree types, which look better in 3x3 than 4x3 */
267  const int num_columns = type_count == 9 ? 3 : 4;
268  const int num_rows = CeilDiv(type_count, num_columns);
269  byte cur_type = type_base;
270 
272  vstack->SetPIP(0, 1, 0);
273 
274  for (int row = 0; row < num_rows; row++) {
276  hstack->SetPIP(0, 1, 0);
277  vstack->Add(hstack);
278  for (int col = 0; col < num_columns; col++) {
279  if (cur_type > type_base + type_count) break;
280  NWidgetBackground *button = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, WID_BT_TYPE_BUTTON_FIRST + cur_type);
281  button->SetDataTip(0x0, STR_PLANT_TREE_TOOLTIP);
282  hstack->Add(button);
283  *biggest_index = WID_BT_TYPE_BUTTON_FIRST + cur_type;
284  cur_type++;
285  }
286  }
287 
288  return vstack;
289 }
290 
291 static const NWidgetPart _nested_build_trees_widgets[] = {
293  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
294  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_PLANT_TREE_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
295  NWidget(WWT_SHADEBOX, COLOUR_DARK_GREEN),
296  NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
297  EndContainer(),
298  NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
302  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BT_TYPE_RANDOM), SetDataTip(STR_TREES_RANDOM_TYPE, STR_TREES_RANDOM_TYPE_TOOLTIP),
303  NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BT_SE_PANE),
307  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BT_MODE_NORMAL), SetFill(1, 0), SetDataTip(STR_TREES_MODE_NORMAL_BUTTON, STR_TREES_MODE_NORMAL_TOOLTIP),
308  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),
309  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),
310  EndContainer(),
312  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_BT_MANY_RANDOM), SetDataTip(STR_TREES_RANDOM_TREES_BUTTON, STR_TREES_RANDOM_TREES_TOOLTIP),
313  EndContainer(),
314  EndContainer(),
315  EndContainer(),
316  EndContainer(),
317 };
318 
319 static WindowDesc _build_trees_desc(
320  WDP_AUTO, "build_tree", 0, 0,
323  _nested_build_trees_widgets, lengthof(_nested_build_trees_widgets)
324 );
325 
326 void ShowBuildTreesToolbar()
327 {
328  if (_game_mode != GM_EDITOR && !Company::IsValidID(_local_company)) return;
329  AllocateWindowDescFront<BuildTreesWindow>(&_build_trees_desc, 0);
330 }
BuildTreesWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: tree_gui.cpp:167
sound_func.h
NWidgetFunction
static NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr)
Obtain a nested widget (sub)tree from an external source.
Definition: widget_type.h:1261
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:176
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:1143
WDF_CONSTRUCTION
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Definition: window_gui.h:144
GameCreationSettings::landscape
byte landscape
the landscape we're currently in
Definition: settings_type.h:328
Window::ReInit
void ReInit(int rx=0, int ry=0)
Re-initialize a window, and optionally change its size.
Definition: window.cpp:1019
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:1436
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
NWidgetContainer::Add
void Add(NWidgetBase *wid)
Append widget wid to container.
Definition: widget.cpp:1261
tree_cmd.h
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:83
PlaceTreeGroupAroundTile
uint PlaceTreeGroupAroundTile(TileIndex tile, TreeType treetype, uint radius, uint count, bool set_zone)
Place some trees in a radius around a tile.
Definition: tree_cmd.cpp:309
TileIndex
The index/ID of a Tile.
Definition: tile_type.h:85
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:38
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:597
WC_BUILD_TREES
@ WC_BUILD_TREES
Build trees toolbar; Window numbers:
Definition: window_type.h:79
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:53
SZSP_HORIZONTAL
@ SZSP_HORIZONTAL
Display plane with zero size vertically, and filling and resizing horizontally.
Definition: widget_type.h:427
WindowNumber
int32 WindowNumber
Number to differentiate different windows of the same class.
Definition: window_type.h:713
ViewportPlaceMethod
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
Definition: viewport_type.h:88
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:217
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:975
tree_land.h
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1111
GameSettings::game_creation
GameCreationSettings game_creation
settings used during the creation of a game (map)
Definition: settings_type.h:587
BuildTreesWindow::mode
PlantingMode mode
Current mode for planting.
Definition: tree_gui.cpp:92
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:226
gfx_func.h
WindowDesc
High level window description.
Definition: window_gui.h:102
window_gui.h
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:469
WDP_AUTO
@ WDP_AUTO
Find a place automatically.
Definition: window_gui.h:90
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:251
tilehighlight_func.h
PlaceTreesRandomly
void PlaceTreesRandomly()
Place some trees randomly.
Definition: tree_cmd.cpp:249
ClientSettings::sound
SoundSettings sound
sound effect settings
Definition: settings_type.h:607
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1804
VpStartPlaceSizing
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
highlighting tiles while only going over them with the mouse
Definition: viewport.cpp:2665
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:1008
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
HT_DIAGONAL
@ HT_DIAGONAL
Also allow 'diagonal rectangles'. Only usable in combination with HT_RECT or HT_POINT.
Definition: tilehighlight_type.h:28
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:3150
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:54
_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:2699
DrawSprite
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Definition: gfx.cpp:1058
sprites.h
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
stdafx.h
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition: window_gui.h:241
tree_sprites
const PalSpriteID tree_sprites[]
Tree Sprites with their palettes.
Definition: tree_gui.cpp:36
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:38
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:993
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:216
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
NWidgetCore::SetDataTip
void SetDataTip(uint32 widget_data, StringID tool_tip)
Set data and tool tip of the nested widget.
Definition: widget.cpp:1176
NWidgetHorizontal
Horizontal container.
Definition: widget_type.h:500
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1229
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1014
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:53
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
NWidgetVertical
Vertical container.
Definition: widget_type.h:523
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:241
Window::window_class
WindowClass window_class
Window class.
Definition: window_gui.h:240
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:97
CommandHelper
Definition: command_func.h:94
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:248
CenterBounds
static int CenterBounds(int min, int max, int size)
Determine where to draw a centred object inside a widget.
Definition: gfx_func.h:178
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:386
MarkWholeScreenDirty
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition: gfx.cpp:1767
random_func.hpp
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1080
CeilDiv
static uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
Definition: math_func.hpp:280
Window
Data structure for an opened window.
Definition: window_gui.h:213
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:116
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:3386
NWidgetBackground
Nested widget with a child.
Definition: widget_type.h:591
BuildTreesWindow::tree_to_plant
int tree_to_plant
Tree number to plant, TREE_INVALID for a random tree.
Definition: tree_gui.cpp:91
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:69
Window::LowerWidget
void LowerWidget(byte widget_index)
Marks a widget as lowered.
Definition: window_gui.h:403
BuildTreesWindow
The build trees window.
Definition: tree_gui.cpp:80
ResetObjectToPlace
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
Definition: viewport.cpp:3434
MakeTreeTypeButtons
static NWidgetBase * MakeTreeTypeButtons(int *biggest_index)
Make widgets for the current available tree types.
Definition: tree_gui.cpp:261
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:157
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
ScaleGUITrad
static RectPadding ScaleGUITrad(const RectPadding &r)
Scale a RectPadding to GUI zoom level.
Definition: widget.cpp:168
WWT_SHADEBOX
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition: widget_type.h:62