|
OpenTTD Source
14.0-beta1
|
Go to the documentation of this file.
27 #include "table/strings.h"
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 }
66 for (
int i = base; i < base + count; i++) {
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));
103 if (this->tree_to_plant >= 0) {
107 this->tree_to_plant = current_tree;
115 }
else if (this->tree_to_plant >= 0) {
119 switch (this->mode) {
123 default: NOT_REACHED();
135 const uint radius = this->mode == PM_FOREST_LG ? 12 : 5;
136 const uint count = this->mode == PM_FOREST_LG ? 12 : 5;
149 if (_game_mode != GM_EDITOR) {
160 size->width = d.width + padding.width;
165 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
174 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
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;
215 void OnPlaceObject([[maybe_unused]]
Point pt,
TileIndex tile)
override
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;
269 auto vstack = std::make_unique<NWidgetVertical>(
NC_EQUALSIZE);
270 vstack->SetPIP(0, 1, 0);
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;
278 button->SetDataTip(0x0, STR_PLANT_TREE_TOOLTIP);
279 hstack->Add(std::move(button));
282 vstack->Add(std::move(hstack));
288 static constexpr
NWidgetPart _nested_build_trees_widgets[] = {
316 static WindowDesc _build_trees_desc(__FILE__, __LINE__,
320 std::begin(_nested_build_trees_widgets), std::end(_nested_build_trees_widgets)
323 void ShowBuildTreesToolbar()
326 AllocateWindowDescFront<BuildTreesWindow>(&_build_trees_desc, 0);
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
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you've selected it.
static std::unique_ptr< NWidgetBase > MakeTreeTypeButtons()
Make widgets for the current available tree types.
static const int BUTTON_BOTTOM_OFFSET
Visual Y offset of tree root from the bottom of the tree type buttons.
uint PlaceTreeGroupAroundTile(TileIndex tile, TreeType treetype, uint radius, uint count, bool set_zone)
Place some trees in a radius around a tile.
bool _ctrl_pressed
Is Ctrl pressed?
@ 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:
constexpr uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
ClientSettings _settings_client
The current settings for this game.
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
GameCreationSettings game_creation
settings used during the creation of a game (map)
PlantingMode mode
Current mode for planting.
High level window description.
int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
@ WDP_AUTO
Find a place automatically.
ResizeInfo resize
Resize information.
void PlaceTreesRandomly()
Place some trees randomly.
SoundSettings sound
sound effect settings
int32_t WindowNumber
Number to differentiate different windows of the same class.
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)
@ HT_DIAGONAL
Also allow 'diagonal rectangles'. Only usable in combination with HT_RECT or HT_POINT.
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 LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
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.
int CenterBounds(int min, int max, int size)
Determine where to draw a centred object inside a widget.
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.
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
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
WindowClass window_class
Window class.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
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.
static debug_inline TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
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 ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
TreeType
List of tree types along all landscape types.