* A central place to handle all X_AND_Y dragged GUI functions. * @param proc Procedure related to the dragging * @param start_tile Begin of the dragging * @param end_tile End of the dragging * @return Returns true if the action was found and handled, and false otherwise. This * allows for additional implements that are more local. For example X_Y drag * of convertrail which belongs i
| 110 | * of convertrail which belongs in rail_gui.cpp and not terraform_gui.cpp |
| 111 | */ |
| 112 | bool GUIPlaceProcDragXY(ViewportDragDropSelectionProcess proc, TileIndex start_tile, TileIndex end_tile) |
| 113 | { |
| 114 | if (!_settings_game.construction.freeform_edges) { |
| 115 | /* When end_tile is MP_VOID, the error tile will not be visible to the |
| 116 | * user. This happens when terraforming at the southern border. */ |
| 117 | if (TileX(end_tile) == Map::MaxX()) end_tile += TileDiffXY(-1, 0); |
| 118 | if (TileY(end_tile) == Map::MaxY()) end_tile += TileDiffXY(0, -1); |
| 119 | } |
| 120 | |
| 121 | switch (proc) { |
| 122 | case DDSP_DEMOLISH_AREA: |
| 123 | Command<CMD_CLEAR_AREA>::Post(STR_ERROR_CAN_T_CLEAR_THIS_AREA, CcPlaySound_EXPLOSION, end_tile, start_tile, _ctrl_pressed); |
| 124 | break; |
| 125 | case DDSP_RAISE_AND_LEVEL_AREA: |
| 126 | Command<CMD_LEVEL_LAND>::Post(STR_ERROR_CAN_T_RAISE_LAND_HERE, CcTerraform, end_tile, start_tile, _ctrl_pressed, LM_RAISE); |
| 127 | break; |
| 128 | case DDSP_LOWER_AND_LEVEL_AREA: |
| 129 | Command<CMD_LEVEL_LAND>::Post(STR_ERROR_CAN_T_LOWER_LAND_HERE, CcTerraform, end_tile, start_tile, _ctrl_pressed, LM_LOWER); |
| 130 | break; |
| 131 | case DDSP_LEVEL_AREA: |
| 132 | Command<CMD_LEVEL_LAND>::Post(STR_ERROR_CAN_T_LEVEL_LAND_HERE, CcTerraform, end_tile, start_tile, _ctrl_pressed, LM_LEVEL); |
| 133 | break; |
| 134 | case DDSP_CREATE_ROCKS: |
| 135 | GenerateRockyArea(end_tile, start_tile); |
| 136 | break; |
| 137 | case DDSP_CREATE_DESERT: |
| 138 | GenerateDesertArea(end_tile, start_tile); |
| 139 | break; |
| 140 | default: |
| 141 | return false; |
| 142 | } |
| 143 | |
| 144 | return true; |
| 145 | } |
| 146 | |
| 147 | /** |
| 148 | * Start a drag for demolishing an area. |
no test coverage detected