diff options
author | rubidium <rubidium@openttd.org> | 2008-05-10 13:46:36 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-05-10 13:46:36 +0000 |
commit | 2ac412375c68db4d037cd5de243eb7e9d1f504b7 (patch) | |
tree | 03bcd6a5e6e6fd5771fa462f05a599c97c6a9661 /src/viewport.cpp | |
parent | f7108760378c98077b1c664939d0e2c32a21624f (diff) | |
download | openttd-2ac412375c68db4d037cd5de243eb7e9d1f504b7.tar.xz |
(svn r13029) -Codechange: more work in the road to getting the WP macros and byte[WINDOW_CUSTOM_SIZE] removed. This step changes the event handling to work directly on the Window class instead of via a function pointer and big switches while keeping backward compatability while we're rewriting the Windows to the new scheme.
Diffstat (limited to 'src/viewport.cpp')
-rw-r--r-- | src/viewport.cpp | 32 |
1 files changed, 6 insertions, 26 deletions
diff --git a/src/viewport.cpp b/src/viewport.cpp index fed5d26e9..499adf69f 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -2057,14 +2057,7 @@ void PlaceObject() _tile_fract_coords.y = pt.y & 0xF; w = GetCallbackWnd(); - if (w != NULL) { - WindowEvent e; - - e.event = WE_PLACE_OBJ; - e.we.place.pt = pt; - e.we.place.tile = TileVirtXY(pt.x, pt.y); - w->HandleWindowEvent(&e); - } + if (w != NULL) w->OnPlaceObject(pt, TileVirtXY(pt.x, pt.y)); } @@ -2695,16 +2688,10 @@ calc_heightdiff_single_direction:; /** while dragging */ bool VpHandlePlaceSizingDrag() { - Window *w; - WindowEvent e; - if (_special_mouse_mode != WSM_SIZING) return true; - e.we.place.select_method = _thd.select_method; - e.we.place.select_proc = _thd.select_proc; - /* stop drag mode if the window has been closed */ - w = FindWindowById(_thd.window_class, _thd.window_number); + Window *w = FindWindowById(_thd.window_class, _thd.window_number); if (w == NULL) { ResetObjectToPlace(); return false; @@ -2712,9 +2699,7 @@ bool VpHandlePlaceSizingDrag() /* while dragging execute the drag procedure of the corresponding window (mostly VpSelectTilesWithMethod() ) */ if (_left_button_down) { - e.event = WE_PLACE_DRAG; - e.we.place.pt = GetTileBelowCursor(); - w->HandleWindowEvent(&e); + w->OnPlaceDrag(_thd.select_method, _thd.select_proc, GetTileBelowCursor()); return false; } @@ -2723,7 +2708,7 @@ bool VpHandlePlaceSizingDrag() _special_mouse_mode = WSM_NONE; if (_thd.next_drawstyle == HT_RECT) { _thd.place_mode = VHM_RECT; - } else if (e.we.place.select_method == VPM_SIGNALDIRS) { // some might call this a hack... -- Dominik + } else if (_thd.select_method == VPM_SIGNALDIRS) { // some might call this a hack... -- Dominik _thd.place_mode = VHM_RECT; } else if (_thd.next_drawstyle & HT_LINE) { _thd.place_mode = VHM_RAIL; @@ -2734,12 +2719,7 @@ bool VpHandlePlaceSizingDrag() } SetTileSelectSize(1, 1); - /* and call the mouseup event. */ - e.event = WE_PLACE_MOUSEUP; - e.we.place.pt = _thd.selend; - e.we.place.tile = TileVirtXY(e.we.place.pt.x, e.we.place.pt.y); - e.we.place.starttile = TileVirtXY(_thd.selstart.x, _thd.selstart.y); - w->HandleWindowEvent(&e); + w->OnPlaceMouseUp(_thd.select_method, _thd.select_proc, _thd.selend, TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y)); return false; } @@ -2758,7 +2738,7 @@ void SetObjectToPlace(CursorID icon, SpriteID pal, ViewportHighlightMode mode, W /* undo clicking on button and drag & drop */ if (_thd.place_mode != VHM_NONE || _special_mouse_mode == WSM_DRAGDROP) { w = FindWindowById(_thd.window_class, _thd.window_number); - if (w != NULL) CallWindowEventNP(w, WE_ABORT_PLACE_OBJ); + if (w != NULL) w->OnPlaceObjectAbort(); } SetTileSelectSize(1, 1); |