# HG changeset patch # User rubidium # Date 2008-05-18 12:40:38 # Node ID 381d58467a0b6860c7859dec16b548a615cad5ab # Parent 3e908df09326fd9bd71c19525886b8762fc1f3d0 (svn r13160) -Codechange: prepare GUIPlaceProcDragXY for the removal of WindowEvent. diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -95,7 +95,7 @@ static void BuildAirToolbWndProc(Window 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; diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -162,7 +162,7 @@ static void BuildDocksToolbWndProc(Windo 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)); diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -610,6 +610,7 @@ static void BuildRailToolbWndProc(Window 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 @@ static void BuildRailToolbWndProc(Window 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: diff --git a/src/road_gui.cpp b/src/road_gui.cpp --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -571,7 +571,7 @@ static void BuildRoadToolbWndProc(Window 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: diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -110,12 +110,9 @@ static void GenerateRockyArea(TileIndex * 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 @@ static void TerraformToolbWndProc(Window 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 @@ static void ScenEditLandGenWndProc(Windo 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 @@ static void ScenEditLandGenWndProc(Windo 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; } } diff --git a/src/tilehighlight_func.h b/src/tilehighlight_func.h --- 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); diff --git a/src/window.cpp b/src/window.cpp --- a/src/window.cpp +++ b/src/window.cpp @@ -178,7 +178,7 @@ void Window::OnPlaceObjectAbort() } -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 @@ void Window::OnPlaceDrag(ViewportPlaceMe 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; diff --git a/src/window_gui.h b/src/window_gui.h --- 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 @@ struct WindowEvent { TileIndex tile; TileIndex starttile; ViewportPlaceMethod select_method; - byte select_proc; + ViewportDragDropSelectionProcess select_proc; } place; struct { @@ -185,6 +183,8 @@ struct WindowEvent { } we; }; +typedef void WindowProc(Window *w, WindowEvent *e); + /** * High level window description */ @@ -482,7 +482,7 @@ public: * @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 @@ public: * @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 diff --git a/src/window_type.h b/src/window_type.h --- a/src/window_type.h +++ b/src/window_type.h @@ -99,7 +99,6 @@ enum WindowClass { }; struct Window; -struct WindowEvent; typedef int32 WindowNumber; #endif /* WINDOW_TYPE_H */