OpenTTD Source: src/tree_gui.cpp Source File

OpenTTD Source 14.0-RC3

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
36 const PalSpriteID tree_sprites[] = {
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
53 static Dimension GetMaxTreeSpriteSize()
54 {
55 const uint16_t base = _tree_base_by_landscape[_settings_game.game_creation.landscape];
56 const uint16_t 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
91 int tree_to_plant;
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 */
110 ResetObjectToPlace();
111 }
112
113 if (this->tree_to_plant == TREE_INVALID) {
114 this->LowerWidget(WID_BT_TYPE_RANDOM);
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:
142 BuildTreesWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc), tree_to_plant(-1), mode(PM_NORMAL)
143 {
144 this->CreateNestedTree();
145 ResetObjectToPlace();
146
147 this->LowerWidget(WID_BT_MODE_NORMAL);
148 /* Show scenario editor tools in editor */
149 if (_game_mode != GM_EDITOR) {
150 this->GetWidget<NWidgetStacked>(WID_BT_SE_PANE)->SetDisplayedPlane(SZSP_HORIZONTAL);
151 }
152 this->FinishInitNested(window_number);
153 }
154
155 void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
156 {
157 if (widget >= WID_BT_TYPE_BUTTON_FIRST) {
158 /* Ensure tree type buttons are sized after the largest tree type */
159 Dimension d = GetMaxTreeSpriteSize();
160 size->width = d.width + padding.width;
161 size->height = d.height + padding.height + ScaleGUITrad(BUTTON_BOTTOM_OFFSET); // we need some more space
162 }
163 }
164
165 void DrawWidget(const Rect &r, WidgetID 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, CenterBounds(r.left, r.right, 0), r.bottom - ScaleGUITrad(BUTTON_BOTTOM_OFFSET));
171 }
172 }
173
174 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] 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);
184 PlaceTreesRandomly();
185 MarkWholeScreenDirty();
186 break;
187
188 case WID_BT_MODE_NORMAL:
189 this->mode = PM_NORMAL;
190 this->UpdateMode();
191 break;
192
193 case WID_BT_MODE_FOREST_SM:
194 assert(_game_mode == GM_EDITOR);
195 this->mode = PM_FOREST_SM;
196 this->UpdateMode();
197 break;
198
199 case WID_BT_MODE_FOREST_LG:
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([[maybe_unused]] Point pt, TileIndex tile) override
216 {
217 if (_game_mode != GM_EDITOR && this->mode == PM_NORMAL) {
218 VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_PLANT_TREES);
219 } else {
220 VpStartDragging(DDSP_PLANT_TREES);
221 }
222 }
223
224 void OnPlaceDrag(ViewportPlaceMethod select_method, [[maybe_unused]] ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] 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 Command<CMD_PLANT_TREE>::Post(tile, tile, this->tree_to_plant, false);
233 } else {
234 this->DoPlantForest(tile);
235 }
236 }
237 }
238
239 void OnPlaceMouseUp([[maybe_unused]] ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] 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 Command<CMD_PLANT_TREE>::Post(STR_ERROR_CAN_T_PLANT_TREE_HERE, end_tile, start_tile, this->tree_to_plant, _ctrl_pressed);
243 }
244 }
245
246 void OnPlaceObjectAbort() override
247 {
248 this->tree_to_plant = -1;
249 this->UpdateMode();
250 }
251 };
252
259 static std::unique_ptr<NWidgetBase> MakeTreeTypeButtons()
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
269 auto vstack = std::make_unique<NWidgetVertical>(NC_EQUALSIZE);
270 vstack->SetPIP(0, 1, 0);
271
272 for (int row = 0; row < num_rows; row++) {
273 auto hstack = std::make_unique<NWidgetHorizontal>(NC_EQUALSIZE);
274 hstack->SetPIP(0, 1, 0);
275 for (int col = 0; col < num_columns; col++) {
276 if (cur_type > type_base + type_count) break;
277 auto button = std::make_unique<NWidgetBackground>(WWT_PANEL, COLOUR_GREY, WID_BT_TYPE_BUTTON_FIRST + cur_type);
278 button->SetDataTip(0x0, STR_PLANT_TREE_TOOLTIP);
279 hstack->Add(std::move(button));
280 cur_type++;
281 }
282 vstack->Add(std::move(hstack));
283 }
284
285 return vstack;
286 }
287
288 static constexpr NWidgetPart _nested_build_trees_widgets[] = {
289 NWidget(NWID_HORIZONTAL),
290 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
291 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_PLANT_TREE_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
292 NWidget(WWT_SHADEBOX, COLOUR_DARK_GREEN),
293 NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
294 EndContainer(),
295 NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
296 NWidget(NWID_VERTICAL), SetPadding(2),
297 NWidgetFunction(MakeTreeTypeButtons),
298 NWidget(NWID_SPACER), SetMinimalSize(0, 1),
299 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BT_TYPE_RANDOM), SetDataTip(STR_TREES_RANDOM_TYPE, STR_TREES_RANDOM_TYPE_TOOLTIP),
300 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BT_SE_PANE),
301 NWidget(NWID_VERTICAL),
302 NWidget(NWID_SPACER), SetMinimalSize(0, 1),
303 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
304 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BT_MODE_NORMAL), SetFill(1, 0), SetDataTip(STR_TREES_MODE_NORMAL_BUTTON, STR_TREES_MODE_NORMAL_TOOLTIP),
305 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),
306 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),
307 EndContainer(),
308 NWidget(NWID_SPACER), SetMinimalSize(0, 1),
309 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_BT_MANY_RANDOM), SetDataTip(STR_TREES_RANDOM_TREES_BUTTON, STR_TREES_RANDOM_TREES_TOOLTIP),
310 EndContainer(),
311 EndContainer(),
312 EndContainer(),
313 EndContainer(),
314 };
315
316 static WindowDesc _build_trees_desc(__FILE__, __LINE__,
317 WDP_AUTO, "build_tree", 0, 0,
318 WC_BUILD_TREES, WC_NONE,
319 WDF_CONSTRUCTION,
320 std::begin(_nested_build_trees_widgets), std::end(_nested_build_trees_widgets)
321 );
322
323 void ShowBuildTreesToolbar()
324 {
325 if (_game_mode != GM_EDITOR && !Company::IsValidID(_local_company)) return;
326 AllocateWindowDescFront<BuildTreesWindow>(&_build_trees_desc, 0);
327 }
SetFill
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1143
sound_func.h
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:30
command_func.h
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:68
WDF_CONSTRUCTION
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Definition: window_gui.h:197
GameCreationSettings::landscape
byte landscape
the landscape we're currently in
Definition: settings_type.h:355
company_base.h
ViewportDragDropSelectionProcess
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you've selected it.
Definition: viewport_type.h:107
tree_cmd.h
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:63
MakeTreeTypeButtons
static std::unique_ptr< NWidgetBase > MakeTreeTypeButtons()
Make widgets for the current available tree types.
Definition: tree_gui.cpp:259
WID_BT_MODE_FOREST_LG
@ WID_BT_MODE_FOREST_LG
Select large forest planting mode.
Definition: tree_widget.h:19
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:77
WID_BT_SE_PANE
@ WID_BT_SE_PANE
Selection pane to show/hide scenario editor tools.
Definition: tree_widget.h:16
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1153
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:306
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:37
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:526
WC_BUILD_TREES
@ WC_BUILD_TREES
Build trees toolbar; Window numbers:
Definition: window_type.h:86
CeilDiv
constexpr uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
Definition: math_func.hpp:320
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:54
SZSP_HORIZONTAL
@ SZSP_HORIZONTAL
Display plane with zero size vertically, and filling and resizing horizontally.
Definition: widget_type.h:468
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
NWidgetFunction
constexpr NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr)
Obtain a nested widget (sub)tree from an external source.
Definition: widget_type.h:1281
ViewportPlaceMethod
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
Definition: viewport_type.h:88
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:1040
tree_land.h
WID_BT_TYPE_RANDOM
@ WID_BT_TYPE_RANDOM
Button to build random type of tree.
Definition: tree_widget.h:15
GameSettings::game_creation
GameCreationSettings game_creation
settings used during the creation of a game (map)
Definition: settings_type.h:618
BuildTreesWindow::mode
PlantingMode mode
Current mode for planting.
Definition: tree_gui.cpp:92
gfx_func.h
WindowDesc
High level window description.
Definition: window_gui.h:153
WidgetID
int WidgetID
Widget ID.
Definition: window_type.h:18
ScaleGUITrad
int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
Definition: zoom_func.h:117
window_gui.h
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:510
SetPadding
constexpr NWidgetPart SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left)
Widget part function for setting additional space around a widget.
Definition: widget_type.h:1190
WDP_AUTO
@ WDP_AUTO
Find a place automatically.
Definition: window_gui.h:141
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:308
tilehighlight_func.h
PlaceTreesRandomly
void PlaceTreesRandomly()
Place some trees randomly.
Definition: tree_cmd.cpp:246
ClientSettings::sound
SoundSettings sound
sound effect settings
Definition: settings_type.h:638
WindowNumber
int32_t WindowNumber
Number to differentiate different windows of the same class.
Definition: window_type.h:732
VpStartPlaceSizing
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
highlighting tiles while only going over them with the mouse
Definition: viewport.cpp:2716
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:941
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:110
VpSelectTilesWithMethod
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
Definition: viewport.cpp:3201
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:55
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1260
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:50
safeguards.h
Window::LowerWidget
void LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
Definition: window_gui.h:460
WID_BT_MODE_FOREST_SM
@ WID_BT_MODE_FOREST_SM
Select small forest planting mode.
Definition: tree_widget.h:18
VpStartDragging
void VpStartDragging(ViewportDragDropSelectionProcess process)
Drag over the map while holding the left mouse down.
Definition: viewport.cpp:2750
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:1003
sprites.h
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
CenterBounds
int CenterBounds(int min, int max, int size)
Determine where to draw a centred object inside a widget.
Definition: gfx_func.h:166
stdafx.h
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition: window_gui.h:296
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:45
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:79
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:937
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:71
SoundSettings::confirm
bool confirm
Play sound effect on successful constructions or other actions.
Definition: settings_type.h:240
Window::CreateNestedTree
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1724
strings_func.h
tree_map.h
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:52
GetMaxTreeSpriteSize
static Dimension GetMaxTreeSpriteSize()
Calculate the maximum size of all tree sprites.
Definition: tree_gui.cpp:53
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_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
Window::window_class
WindowClass window_class
Window class.
Definition: window_gui.h:295
Window::FinishInitNested
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition: window.cpp:1734
WID_BT_MODE_NORMAL
@ WID_BT_MODE_NORMAL
Select normal/rectangle planting mode.
Definition: tree_widget.h:17
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:81
company_func.h
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:93
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:300
SetMinimalSize
constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1099
MarkWholeScreenDirty
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition: gfx.cpp:1548
random_func.hpp
WID_BT_MANY_RANDOM
@ WID_BT_MANY_RANDOM
Button to build many random trees.
Definition: tree_widget.h:20
TileVirtXY
static debug_inline TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
Definition: map_func.h:416
Window
Data structure for an opened window.
Definition: window_gui.h:267
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:328
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:3435
BuildTreesWindow::tree_to_plant
int tree_to_plant
Tree number to plant, TREE_INVALID for a random tree.
Definition: tree_gui.cpp:91
SetDataTip
constexpr NWidgetPart SetDataTip(uint32_t data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1164
NWID_SELECTION
@ NWID_SELECTION
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition: widget_type.h:82
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:75
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:3483
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:57
TreeType
TreeType
List of tree types along all landscape types.
Definition: tree_map.h:25
WWT_SHADEBOX
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition: widget_type.h:66