From f7eb0ffc37870c461379d7d8cffdef2c8733fef9 Mon Sep 17 00:00:00 2001 From: Tyler Trahan Date: Mon, 12 Sep 2022 10:45:02 -0600 Subject: [PATCH] Feature: Purchase land multiple tiles at a time --- src/company_base.h | 2 +- src/lang/english.txt | 2 +- src/settings_type.h | 4 ++-- src/terraform_gui.cpp | 14 ++++++++++++-- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/company_base.h b/src/company_base.h index 741d97be8d..bb88e94fd6 100644 --- a/src/company_base.h +++ b/src/company_base.h @@ -87,7 +87,7 @@ struct CompanyProperties { uint32 terraform_limit; ///< Amount of tileheights we can (still) terraform (times 65536). uint32 clear_limit; ///< Amount of tiles we can (still) clear (times 65536). uint32 tree_limit; ///< Amount of trees we can (still) plant (times 65536). - uint32 build_object_limit; ///< Amount of tiles we can (still) build objects on (times 65536). + uint32 build_object_limit; ///< Amount of tiles we can (still) build objects on (times 65536). Also applies to buying land. /** * If \c true, the company is (also) controlled by the computer (a NoAI program). diff --git a/src/lang/english.txt b/src/lang/english.txt index e0ee6b9464..4064c75143 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -2812,7 +2812,7 @@ STR_LANDSCAPING_TOOLBAR :{WHITE}Landscap STR_LANDSCAPING_TOOLTIP_LOWER_A_CORNER_OF_LAND :{BLACK}Lower a corner of land. Dragging lowers the first selected corner and levels the selected area to the new corner height. Ctrl selects the area diagonally. Shift toggles building/showing cost estimate STR_LANDSCAPING_TOOLTIP_RAISE_A_CORNER_OF_LAND :{BLACK}Raise a corner of land. Dragging raises the first selected corner and levels the selected area to the new corner height. Ctrl selects the area diagonally. Shift toggles building/showing cost estimate STR_LANDSCAPING_LEVEL_LAND_TOOLTIP :{BLACK}Level an area of land to the height of the first selected corner. Ctrl selects the area diagonally. Shift toggles building/showing cost estimate -STR_LANDSCAPING_TOOLTIP_PURCHASE_LAND :{BLACK}Purchase land for future use. Shift toggles building/showing cost estimate +STR_LANDSCAPING_TOOLTIP_PURCHASE_LAND :{BLACK}Purchase land for future use. Ctrl selects the area diagonally. Shift toggles building/showing cost estimate # Object construction window STR_OBJECT_BUILD_CAPTION :{WHITE}Object Selection diff --git a/src/settings_type.h b/src/settings_type.h index a501ca5452..2c3dea7b92 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -355,8 +355,8 @@ struct ConstructionSettings { uint16 clear_frame_burst; ///< how many tiles may, over a short period, be cleared? uint32 tree_per_64k_frames; ///< how many trees may, over a long period, be planted per 65536 frames? uint16 tree_frame_burst; ///< how many trees may, over a short period, be planted? - uint32 build_object_per_64k_frames; ///< how many tiles may, over a long period, have objects built on them per 65536 frames? - uint16 build_object_frame_burst; ///< how many tiles may, over a short period, have objects built on them? + uint32 build_object_per_64k_frames; ///< how many tiles may, over a long period, be purchased or have objects built on them per 65536 frames? + uint16 build_object_frame_burst; ///< how many tiles may, over a short period, be purchased or have objects built on them? }; /** Settings related to the AI. */ diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index 260234efc8..c76ab8ce8d 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -201,7 +201,7 @@ struct TerraformToolbarWindow : Window { break; case WID_TT_BUY_LAND: // Buy land button - HandlePlacePushButton(this, WID_TT_BUY_LAND, SPR_CURSOR_BUY_LAND, HT_RECT); + HandlePlacePushButton(this, WID_TT_BUY_LAND, SPR_CURSOR_BUY_LAND, HT_RECT | HT_DIAGONAL); this->last_user_action = widget; break; @@ -242,7 +242,7 @@ struct TerraformToolbarWindow : Window { break; case WID_TT_BUY_LAND: // Buy land button - Command::Post(STR_ERROR_CAN_T_PURCHASE_THIS_LAND, CcPlaySound_CONSTRUCTION_RAIL, tile, OBJECT_OWNED_LAND, 0); + VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_BUILD_OBJECT); break; case WID_TT_PLACE_SIGN: // Place sign button @@ -276,6 +276,16 @@ struct TerraformToolbarWindow : Window { case DDSP_LEVEL_AREA: GUIPlaceProcDragXY(select_proc, start_tile, end_tile); break; + case DDSP_BUILD_OBJECT: + if (!_settings_game.construction.freeform_edges) { + /* When end_tile is MP_VOID, the error tile will not be visible to the + * user. This happens when terraforming at the southern border. */ + if (TileX(end_tile) == MapMaxX()) end_tile += TileDiffXY(-1, 0); + if (TileY(end_tile) == MapMaxY()) end_tile += TileDiffXY(0, -1); + } + Command::Post(STR_ERROR_CAN_T_PURCHASE_THIS_LAND, CcPlaySound_CONSTRUCTION_RAIL, + end_tile, start_tile, OBJECT_OWNED_LAND, 0, (_ctrl_pressed ? true : false)); + break; } } }