(svn r11759) -Feature: Add drag-n-drop support to the raise/lower land tools. Land is raised/lowered at the start and the rest of the area levelled to match. Patch by Roujin.

This commit is contained in:
peter1138 2008-01-04 18:18:46 +00:00
parent 6a13067931
commit 9299f76af4
4 changed files with 23 additions and 11 deletions

View File

@ -355,7 +355,7 @@ CommandCost CmdTerraformLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
* @param tile end tile of area-drag * @param tile end tile of area-drag
* @param flags for this command type * @param flags for this command type
* @param p1 start tile of area drag * @param p1 start tile of area drag
* @param p2 unused * @param p2 height difference; eg raise (+1), lower (-1) or level (0)
* @return error or cost of terraforming * @return error or cost of terraforming
*/ */
CommandCost CmdLevelLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdLevelLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
@ -364,7 +364,7 @@ CommandCost CmdLevelLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
int ex; int ex;
int ey; int ey;
int sx, sy; int sx, sy;
uint h, curh; uint h, oldh, curh;
CommandCost money; CommandCost money;
CommandCost ret; CommandCost ret;
CommandCost cost; CommandCost cost;
@ -374,7 +374,13 @@ CommandCost CmdLevelLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
/* remember level height */ /* remember level height */
h = TileHeight(p1); oldh = TileHeight(p1);
/* compute new height */
h = oldh + p2;
/* Check range of destination height */
if (h > MAX_TILE_HEIGHT) return_cmd_error((oldh == 0) ? STR_1003_ALREADY_AT_SEA_LEVEL : STR_1004_TOO_HIGH);
/* make sure sx,sy are smaller than ex,ey */ /* make sure sx,sy are smaller than ex,ey */
ex = TileX(tile); ex = TileX(tile);

View File

@ -64,6 +64,8 @@ VARDEF PlaceProc *_place_proc;
* you've selected it. */ * you've selected it. */
enum { enum {
DDSP_DEMOLISH_AREA, DDSP_DEMOLISH_AREA,
DDSP_RAISE_AND_LEVEL_AREA,
DDSP_LOWER_AND_LEVEL_AREA,
DDSP_LEVEL_AREA, DDSP_LEVEL_AREA,
DDSP_CREATE_DESERT, DDSP_CREATE_DESERT,
DDSP_CREATE_ROCKS, DDSP_CREATE_ROCKS,

View File

@ -1382,6 +1382,8 @@ static void ScenEditLandGenWndProc(Window *w, WindowEvent *e)
case DDSP_CREATE_ROCKS: case DDSP_CREATE_ROCKS:
case DDSP_CREATE_DESERT: case DDSP_CREATE_DESERT:
case DDSP_CREATE_WATER: case DDSP_CREATE_WATER:
case DDSP_RAISE_AND_LEVEL_AREA:
case DDSP_LOWER_AND_LEVEL_AREA:
case DDSP_LEVEL_AREA: case DDSP_LEVEL_AREA:
case DDSP_DEMOLISH_AREA: case DDSP_DEMOLISH_AREA:
GUIPlaceProcDragXY(e); GUIPlaceProcDragXY(e);

View File

@ -105,6 +105,12 @@ bool GUIPlaceProcDragXY(const WindowEvent *e)
case DDSP_DEMOLISH_AREA: case DDSP_DEMOLISH_AREA:
DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA)); DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
break; break;
case DDSP_RAISE_AND_LEVEL_AREA:
DoCommandP(end_tile, start_tile, 1, CcTerraform, CMD_LEVEL_LAND| CMD_MSG(STR_0808_CAN_T_RAISE_LAND_HERE));
break;
case DDSP_LOWER_AND_LEVEL_AREA:
DoCommandP(end_tile, start_tile, -1, CcTerraform, CMD_LEVEL_LAND | CMD_MSG(STR_0809_CAN_T_LOWER_LAND_HERE));
break;
case DDSP_LEVEL_AREA: case DDSP_LEVEL_AREA:
DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_LEVEL_LAND); DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_LEVEL_LAND);
break; break;
@ -143,18 +149,12 @@ void PlaceProc_DemolishArea(TileIndex tile)
static void PlaceProc_RaiseLand(TileIndex tile) static void PlaceProc_RaiseLand(TileIndex tile)
{ {
DoCommandP( VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_RAISE_AND_LEVEL_AREA);
tile, SLOPE_N, 1, CcTerraform,
CMD_TERRAFORM_LAND | CMD_MSG(STR_0808_CAN_T_RAISE_LAND_HERE)
);
} }
static void PlaceProc_LowerLand(TileIndex tile) static void PlaceProc_LowerLand(TileIndex tile)
{ {
DoCommandP( VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_LOWER_AND_LEVEL_AREA);
tile, SLOPE_N, 0, CcTerraform,
CMD_TERRAFORM_LAND | CMD_MSG(STR_0809_CAN_T_LOWER_LAND_HERE)
);
} }
void PlaceProc_LevelLand(TileIndex tile) void PlaceProc_LevelLand(TileIndex tile)
@ -244,6 +244,8 @@ static void TerraformToolbWndProc(Window *w, WindowEvent *e)
if (e->we.place.pt.x != -1) { if (e->we.place.pt.x != -1) {
switch (e->we.place.select_proc) { switch (e->we.place.select_proc) {
case DDSP_DEMOLISH_AREA: case DDSP_DEMOLISH_AREA:
case DDSP_RAISE_AND_LEVEL_AREA:
case DDSP_LOWER_AND_LEVEL_AREA:
case DDSP_LEVEL_AREA: case DDSP_LEVEL_AREA:
GUIPlaceProcDragXY(e); GUIPlaceProcDragXY(e);
break; break;