1
0
Fork 0

(svn r13160) -Codechange: prepare GUIPlaceProcDragXY for the removal of WindowEvent.

release/0.7
rubidium 2008-05-18 12:40:38 +00:00
parent a426047441
commit fc4393dcfe
9 changed files with 19 additions and 20 deletions

View File

@ -95,7 +95,7 @@ static void BuildAirToolbWndProc(Window *w, WindowEvent *e)
case WE_PLACE_MOUSEUP: case WE_PLACE_MOUSEUP:
if (e->we.place.pt.x != -1 && e->we.place.select_proc == DDSP_DEMOLISH_AREA) { 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; break;

View File

@ -162,7 +162,7 @@ static void BuildDocksToolbWndProc(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:
GUIPlaceProcDragXY(e); GUIPlaceProcDragXY(e->we.place.select_proc, e->we.place.starttile, e->we.place.tile);
break; break;
case DDSP_CREATE_WATER: case DDSP_CREATE_WATER:
DoCommandP(e->we.place.tile, e->we.place.starttile, 0, CcBuildCanal, CMD_BUILD_CANAL | CMD_MSG(STR_CANT_BUILD_CANALS)); DoCommandP(e->we.place.tile, e->we.place.starttile, 0, CcBuildCanal, CMD_BUILD_CANAL | CMD_MSG(STR_CANT_BUILD_CANALS));

View File

@ -610,6 +610,7 @@ static void BuildRailToolbWndProc(Window *w, WindowEvent *e)
TileIndex end_tile = e->we.place.tile; TileIndex end_tile = e->we.place.tile;
switch (e->we.place.select_proc) { switch (e->we.place.select_proc) {
default: NOT_REACHED();
case DDSP_BUILD_BRIDGE: case DDSP_BUILD_BRIDGE:
ResetObjectToPlace(); ResetObjectToPlace();
ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_RAIL, _cur_railtype); ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_RAIL, _cur_railtype);
@ -624,7 +625,7 @@ static void BuildRailToolbWndProc(Window *w, WindowEvent *e)
break; break;
case DDSP_DEMOLISH_AREA: case DDSP_DEMOLISH_AREA:
GUIPlaceProcDragXY(e); GUIPlaceProcDragXY(e->we.place.select_proc, e->we.place.starttile, e->we.place.tile);
break; break;
case DDSP_CONVERT_RAIL: case DDSP_CONVERT_RAIL:

View File

@ -571,7 +571,7 @@ static void BuildRoadToolbWndProc(Window *w, WindowEvent *e)
break; break;
case DDSP_DEMOLISH_AREA: case DDSP_DEMOLISH_AREA:
GUIPlaceProcDragXY(e); GUIPlaceProcDragXY(e->we.place.select_proc, e->we.place.starttile, e->we.place.tile);
break; break;
case DDSP_PLACE_ROAD_X_DIR: case DDSP_PLACE_ROAD_X_DIR:

View File

@ -110,12 +110,9 @@ static void GenerateRockyArea(TileIndex end, TileIndex start)
* allows for additional implements that are more local. For example X_Y drag * 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 * 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; switch (proc) {
TileIndex end_tile = e->we.place.tile;
switch (e->we.place.select_proc) {
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;
@ -267,11 +264,12 @@ static void TerraformToolbWndProc(Window *w, WindowEvent *e)
case WE_PLACE_MOUSEUP: case WE_PLACE_MOUSEUP:
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) {
default: NOT_REACHED();
case DDSP_DEMOLISH_AREA: case DDSP_DEMOLISH_AREA:
case DDSP_RAISE_AND_LEVEL_AREA: case DDSP_RAISE_AND_LEVEL_AREA:
case DDSP_LOWER_AND_LEVEL_AREA: case DDSP_LOWER_AND_LEVEL_AREA:
case DDSP_LEVEL_AREA: case DDSP_LEVEL_AREA:
GUIPlaceProcDragXY(e); GUIPlaceProcDragXY(e->we.place.select_proc, e->we.place.starttile, e->we.place.tile);
break; break;
} }
} }
@ -655,6 +653,7 @@ static void ScenEditLandGenWndProc(Window *w, WindowEvent *e)
case WE_PLACE_MOUSEUP: case WE_PLACE_MOUSEUP:
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) {
default: NOT_REACHED();
case DDSP_CREATE_ROCKS: case DDSP_CREATE_ROCKS:
case DDSP_CREATE_DESERT: case DDSP_CREATE_DESERT:
case DDSP_CREATE_WATER: case DDSP_CREATE_WATER:
@ -663,7 +662,7 @@ static void ScenEditLandGenWndProc(Window *w, WindowEvent *e)
case DDSP_LOWER_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->we.place.select_proc, e->we.place.starttile, e->we.place.tile);
break; break;
} }
} }

View File

@ -12,7 +12,7 @@
typedef void PlaceProc(TileIndex tile); typedef void PlaceProc(TileIndex tile);
void PlaceProc_DemolishArea(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); bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, ViewportHighlightMode mode, PlaceProc *placeproc);
void SetObjectToPlaceWnd(CursorID icon, SpriteID pal, ViewportHighlightMode mode, Window *w); void SetObjectToPlaceWnd(CursorID icon, SpriteID pal, ViewportHighlightMode mode, Window *w);

View File

@ -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; WindowEvent e;
e.event = WE_PLACE_DRAG; e.event = WE_PLACE_DRAG;
@ -188,7 +188,7 @@ void Window::OnPlaceDrag(ViewportPlaceMethod select_method, byte select_proc, Po
this->HandleWindowEvent(&e); 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; WindowEvent e;
e.event = WE_PLACE_MOUSEUP; e.event = WE_PLACE_MOUSEUP;

View File

@ -20,8 +20,6 @@
*/ */
static const int MAX_NUMBER_OF_WINDOWS = 25; static const int MAX_NUMBER_OF_WINDOWS = 25;
typedef void WindowProc(Window *w, WindowEvent *e);
/* How the resize system works: /* How the resize system works:
First, you need to add a WWT_RESIZEBOX to the widgets, and you need 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 to add the flag WDF_RESIZABLE to the window. Now the window is ready
@ -147,7 +145,7 @@ struct WindowEvent {
TileIndex tile; TileIndex tile;
TileIndex starttile; TileIndex starttile;
ViewportPlaceMethod select_method; ViewportPlaceMethod select_method;
byte select_proc; ViewportDragDropSelectionProcess select_proc;
} place; } place;
struct { struct {
@ -185,6 +183,8 @@ struct WindowEvent {
} we; } we;
}; };
typedef void WindowProc(Window *w, WindowEvent *e);
/** /**
* High level window description * High level window description
*/ */
@ -482,7 +482,7 @@ public:
* @param select_proc what will be created when the drag is over. * @param select_proc what will be created when the drag is over.
* @param pt the exact point on the map where the mouse is. * @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 * 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 start_tile the begin tile of the drag.
* @param end_tile the end 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 * The user moves over the map when a tile highlight mode has been set

View File

@ -99,7 +99,6 @@ enum WindowClass {
}; };
struct Window; struct Window;
struct WindowEvent;
typedef int32 WindowNumber; typedef int32 WindowNumber;
#endif /* WINDOW_TYPE_H */ #endif /* WINDOW_TYPE_H */