69 GenericPlaceRail(tile, cmd); |
70 GenericPlaceRail(tile, cmd); |
70 } |
71 } |
71 |
72 |
72 static void PlaceRail_NE(TileIndex tile) |
73 static void PlaceRail_NE(TileIndex tile) |
73 { |
74 { |
74 VpStartPlaceSizing(tile, VPM_FIX_Y); |
75 VpStartPlaceSizing(tile, VPM_FIX_Y, DDSP_PLACE_RAIL_NE); |
75 } |
76 } |
76 |
77 |
77 static void PlaceRail_E(TileIndex tile) |
78 static void PlaceRail_E(TileIndex tile) |
78 { |
79 { |
79 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; |
80 GenericPlaceRail(tile, cmd); |
81 GenericPlaceRail(tile, cmd); |
81 } |
82 } |
82 |
83 |
83 static void PlaceRail_NW(TileIndex tile) |
84 static void PlaceRail_NW(TileIndex tile) |
84 { |
85 { |
85 VpStartPlaceSizing(tile, VPM_FIX_X); |
86 VpStartPlaceSizing(tile, VPM_FIX_X, DDSP_PLACE_RAIL_NW); |
86 } |
87 } |
87 |
88 |
88 static void PlaceRail_AutoRail(TileIndex tile) |
89 static void PlaceRail_AutoRail(TileIndex tile) |
89 { |
90 { |
90 VpStartPlaceSizing(tile, VPM_RAILDIRS); |
91 VpStartPlaceSizing(tile, VPM_RAILDIRS, DDSP_PLACE_AUTORAIL); |
91 } |
92 } |
92 |
93 |
93 static void PlaceExtraDepotRail(TileIndex tile, uint16 extra) |
94 static void PlaceExtraDepotRail(TileIndex tile, uint16 extra) |
94 { |
95 { |
95 if (GetRailTileType(tile) != RAIL_TILE_NORMAL) return; |
96 if (GetRailTileType(tile) != RAIL_TILE_NORMAL) return; |
148 } |
149 } |
149 |
150 |
150 static void PlaceRail_Station(TileIndex tile) |
151 static void PlaceRail_Station(TileIndex tile) |
151 { |
152 { |
152 if (_remove_button_clicked) { |
153 if (_remove_button_clicked) { |
153 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, DDSP_REMOVE_STATION); |
154 } else if (_railstation.dragdrop) { |
155 } else if (_railstation.dragdrop) { |
155 VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED); |
156 VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_BUILD_STATION); |
156 VpSetPlaceSizingLimit(_patches.station_spread); |
157 VpSetPlaceSizingLimit(_patches.station_spread); |
157 } else { |
158 } else { |
158 DoCommandP(tile, |
159 DoCommandP(tile, |
159 _railstation.orientation | (_railstation.numtracks << 8) | (_railstation.platlength << 16), |
160 _railstation.orientation | (_railstation.numtracks << 8) | (_railstation.platlength << 16) | (_ctrl_pressed << 24), |
160 _cur_railtype | (_railstation.station_class << 8) | (_railstation.station_type << 16), CcStation, |
161 _cur_railtype | (_railstation.station_class << 8) | (_railstation.station_type << 16), CcStation, |
161 CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_AUTO | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION)); |
162 CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_AUTO | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION)); |
162 } |
163 } |
163 } |
164 } |
164 |
165 |
165 static void GenericPlaceSignals(TileIndex tile) |
166 static void GenericPlaceSignals(TileIndex tile) |
166 { |
167 { |
167 byte trackstat; |
168 byte trackstat; |
168 uint i; |
169 uint i; |
169 |
170 |
170 trackstat = (byte)GetTileTrackStatus(tile, TRANSPORT_RAIL); |
171 trackstat = (byte)GetTileTrackStatus(tile, TRANSPORT_RAIL, 0); |
171 |
172 |
172 if (trackstat & TRACK_BIT_VERT) // N-S direction |
173 if (trackstat & TRACK_BIT_VERT) // N-S direction |
173 trackstat = (_tile_fract_coords.x <= _tile_fract_coords.y) ? TRACK_BIT_RIGHT : TRACK_BIT_LEFT; |
174 trackstat = (_tile_fract_coords.x <= _tile_fract_coords.y) ? TRACK_BIT_RIGHT : TRACK_BIT_LEFT; |
174 |
175 |
175 if (trackstat & TRACK_BIT_HORZ) // E-W direction |
176 if (trackstat & TRACK_BIT_HORZ) // E-W direction |
220 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)); |
221 } |
222 } |
222 |
223 |
223 static void PlaceRail_ConvertRail(TileIndex tile) |
224 static void PlaceRail_ConvertRail(TileIndex tile) |
224 { |
225 { |
225 VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_ConvertRailArea); |
226 VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CONVERT_RAIL); |
226 } |
227 } |
227 |
228 |
228 static void PlaceRail_AutoSignals(TileIndex tile) |
229 static void PlaceRail_AutoSignals(TileIndex tile) |
229 { |
230 { |
230 VpStartPlaceSizing(tile, VPM_SIGNALDIRS); |
231 VpStartPlaceSizing(tile, VPM_SIGNALDIRS, DDSP_BUILD_SIGNALS); |
231 } |
232 } |
232 |
233 |
233 |
234 |
234 /** Enum referring to the widgets of the build rail toolbar */ |
235 /** Enum referring to the widgets of the build rail toolbar */ |
235 enum { |
236 enum { |
489 case WE_PLACE_OBJ: |
490 case WE_PLACE_OBJ: |
490 _place_proc(e->we.place.tile); |
491 _place_proc(e->we.place.tile); |
491 return; |
492 return; |
492 |
493 |
493 case WE_PLACE_DRAG: { |
494 case WE_PLACE_DRAG: { |
494 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); |
495 return; |
496 return; |
496 } |
497 } |
497 |
498 |
498 case WE_PLACE_MOUSEUP: |
499 case WE_PLACE_MOUSEUP: |
499 if (e->we.place.pt.x != -1) { |
500 if (e->we.place.pt.x != -1) { |
500 TileIndex start_tile = e->we.place.starttile; |
501 TileIndex start_tile = e->we.place.starttile; |
501 TileIndex end_tile = e->we.place.tile; |
502 TileIndex end_tile = e->we.place.tile; |
502 |
503 |
503 if (e->we.place.userdata == VPM_X_OR_Y) { |
504 switch (e->we.place.select_proc) { |
504 ResetObjectToPlace(); |
505 case DDSP_BUILD_BRIDGE: |
505 ShowBuildBridgeWindow(start_tile, end_tile, _cur_railtype); |
506 ResetObjectToPlace(); |
506 } else if (e->we.place.userdata == VPM_RAILDIRS) { |
507 ShowBuildBridgeWindow(start_tile, end_tile, _cur_railtype); |
507 bool old = _remove_button_clicked; |
508 break; |
508 if (_ctrl_pressed) _remove_button_clicked = true; |
509 |
509 HandleAutodirPlacement(); |
510 case DDSP_PLACE_AUTORAIL: { |
510 _remove_button_clicked = old; |
511 bool old = _remove_button_clicked; |
511 } else if (e->we.place.userdata == VPM_SIGNALDIRS) { |
512 if (_ctrl_pressed) _remove_button_clicked = true; |
512 HandleAutoSignalPlacement(); |
513 HandleAutodirPlacement(); |
513 } else if ((e->we.place.userdata & 0xF) == VPM_X_AND_Y) { |
514 _remove_button_clicked = old; |
514 if (GUIPlaceProcDragXY(e)) break; |
515 break; |
515 |
516 } |
516 if ((e->we.place.userdata >> 4) == GUI_PlaceProc_ConvertRailArea >> 4) |
517 |
|
518 case DDSP_BUILD_SIGNALS: |
|
519 HandleAutoSignalPlacement(); |
|
520 break; |
|
521 |
|
522 case DDSP_DEMOLISH_AREA: |
|
523 GUIPlaceProcDragXY(e); |
|
524 break; |
|
525 |
|
526 case DDSP_REMOVE_STATION: |
|
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 DDSP_CONVERT_RAIL: |
517 DoCommandP(end_tile, start_tile, _cur_railtype, CcPlaySound10, CMD_CONVERT_RAIL | CMD_MSG(STR_CANT_CONVERT_RAIL)); |
531 DoCommandP(end_tile, start_tile, _cur_railtype, CcPlaySound10, CMD_CONVERT_RAIL | CMD_MSG(STR_CANT_CONVERT_RAIL)); |
518 } else if (e->we.place.userdata == VPM_X_AND_Y_LIMITED) { |
532 break; |
519 HandleStationPlacement(start_tile, end_tile); |
533 |
520 } else { |
534 case DDSP_BUILD_STATION: |
521 DoRailroadTrack(e->we.place.userdata & 1); |
535 HandleStationPlacement(start_tile, end_tile); |
|
536 break; |
|
537 |
|
538 case DDSP_PLACE_RAIL_NE: |
|
539 case DDSP_PLACE_RAIL_NW: |
|
540 DoRailroadTrack(e->we.place.select_proc == DDSP_PLACE_RAIL_NE ? TRACK_X : TRACK_Y); |
|
541 break; |
522 } |
542 } |
523 } |
543 } |
524 break; |
544 break; |
525 |
545 |
526 case WE_ABORT_PLACE_OBJ: |
546 case WE_ABORT_PLACE_OBJ: |
643 w = ex - sx + 1; |
663 w = ex - sx + 1; |
644 h = ey - sy + 1; |
664 h = ey - sy + 1; |
645 if (!_railstation.orientation) Swap(w, h); |
665 if (!_railstation.orientation) Swap(w, h); |
646 |
666 |
647 DoCommandP(TileXY(sx, sy), |
667 DoCommandP(TileXY(sx, sy), |
648 _railstation.orientation | (w << 8) | (h << 16), |
668 _railstation.orientation | (w << 8) | (h << 16) | (_ctrl_pressed << 24), |
649 _cur_railtype | (_railstation.station_class << 8) | (_railstation.station_type << 16), CcStation, |
669 _cur_railtype | (_railstation.station_class << 8) | (_railstation.station_type << 16), CcStation, |
650 CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_AUTO | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION)); |
670 CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_AUTO | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION)); |
651 } |
671 } |
652 |
672 |
653 /* Check if the currently selected station size is allowed */ |
673 /* Check if the currently selected station size is allowed */ |
735 /* Set up a clipping area for the '/' station preview */ |
755 /* Set up a clipping area for the '/' station preview */ |
736 if (FillDrawPixelInfo(&tmp_dpi, 7, 26 + y_offset, 66, 48)) { |
756 if (FillDrawPixelInfo(&tmp_dpi, 7, 26 + y_offset, 66, 48)) { |
737 old_dpi = _cur_dpi; |
757 old_dpi = _cur_dpi; |
738 _cur_dpi = &tmp_dpi; |
758 _cur_dpi = &tmp_dpi; |
739 if (!DrawStationTile(32, 16, _cur_railtype, AXIS_X, _railstation.station_class, _railstation.station_type)) { |
759 if (!DrawStationTile(32, 16, _cur_railtype, AXIS_X, _railstation.station_class, _railstation.station_type)) { |
740 StationPickerDrawSprite(32, 16, _cur_railtype, 2); |
760 StationPickerDrawSprite(32, 16, _cur_railtype, INVALID_ROADTYPE, 2); |
741 } |
761 } |
742 _cur_dpi = old_dpi; |
762 _cur_dpi = old_dpi; |
743 } |
763 } |
744 |
764 |
745 /* Set up a clipping area for the '\' station preview */ |
765 /* Set up a clipping area for the '\' station preview */ |
746 if (FillDrawPixelInfo(&tmp_dpi, 75, 26 + y_offset, 66, 48)) { |
766 if (FillDrawPixelInfo(&tmp_dpi, 75, 26 + y_offset, 66, 48)) { |
747 old_dpi = _cur_dpi; |
767 old_dpi = _cur_dpi; |
748 _cur_dpi = &tmp_dpi; |
768 _cur_dpi = &tmp_dpi; |
749 if (!DrawStationTile(32, 16, _cur_railtype, AXIS_Y, _railstation.station_class, _railstation.station_type)) { |
769 if (!DrawStationTile(32, 16, _cur_railtype, AXIS_Y, _railstation.station_class, _railstation.station_type)) { |
750 StationPickerDrawSprite(32, 16, _cur_railtype, 3); |
770 StationPickerDrawSprite(32, 16, _cur_railtype, INVALID_ROADTYPE, 3); |
751 } |
771 } |
752 _cur_dpi = old_dpi; |
772 _cur_dpi = old_dpi; |
753 } |
773 } |
754 |
774 |
755 DrawStringCentered(74, 15 + y_offset, STR_3002_ORIENTATION, 0); |
775 DrawStringCentered(74, 15 + y_offset, STR_3002_ORIENTATION, 0); |