OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
26 #include "table/strings.h"
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 }
65 for (
int i = base; i < base + count; i++) {
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));
102 if (this->tree_to_plant >= 0) {
106 this->tree_to_plant = current_tree;
114 }
else if (this->tree_to_plant >= 0) {
118 switch (this->mode) {
122 default: NOT_REACHED();
134 const uint radius = this->mode == PM_FOREST_LG ? 12 : 5;
135 const uint count = this->mode == PM_FOREST_LG ? 12 : 5;
149 if (_game_mode != GM_EDITOR) {
189 this->mode = PM_NORMAL;
194 assert(_game_mode == GM_EDITOR);
195 this->mode = PM_FOREST_SM;
200 assert(_game_mode == GM_EDITOR);
201 this->mode = PM_FOREST_LG;
208 this->tree_to_plant = this->tree_to_plant == index ? -1 : index;
217 if (_game_mode != GM_EDITOR && this->mode == PM_NORMAL) {
226 if (_game_mode != GM_EDITOR && this->mode == PM_NORMAL) {
231 if (this->mode == PM_NORMAL) {
234 this->DoPlantForest(tile);
241 if (_game_mode != GM_EDITOR && this->mode == PM_NORMAL && pt.x != -1 && select_proc ==
DDSP_PLANT_TREES) {
248 this->tree_to_plant = -1;
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;
272 for (
int row = 0; row < num_rows; row++) {
276 for (
int col = 0; col < num_columns; col++) {
277 if (cur_type > type_base + type_count)
break;
279 button->
SetDataTip(0x0, STR_PLANT_TREE_TOOLTIP);
289 static const NWidgetPart _nested_build_trees_widgets[] = {
321 _nested_build_trees_widgets,
lengthof(_nested_build_trees_widgets)
324 void ShowBuildTreesToolbar()
327 AllocateWindowDescFront<BuildTreesWindow>(&_build_trees_desc, 0);
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
#define CMD_MSG(x)
Used to combine a StringID with the command.
uint32 TileIndex
The index/ID of a Tile.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Dimensions (a width and height) of a rectangle in 2D.
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
byte landscape
the landscape we're currently in
void ReInit(int rx=0, int ry=0)
Re-initialize a window, and optionally change its size.
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you've selected it.
static const int BUTTON_BOTTOM_OFFSET
Visual Y offset of tree root from the bottom of the tree type buttons.
@ SND_15_BEEP
19 == 0x13 GUI button click
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
@ WC_BUILD_TREES
Build trees toolbar; Window numbers:
ClientSettings _settings_client
The current settings for this game.
int32 WindowNumber
Number to differentiate different windows of the same class.
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
void OnPlaceObject(Point pt, TileIndex tile) override
The user clicked some place on the map when a tile highlight mode has been set.
GameCreationSettings game_creation
settings used during the creation of a game (map)
PlantingMode mode
Current mode for planting.
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.
High level window description.
@ WDP_AUTO
Find a place automatically.
ResizeInfo resize
Resize information.
void PlaceTreesRandomly()
Place some trees randomly.
SoundSettings sound
sound effect settings
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
highlighting tiles while only going over them with the mouse
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
@ WD_FRAMERECT_LEFT
Offset at left to draw the frame rectangular area.
@ WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
@ WD_FRAMERECT_BOTTOM
Offset at bottom to draw the frame rectangular area.
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
@ TREE_INVALID
An invalid tree.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
void VpStartDragging(ViewportDragDropSelectionProcess process)
Drag over the map while holding the left mouse down.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Coordinates of a point in 2D.
uint PlaceTreeGroupAroundTile(TileIndex tile, TreeType treetype, uint radius, uint count)
Place some trees in a radius around a tile.
WindowNumber window_number
Window number within the window class.
const PalSpriteID tree_sprites[]
Tree Sprites with their palettes.
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
bool confirm
Play sound effect on successful constructions or other actions.
static int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
static Dimension GetMaxTreeSpriteSize()
Calculate the maximum size of all tree sprites.
@ HT_RECT
rectangle (stations, depots, ...)
@ VPM_X_AND_Y
area of land in X and Y directions
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.
WindowClass window_class
Window class.
Combination of a palette sprite and a 'real' sprite.
void UpdateMode()
Update the GUI and enable/disable planting to reflect selected options.
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
#define lengthof(x)
Return the length of an fixed size array.
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
@ CMD_PLANT_TREE
plant a tree
static uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
Data structure for an opened window.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
@ DDSP_PLANT_TREES
Plant trees.
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...
int tree_to_plant
Tree number to plant, TREE_INVALID for a random tree.
Specification of a rectangle with absolute coordinates of all edges.
void LowerWidget(byte widget_index)
Marks a widget as lowered.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
static NWidgetBase * MakeTreeTypeButtons(int *biggest_index)
Make widgets for the current available tree types.
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.
TreeType
List of tree types along all landscape types.
static TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.