OpenTTD Source 20241224-master-gee860a5c8e
|
GUIs for building trees. More...
#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 "tree_cmd.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. | |
uint | PlaceTreeGroupAroundTile (TileIndex tile, TreeType treetype, uint radius, uint count, bool set_zone) |
Place some trees in a radius around a tile. | |
static Dimension | GetMaxTreeSpriteSize () |
Calculate the maximum size of all tree sprites. | |
static std::unique_ptr< NWidgetBase > | MakeTreeTypeButtons () |
Make widgets for the current available tree types. | |
void | ShowBuildTreesToolbar () |
Variables | |
const PalSpriteID | tree_sprites [] |
Tree Sprites with their palettes. | |
static constexpr 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) |
GUIs for building trees.
Definition in file tree_gui.cpp.
|
static |
Calculate the maximum size of all tree sprites.
Definition at line 53 of file tree_gui.cpp.
References _settings_game, GameSettings::game_creation, GetSpriteSize(), GameCreationSettings::landscape, lengthof, ScaleGUITrad(), and tree_sprites.
Referenced by BuildTreesWindow::UpdateWidgetSize().
|
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.
Definition at line 259 of file tree_gui.cpp.
References _settings_game, CeilDiv(), GameSettings::game_creation, GameCreationSettings::landscape, NC_EQUALSIZE, WID_BT_TYPE_BUTTON_FIRST, and WWT_PANEL.
uint PlaceTreeGroupAroundTile | ( | TileIndex | tile, |
TreeType | treetype, | ||
uint | radius, | ||
uint | count, | ||
bool | set_zone | ||
) |
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.
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. |
set_zone | Whether to create a rainforest zone when placing rainforest trees. |
Definition at line 307 of file tree_cmd.cpp.
References AddTreeCount(), CanPlantTreesOnTile(), DistanceSquare(), OrthogonalTileArea::Expand(), GetTileType(), GetTreeCount(), Growing1, Grown, INVALID_TILE, IsInsideMM(), IsTileType(), MarkTileDirtyByTile(), MP_TREES, MP_VOID, PlantTreesOnTile(), SetTreeGrowth(), SetTropicZone(), TileAddWrap(), TREE_CACTUS, TREE_COUNT_TOYLAND, TREE_RAINFOREST, TREE_TOYLAND, and TROPICZONE_RAINFOREST.
void PlaceTreesRandomly | ( | ) |
Place some trees randomly.
This function just place some trees randomly on the map.
Definition at line 247 of file tree_cmd.cpp.
References _settings_game, CanPlantTreesOnTile(), DEFAULT_RAINFOREST_TREE_STEPS, DEFAULT_TREE_STEPS, EDITOR_TREE_DIV, GameSettings::game_creation, GetSnowLine(), GetTileZ(), GetTropicZone(), GWP_TREE, IncreaseGeneratingWorldProgress(), GameCreationSettings::landscape, PlaceTree(), PlaceTreeAtSameHeight(), RandomTileSeed(), Map::ScaleBySize(), TP_IMPROVED, GameCreationSettings::tree_placer, and TROPICZONE_RAINFOREST.
Referenced by GenerateTrees(), and BuildTreesWindow::OnClick().
void ShowBuildTreesToolbar | ( | ) |
Definition at line 320 of file tree_gui.cpp.
|
staticconstexpr |
Definition at line 288 of file tree_gui.cpp.
const PalSpriteID tree_sprites[] |
Tree Sprites with their palettes.
Definition at line 36 of file tree_gui.cpp.
Referenced by BuildTreesWindow::DrawWidget(), and GetMaxTreeSpriteSize().