src/terraform_gui.cpp
branchNewGRF_ports
changeset 6719 4cc327ad39d5
parent 6432 8fb778a7f2d7
child 6743 cabfaa4a0295
--- a/src/terraform_gui.cpp	Tue Mar 27 23:27:27 2007 +0000
+++ b/src/terraform_gui.cpp	Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
 /* $Id$ */
 
+/** @file terraform_gui.cpp */
+
 #include "stdafx.h"
 #include "openttd.h"
 #include "bridge_map.h"
@@ -91,34 +93,35 @@
 
 /**
  * A central place to handle all X_AND_Y dragged GUI functions.
- * @param e @WindowEvent variable holding in its higher bits (excluding the lower
+ * @param e WindowEvent variable holding in its higher bits (excluding the lower
  * 4, since that defined the X_Y drag) the type of action to be performed
  * @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 in rail_gui.c and not terraform_gui.c
+ * of convertrail which belongs in rail_gui.cpp and not terraform_gui.cpp
  **/
 bool GUIPlaceProcDragXY(const WindowEvent *e)
 {
 	TileIndex start_tile = e->we.place.starttile;
 	TileIndex end_tile = e->we.place.tile;
 
-	switch (e->we.place.userdata >> 4) {
-	case GUI_PlaceProc_DemolishArea >> 4:
-		DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
-		break;
-	case GUI_PlaceProc_LevelArea >> 4:
-		DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_LEVEL_LAND | CMD_AUTO);
-		break;
-	case GUI_PlaceProc_RockyArea >> 4:
-		GenerateRockyArea(end_tile, start_tile);
-		break;
-	case GUI_PlaceProc_DesertArea >> 4:
-		GenerateDesertArea(end_tile, start_tile);
-		break;
-	case GUI_PlaceProc_WaterArea >> 4:
-		DoCommandP(end_tile, start_tile, _ctrl_pressed, CcBuildCanal, CMD_BUILD_CANAL | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_CANALS));
-		break;
-	default: return false;
+	switch (e->we.place.select_proc) {
+		case DDSP_DEMOLISH_AREA:
+			DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
+			break;
+		case DDSP_LEVEL_AREA:
+			DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_LEVEL_LAND | CMD_AUTO);
+			break;
+		case DDSP_CREATE_ROCKS:
+			GenerateRockyArea(end_tile, start_tile);
+			break;
+		case DDSP_CREATE_DESERT:
+			GenerateDesertArea(end_tile, start_tile);
+			break;
+		case DDSP_CREATE_WATER:
+			DoCommandP(end_tile, start_tile, _ctrl_pressed, CcBuildCanal, CMD_BUILD_CANAL | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_CANALS));
+			break;
+		default:
+			return false;
 	}
 
 	return true;
@@ -138,7 +141,7 @@
 
 void PlaceProc_DemolishArea(TileIndex tile)
 {
-	VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_DemolishArea);
+	VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_DEMOLISH_AREA);
 }
 
 static void PlaceProc_RaiseLand(TileIndex tile)
@@ -159,7 +162,7 @@
 
 void PlaceProc_LevelLand(TileIndex tile)
 {
-	VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_LevelArea);
+	VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_LEVEL_AREA);
 }
 
 static void TerraformClick_Lower(Window *w)
@@ -237,13 +240,17 @@
 		return;
 
 	case WE_PLACE_DRAG:
-		VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.userdata & 0xF);
+		VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
 		break;
 
 	case WE_PLACE_MOUSEUP:
-		if (e->we.place.pt.x != -1 &&
-				(e->we.place.userdata & 0xF) == VPM_X_AND_Y) { // dragged actions
-			GUIPlaceProcDragXY(e);
+		if (e->we.place.pt.x != -1) {
+			switch (e->we.place.select_proc) {
+				case DDSP_DEMOLISH_AREA:
+				case DDSP_LEVEL_AREA:
+					GUIPlaceProcDragXY(e);
+					break;
+			}
 		}
 		break;
 
@@ -265,13 +272,13 @@
 {   WWT_IMGBTN,   RESIZE_NONE,     7,  70,  91,  14,  35, SPR_IMG_DYNAMITE,        STR_018D_DEMOLISH_BUILDINGS_ETC},
 {   WWT_IMGBTN,   RESIZE_NONE,     7,  92, 113,  14,  35, SPR_IMG_BUY_LAND,        STR_0329_PURCHASE_LAND_FOR_FUTURE},
 {   WWT_IMGBTN,   RESIZE_NONE,     7, 114, 135,  14,  35, SPR_IMG_PLANTTREES,      STR_0185_PLANT_TREES_PLACE_SIGNS},
-{   WWT_IMGBTN,   RESIZE_NONE,     7, 136, 157,  14,  35, SPR_IMG_PLACE_SIGN,      STR_0289_PLACE_SIGN},
+{   WWT_IMGBTN,   RESIZE_NONE,     7, 136, 157,  14,  35, SPR_IMG_SIGN,            STR_0289_PLACE_SIGN},
 
 {   WIDGETS_END},
 };
 
 static const WindowDesc _terraform_desc = {
-	WDP_ALIGN_TBR, 22+36, 158, 36,
+	WDP_ALIGN_TBR, 22 + 36, 158, 36,
 	WC_SCEN_LAND_GEN, WC_NONE,
 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
 	_terraform_widgets,