diff --git a/src/lang/english.txt b/src/lang/english.txt index ec801303f8..6d4585e387 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -2819,6 +2819,8 @@ STR_TREES_RANDOM_TYPE :{BLACK}Trees of STR_TREES_RANDOM_TYPE_TOOLTIP :{BLACK}Place trees of random type. Shift toggles building/showing cost estimate STR_TREES_RANDOM_TREES_BUTTON :{BLACK}Random Trees STR_TREES_RANDOM_TREES_TOOLTIP :{BLACK}Plant trees randomly throughout the landscape +STR_TREES_REMOVE_TREES_BUTTON :{BLACK}Remove all Trees +STR_TREES_REMOVE_TREES_TOOLTIP :{BLACK}Remove all Trees over landscape # Land generation window (SE) STR_TERRAFORM_TOOLBAR_LAND_GENERATION_CAPTION :{WHITE}Land Generation diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp index bb57b55fb8..84e4e3c512 100644 --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -356,6 +356,24 @@ void PlaceTreesRandomly() } } +/** + * Remove all trees + * + * This function remove all trees on the map. + */ +void RemoveAllTrees() +{ + for(uint i = 0; i < MapSizeX(); i++) { + for(uint j = 0; j < MapSizeY(); j++) { + TileIndex tile = TileXY(i, j); + if(GetTileType(tile) == MP_TREES) { + DoCommandP(tile, 0, 0, CMD_LANDSCAPE_CLEAR | CMD_MSG(STR_ERROR_CAN_T_CLEAR_THIS_AREA), CcPlaySound10); + } + } + } +} + + /** * Place new trees. * diff --git a/src/tree_gui.cpp b/src/tree_gui.cpp index 0fc12cf781..d13fc5c865 100644 --- a/src/tree_gui.cpp +++ b/src/tree_gui.cpp @@ -28,6 +28,7 @@ #include "safeguards.h" void PlaceTreesRandomly(); +void RemoveAllTrees(); /** * The build trees window. @@ -120,6 +121,13 @@ public: PlaceTreesRandomly(); MarkWholeScreenDirty(); break; + + case WID_BT_REMOVE_ALL: // remove all trees over the landscape + if (_settings_client.sound.confirm) SndPlayFx(SND_15_BEEP); + RemoveAllTrees(); + MarkWholeScreenDirty(); + break; + } } @@ -213,6 +221,8 @@ static const NWidgetPart _nested_build_trees_widgets[] = { NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BT_TYPE_RANDOM), SetMinimalSize(139, 12), SetDataTip(STR_TREES_RANDOM_TYPE, STR_TREES_RANDOM_TYPE_TOOLTIP), NWidget(NWID_SPACER), SetMinimalSize(0, 1), NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_BT_MANY_RANDOM), SetMinimalSize(139, 12), SetDataTip(STR_TREES_RANDOM_TREES_BUTTON, STR_TREES_RANDOM_TREES_TOOLTIP), + NWidget(NWID_SPACER), SetMinimalSize(0, 1), + NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_BT_REMOVE_ALL), SetMinimalSize(139, 12), SetDataTip(STR_TREES_REMOVE_TREES_BUTTON, STR_TREES_REMOVE_TREES_TOOLTIP), NWidget(NWID_SPACER), SetMinimalSize(0, 2), EndContainer(), NWidget(NWID_SPACER), SetMinimalSize(2, 0), diff --git a/src/widgets/tree_widget.h b/src/widgets/tree_widget.h index cd0b85c9d1..e505c23e34 100644 --- a/src/widgets/tree_widget.h +++ b/src/widgets/tree_widget.h @@ -28,6 +28,7 @@ enum BuildTreesWidgets { WID_BT_TYPE_34, ///< Tree 3st column 4th row. WID_BT_TYPE_RANDOM, ///< Button to build random type of tree. WID_BT_MANY_RANDOM, ///< Button to build many random trees. + WID_BT_REMOVE_ALL, ///< Button to remove all trees. }; #endif /* WIDGETS_TREE_WIDGET_H */