OpenTTD Source: src/tree_gui.cpp File Reference

OpenTTD Source 1.11.0-RC1

Data Structures | Functions | Variables
tree_gui.cpp File Reference
`#include "stdafx.h"`
`#include "window_gui.h"`
`#include "gfx_func.h"`
`#include "tilehighlight_func.h"`
`#include "company_func.h"`
`#include "company_base.h"`
`#include "command_func.h"`
`#include "core/random_func.hpp"`
`#include "sound_func.h"`
`#include "strings_func.h"`
`#include "zoom_func.h"`
`#include "tree_map.h"`
`#include "widgets/tree_widget.h"`
`#include "table/sprites.h"`
`#include "table/strings.h"`
`#include "table/tree_land.h"`
`#include "safeguards.h"`

Go to the source code of this file.

## Data Structures
class | BuildTreesWindow
| The build trees window. More...

## Functions
void | PlaceTreesRandomly ()
| Place some trees randomly. More...
uint | PlaceTreeGroupAroundTile (TileIndex tile, TreeType treetype, uint radius, uint count)
| Place some trees in a radius around a tile. More...
static Dimension | GetMaxTreeSpriteSize ()
| Calculate the maximum size of all tree sprites. More...
static NWidgetBase * | MakeTreeTypeButtons (int *biggest_index)
| Make widgets for the current available tree types. More...
void | ShowBuildTreesToolbar ()

## Variables
const PalSpriteID | tree_sprites []
| Tree Sprites with their palettes. More...
static const NWidgetPart | _nested_build_trees_widgets []
static WindowDesc | _build_trees_desc (WDP_AUTO, "build_tree", 0, 0, WC_BUILD_TREES, WC_NONE, WDF_CONSTRUCTION, _nested_build_trees_widgets, lengthof(_nested_build_trees_widgets))

## Detailed Description

GUIs for building trees.

Definition in file tree_gui.cpp.

## Function Documentation

## ◆ GetMaxTreeSpriteSize()

static Dimension GetMaxTreeSpriteSize | ( |  | ) |
| static

Calculate the maximum size of all tree sprites.

Returns
  Dimension of the largest tree sprite

Definition at line 52 of file tree_gui.cpp.

Referenced by BuildTreesWindow::UpdateWidgetSize().

## ◆ MakeTreeTypeButtons()

static NWidgetBase* MakeTreeTypeButtons | ( | int * | biggest_index | ) |
| static

Make widgets for the current available tree types.

This does not use a NWID_MATRIX or WWT_MATRIX control as those are more difficult to get producing the correct result than dynamically building the widgets is.

See also
  NWidgetFunctionType

Definition at line 259 of file tree_gui.cpp.

## ◆ PlaceTreeGroupAroundTile()

uint PlaceTreeGroupAroundTile | ( | TileIndex | tile,
|  | TreeType | treetype,
|  | uint | radius,
|  | uint | count
| ) |  |

Place some trees in a radius around a tile.

The trees are placed in an quasi-normal distribution around the indicated tile, meaning that while the radius does define a square, the distribution inside the square will be roughly circular.

Note
  This function the interactive RNG and must only be used in editor and map generation.

Parameters

  tile | Tile to place trees around.
  treetype | Type of trees to place. Must be a valid tree type for the climate.
  radius | Maximum distance (on each axis) from tile to place trees.
  count | Maximum number of trees to place.

Returns
  Number of trees actually placed.

Definition at line 305 of file tree_cmd.cpp.

References TREE_CACTUS, TREE_COUNT_TOYLAND, and TREE_TOYLAND.

## ◆ PlaceTreesRandomly()

void PlaceTreesRandomly | ( |  | ) |

Place some trees randomly.

This function just place some trees randomly on the map.

Definition at line 246 of file tree_cmd.cpp.

References DEFAULT_TREE_STEPS, and ScaleByMapSize().

## Variable Documentation

## ◆ _nested_build_trees_widgets

const NWidgetPart _nested_build_trees_widgets[]
| static

Initial value:
= {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_PLANT_TREE_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_SHADEBOX, COLOUR_DARK_GREEN),
NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
NWidget(NWID_VERTICAL), SetPadding(2),
NWidgetFunction(MakeTreeTypeButtons),
NWidget(NWID_SPACER), SetMinimalSize(0, 1),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BT_TYPE_RANDOM), SetDataTip(STR_TREES_RANDOM_TYPE, STR_TREES_RANDOM_TYPE_TOOLTIP),
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BT_SE_PANE),
NWidget(NWID_VERTICAL),
NWidget(NWID_SPACER), SetMinimalSize(0, 1),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BT_MODE_NORMAL), SetFill(1, 0), SetDataTip(STR_TREES_MODE_NORMAL_BUTTON, STR_TREES_MODE_NORMAL_TOOLTIP),
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),
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),
EndContainer(),
NWidget(NWID_SPACER), SetMinimalSize(0, 1),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_BT_MANY_RANDOM), SetDataTip(STR_TREES_RANDOM_TREES_BUTTON, STR_TREES_RANDOM_TREES_TOOLTIP),
EndContainer(),
EndContainer(),
EndContainer(),
EndContainer(),
}

Definition at line 289 of file tree_gui.cpp.

## ◆ tree_sprites

const PalSpriteID tree_sprites[]

Initial value:
= {
{ 1621, PAL_NONE }, { 1635, PAL_NONE }, { 1656, PAL_NONE }, { 1579, PAL_NONE },
{ 1607, PAL_NONE }, { 1593, PAL_NONE }, { 1614, PAL_NONE }, { 1586, PAL_NONE },
{ 1663, PAL_NONE }, { 1677, PAL_NONE }, { 1691, PAL_NONE }, { 1705, PAL_NONE },
{ 1711, PAL_NONE }, { 1746, PAL_NONE }, { 1753, PAL_NONE }, { 1732, PAL_NONE },
{ 1739, PAL_NONE }, { 1718, PAL_NONE }, { 1725, PAL_NONE }, { 1760, PAL_NONE },
{ 1838, PAL_NONE }, { 1844, PAL_NONE }, { 1866, PAL_NONE }, { 1871, PAL_NONE },
{ 1899, PAL_NONE }, { 1935, PAL_NONE }, { 1928, PAL_NONE }, { 1915, PAL_NONE },
{ 1887, PAL_NONE }, { 1908, PAL_NONE }, { 1824, PAL_NONE }, { 1943, PAL_NONE },
{ 1950, PAL_NONE }, { 1957, PALETTE_TO_GREEN }, { 1964, PALETTE_TO_RED }, { 1971, PAL_NONE },
{ 1978, PAL_NONE }, { 1985, PALETTE_TO_RED, }, { 1992, PALETTE_TO_PALE_GREEN }, { 1999, PALETTE_TO_YELLOW }, { 2006, PALETTE_TO_RED }
}

Tree Sprites with their palettes.

Definition at line 35 of file tree_gui.cpp.

Referenced by BuildTreesWindow::DrawWidget().

NWidgetFunction
static NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr)
Obtain a nested widget (sub)tree from an external source.
Definition: widget_type.h:1145
WID_BT_SE_PANE
@ WID_BT_SE_PANE
Selection pane to show/hide scenario editor tools.
Definition: tree_widget.h:16
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:1045
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
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1013
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:428
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:102
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:75
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
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:998
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1113
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:946
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:48
NWID_SPACER
@ NWID_SPACER
Invisible widget that takes some space.
Definition: widget_type.h:77
WID_BT_MODE_FOREST_LG
@ WID_BT_MODE_FOREST_LG
Select large forest planting mode.
Definition: tree_widget.h:19
WID_BT_MODE_FOREST_SM
@ WID_BT_MODE_FOREST_SM
Select small forest planting mode.
Definition: tree_widget.h:18
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:982
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
MakeTreeTypeButtons
static NWidgetBase * MakeTreeTypeButtons(int *biggest_index)
Make widgets for the current available tree types.
Definition: tree_gui.cpp:259
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:53
WWT_SHADEBOX
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition: widget_type.h:62