70 GenericPlaceRail(tile, cmd); |
70 GenericPlaceRail(tile, cmd); |
71 } |
71 } |
72 |
72 |
73 static void PlaceRail_NE(TileIndex tile) |
73 static void PlaceRail_NE(TileIndex tile) |
74 { |
74 { |
75 VpStartPlaceSizing(tile, VPM_FIX_Y); |
75 VpStartPlaceSizing(tile, VPM_FIX_Y, GUI_PlaceProc_None); |
76 } |
76 } |
77 |
77 |
78 static void PlaceRail_E(TileIndex tile) |
78 static void PlaceRail_E(TileIndex tile) |
79 { |
79 { |
80 int cmd = _tile_fract_coords.x + _tile_fract_coords.y <= 15 ? 2 : 3; |
80 int cmd = _tile_fract_coords.x + _tile_fract_coords.y <= 15 ? 2 : 3; |
81 GenericPlaceRail(tile, cmd); |
81 GenericPlaceRail(tile, cmd); |
82 } |
82 } |
83 |
83 |
84 static void PlaceRail_NW(TileIndex tile) |
84 static void PlaceRail_NW(TileIndex tile) |
85 { |
85 { |
86 VpStartPlaceSizing(tile, VPM_FIX_X); |
86 VpStartPlaceSizing(tile, VPM_FIX_X, GUI_PlaceProc_None); |
87 } |
87 } |
88 |
88 |
89 static void PlaceRail_AutoRail(TileIndex tile) |
89 static void PlaceRail_AutoRail(TileIndex tile) |
90 { |
90 { |
91 VpStartPlaceSizing(tile, VPM_RAILDIRS); |
91 VpStartPlaceSizing(tile, VPM_RAILDIRS, GUI_PlaceProc_None); |
92 } |
92 } |
93 |
93 |
94 static void PlaceExtraDepotRail(TileIndex tile, uint16 extra) |
94 static void PlaceExtraDepotRail(TileIndex tile, uint16 extra) |
95 { |
95 { |
96 if (GetRailTileType(tile) != RAIL_TILE_NORMAL) return; |
96 if (GetRailTileType(tile) != RAIL_TILE_NORMAL) return; |
149 } |
149 } |
150 |
150 |
151 static void PlaceRail_Station(TileIndex tile) |
151 static void PlaceRail_Station(TileIndex tile) |
152 { |
152 { |
153 if (_remove_button_clicked) { |
153 if (_remove_button_clicked) { |
154 DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_REMOVE_FROM_RAILROAD_STATION | CMD_MSG(STR_CANT_REMOVE_PART_OF_STATION)); |
154 VpStartPlaceSizing(tile, VPM_X_AND_Y, GUI_PlaceProc_RemoveFromStation); |
155 } else if (_railstation.dragdrop) { |
155 } else if (_railstation.dragdrop) { |
156 VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED); |
156 VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, GUI_PlaceProc_None); |
157 VpSetPlaceSizingLimit(_patches.station_spread); |
157 VpSetPlaceSizingLimit(_patches.station_spread); |
158 } else { |
158 } else { |
159 DoCommandP(tile, |
159 DoCommandP(tile, |
160 _railstation.orientation | (_railstation.numtracks << 8) | (_railstation.platlength << 16), |
160 _railstation.orientation | (_railstation.numtracks << 8) | (_railstation.platlength << 16), |
161 _cur_railtype | (_railstation.station_class << 8) | (_railstation.station_type << 16), CcStation, |
161 _cur_railtype | (_railstation.station_class << 8) | (_railstation.station_type << 16), CcStation, |
221 DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_PURCHASE_LAND_AREA | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_5806_CAN_T_PURCHASE_THIS_LAND)); |
221 DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_PURCHASE_LAND_AREA | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_5806_CAN_T_PURCHASE_THIS_LAND)); |
222 } |
222 } |
223 |
223 |
224 static void PlaceRail_ConvertRail(TileIndex tile) |
224 static void PlaceRail_ConvertRail(TileIndex tile) |
225 { |
225 { |
226 VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_ConvertRailArea); |
226 VpStartPlaceSizing(tile, VPM_X_AND_Y, GUI_PlaceProc_ConvertRailArea); |
227 } |
227 } |
228 |
228 |
229 static void PlaceRail_AutoSignals(TileIndex tile) |
229 static void PlaceRail_AutoSignals(TileIndex tile) |
230 { |
230 { |
231 VpStartPlaceSizing(tile, VPM_SIGNALDIRS); |
231 VpStartPlaceSizing(tile, VPM_SIGNALDIRS, GUI_PlaceProc_None); |
232 } |
232 } |
233 |
233 |
234 |
234 |
235 /** Enum referring to the widgets of the build rail toolbar */ |
235 /** Enum referring to the widgets of the build rail toolbar */ |
236 enum { |
236 enum { |
490 case WE_PLACE_OBJ: |
490 case WE_PLACE_OBJ: |
491 _place_proc(e->we.place.tile); |
491 _place_proc(e->we.place.tile); |
492 return; |
492 return; |
493 |
493 |
494 case WE_PLACE_DRAG: { |
494 case WE_PLACE_DRAG: { |
495 VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.userdata & 0xF); |
495 VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method); |
496 return; |
496 return; |
497 } |
497 } |
498 |
498 |
499 case WE_PLACE_MOUSEUP: |
499 case WE_PLACE_MOUSEUP: |
500 if (e->we.place.pt.x != -1) { |
500 if (e->we.place.pt.x != -1) { |
501 TileIndex start_tile = e->we.place.starttile; |
501 TileIndex start_tile = e->we.place.starttile; |
502 TileIndex end_tile = e->we.place.tile; |
502 TileIndex end_tile = e->we.place.tile; |
503 |
503 |
504 if (e->we.place.userdata == VPM_X_OR_Y) { |
504 switch (e->we.place.select_method) { |
505 ResetObjectToPlace(); |
505 case VPM_X_OR_Y: |
506 ShowBuildBridgeWindow(start_tile, end_tile, _cur_railtype); |
506 ResetObjectToPlace(); |
507 } else if (e->we.place.userdata == VPM_RAILDIRS) { |
507 ShowBuildBridgeWindow(start_tile, end_tile, _cur_railtype); |
508 bool old = _remove_button_clicked; |
508 break; |
509 if (_ctrl_pressed) _remove_button_clicked = true; |
509 |
510 HandleAutodirPlacement(); |
510 case VPM_RAILDIRS: { |
511 _remove_button_clicked = old; |
511 bool old = _remove_button_clicked; |
512 } else if (e->we.place.userdata == VPM_SIGNALDIRS) { |
512 if (_ctrl_pressed) _remove_button_clicked = true; |
513 HandleAutoSignalPlacement(); |
513 HandleAutodirPlacement(); |
514 } else if ((e->we.place.userdata & 0xF) == VPM_X_AND_Y) { |
514 _remove_button_clicked = old; |
515 if (GUIPlaceProcDragXY(e)) break; |
515 break; |
516 |
516 } |
517 if ((e->we.place.userdata >> 4) == GUI_PlaceProc_ConvertRailArea >> 4) |
517 |
518 DoCommandP(end_tile, start_tile, _cur_railtype, CcPlaySound10, CMD_CONVERT_RAIL | CMD_MSG(STR_CANT_CONVERT_RAIL)); |
518 case VPM_SIGNALDIRS: |
519 } else if (e->we.place.userdata == VPM_X_AND_Y_LIMITED) { |
519 HandleAutoSignalPlacement(); |
520 HandleStationPlacement(start_tile, end_tile); |
520 break; |
521 } else { |
521 |
522 DoRailroadTrack(e->we.place.userdata & 1); |
522 case VPM_X_AND_Y: |
|
523 if (GUIPlaceProcDragXY(e)) break; |
|
524 |
|
525 switch (e->we.place.select_proc) { |
|
526 case GUI_PlaceProc_RemoveFromStation: |
|
527 DoCommandP(end_tile, start_tile, 0, CcPlaySound1E, CMD_REMOVE_FROM_RAILROAD_STATION | CMD_MSG(STR_CANT_REMOVE_PART_OF_STATION)); |
|
528 break; |
|
529 |
|
530 case GUI_PlaceProc_ConvertRailArea: |
|
531 DoCommandP(end_tile, start_tile, _cur_railtype, CcPlaySound10, CMD_CONVERT_RAIL | CMD_MSG(STR_CANT_CONVERT_RAIL)); |
|
532 break; |
|
533 } |
|
534 break; |
|
535 |
|
536 case VPM_X_AND_Y_LIMITED: |
|
537 HandleStationPlacement(start_tile, end_tile); |
|
538 break; |
|
539 |
|
540 default: |
|
541 DoRailroadTrack(e->we.place.select_method == VPM_FIX_Y ? TRACK_X : TRACK_Y); |
|
542 break; |
523 } |
543 } |
524 } |
544 } |
525 break; |
545 break; |
526 |
546 |
527 case WE_ABORT_PLACE_OBJ: |
547 case WE_ABORT_PLACE_OBJ: |