changeset 9293:d14fbfc20940 draft

(svn r13160) -Codechange: prepare GUIPlaceProcDragXY for the removal of WindowEvent.
author rubidium <rubidium@openttd.org>
date Sun, 18 May 2008 12:40:38 +0000
parents da3ff971bec7
children 47b54e10e0b2
files src/airport_gui.cpp src/dock_gui.cpp src/rail_gui.cpp src/road_gui.cpp src/terraform_gui.cpp src/tilehighlight_func.h src/window.cpp src/window_gui.h src/window_type.h
diffstat 9 files changed, 19 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/src/airport_gui.cpp
+++ b/src/airport_gui.cpp
@@ -95,7 +95,7 @@
 
 		case WE_PLACE_MOUSEUP:
 			if (e->we.place.pt.x != -1 && e->we.place.select_proc == DDSP_DEMOLISH_AREA) {
-				GUIPlaceProcDragXY(e);
+				GUIPlaceProcDragXY(e->we.place.select_proc, e->we.place.starttile, e->we.place.tile);
 			}
 			break;
 
--- a/src/dock_gui.cpp
+++ b/src/dock_gui.cpp
@@ -162,7 +162,7 @@
 		if (e->we.place.pt.x != -1) {
 			switch (e->we.place.select_proc) {
 				case DDSP_DEMOLISH_AREA:
-					GUIPlaceProcDragXY(e);
+					GUIPlaceProcDragXY(e->we.place.select_proc, e->we.place.starttile, e->we.place.tile);
 					break;
 				case DDSP_CREATE_WATER:
 					DoCommandP(e->we.place.tile, e->we.place.starttile, 0, CcBuildCanal, CMD_BUILD_CANAL | CMD_MSG(STR_CANT_BUILD_CANALS));
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -610,6 +610,7 @@
 			TileIndex end_tile = e->we.place.tile;
 
 			switch (e->we.place.select_proc) {
+				default: NOT_REACHED();
 				case DDSP_BUILD_BRIDGE:
 					ResetObjectToPlace();
 					ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_RAIL, _cur_railtype);
@@ -624,7 +625,7 @@
 					break;
 
 				case DDSP_DEMOLISH_AREA:
-					GUIPlaceProcDragXY(e);
+					GUIPlaceProcDragXY(e->we.place.select_proc, e->we.place.starttile, e->we.place.tile);
 					break;
 
 				case DDSP_CONVERT_RAIL:
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -571,7 +571,7 @@
 						break;
 
 					case DDSP_DEMOLISH_AREA:
-						GUIPlaceProcDragXY(e);
+						GUIPlaceProcDragXY(e->we.place.select_proc, e->we.place.starttile, e->we.place.tile);
 						break;
 
 					case DDSP_PLACE_ROAD_X_DIR:
--- a/src/terraform_gui.cpp
+++ b/src/terraform_gui.cpp
@@ -110,12 +110,9 @@
  * allows for additional implements that are more local. For example X_Y drag
  * of convertrail which belongs in rail_gui.cpp and not terraform_gui.cpp
  **/
-bool GUIPlaceProcDragXY(const WindowEvent *e)
+bool GUIPlaceProcDragXY(ViewportDragDropSelectionProcess proc, TileIndex start_tile, TileIndex end_tile)
 {
-	TileIndex start_tile = e->we.place.starttile;
-	TileIndex end_tile = e->we.place.tile;
-
-	switch (e->we.place.select_proc) {
+	switch (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;
@@ -267,11 +264,12 @@
 	case WE_PLACE_MOUSEUP:
 		if (e->we.place.pt.x != -1) {
 			switch (e->we.place.select_proc) {
+				default: NOT_REACHED();
 				case DDSP_DEMOLISH_AREA:
 				case DDSP_RAISE_AND_LEVEL_AREA:
 				case DDSP_LOWER_AND_LEVEL_AREA:
 				case DDSP_LEVEL_AREA:
-					GUIPlaceProcDragXY(e);
+					GUIPlaceProcDragXY(e->we.place.select_proc, e->we.place.starttile, e->we.place.tile);
 					break;
 			}
 		}
@@ -655,6 +653,7 @@
 		case WE_PLACE_MOUSEUP:
 			if (e->we.place.pt.x != -1) {
 				switch (e->we.place.select_proc) {
+					default: NOT_REACHED();
 					case DDSP_CREATE_ROCKS:
 					case DDSP_CREATE_DESERT:
 					case DDSP_CREATE_WATER:
@@ -663,7 +662,7 @@
 					case DDSP_LOWER_AND_LEVEL_AREA:
 					case DDSP_LEVEL_AREA:
 					case DDSP_DEMOLISH_AREA:
-						GUIPlaceProcDragXY(e);
+						GUIPlaceProcDragXY(e->we.place.select_proc, e->we.place.starttile, e->we.place.tile);
 						break;
 				}
 			}
--- a/src/tilehighlight_func.h
+++ b/src/tilehighlight_func.h
@@ -12,7 +12,7 @@
 
 typedef void PlaceProc(TileIndex tile);
 void PlaceProc_DemolishArea(TileIndex tile);
-bool GUIPlaceProcDragXY(const WindowEvent *e);
+bool GUIPlaceProcDragXY(ViewportDragDropSelectionProcess proc, TileIndex start_tile, TileIndex end_tile);
 
 bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, ViewportHighlightMode mode, PlaceProc *placeproc);
 void SetObjectToPlaceWnd(CursorID icon, SpriteID pal, ViewportHighlightMode mode, Window *w);
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -178,7 +178,7 @@
 }
 
 
-void Window::OnPlaceDrag(ViewportPlaceMethod select_method, byte select_proc, Point pt)
+void Window::OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
 {
 	WindowEvent e;
 	e.event = WE_PLACE_DRAG;
@@ -188,7 +188,7 @@
 	this->HandleWindowEvent(&e);
 }
 
-void Window::OnPlaceMouseUp(ViewportPlaceMethod select_method, byte select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
+void Window::OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
 {
 	WindowEvent e;
 	e.event = WE_PLACE_MOUSEUP;
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -20,8 +20,6 @@
  */
 static const int MAX_NUMBER_OF_WINDOWS = 25;
 
-typedef void WindowProc(Window *w, WindowEvent *e);
-
 /* How the resize system works:
     First, you need to add a WWT_RESIZEBOX to the widgets, and you need
      to add the flag WDF_RESIZABLE to the window. Now the window is ready
@@ -147,7 +145,7 @@
 			TileIndex tile;
 			TileIndex starttile;
 			ViewportPlaceMethod select_method;
-			byte select_proc;
+			ViewportDragDropSelectionProcess select_proc;
 		} place;
 
 		struct {
@@ -185,6 +183,8 @@
 	} we;
 };
 
+typedef void WindowProc(Window *w, WindowEvent *e);
+
 /**
  * High level window description
  */
@@ -482,7 +482,7 @@
 	 * @param select_proc   what will be created when the drag is over.
 	 * @param pt            the exact point on the map where the mouse is.
 	 */
-	virtual void OnPlaceDrag(ViewportPlaceMethod select_method, byte select_proc, Point pt);
+	virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt);
 
 	/**
 	 * The user has dragged over the map when the tile highlight mode
@@ -493,7 +493,7 @@
 	 * @param start_tile    the begin tile of the drag.
 	 * @param end_tile      the end tile of the drag.
 	 */
-	virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, byte select_proc, Point pt, TileIndex start_tile, TileIndex end_tile);
+	virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile);
 
 	/**
 	 * The user moves over the map when a tile highlight mode has been set
--- a/src/window_type.h
+++ b/src/window_type.h
@@ -99,7 +99,6 @@
 };
 
 struct Window;
-struct WindowEvent;
 typedef int32 WindowNumber;
 
 #endif /* WINDOW_TYPE_H */