| 730 | } |
| 731 | |
| 732 | void OnPlaceMouseUp([[maybe_unused]] ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt, TileIndex start_tile, TileIndex end_tile) override |
| 733 | { |
| 734 | if (pt.x != -1) { |
| 735 | switch (select_proc) { |
| 736 | default: NOT_REACHED(); |
| 737 | case DDSP_BUILD_BRIDGE: |
| 738 | if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); |
| 739 | ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_ROAD, _cur_roadtype); |
| 740 | break; |
| 741 | |
| 742 | case DDSP_DEMOLISH_AREA: |
| 743 | GUIPlaceProcDragXY(select_proc, start_tile, end_tile); |
| 744 | break; |
| 745 | |
| 746 | case DDSP_PLACE_ROAD_X_DIR: |
| 747 | case DDSP_PLACE_ROAD_Y_DIR: |
| 748 | case DDSP_PLACE_AUTOROAD: { |
| 749 | bool start_half = _place_road_dir == AXIS_Y ? _place_road_start_half_y : _place_road_start_half_x; |
| 750 | |
| 751 | if (_remove_button_clicked) { |
| 752 | Command<CMD_REMOVE_LONG_ROAD>::Post(GetRoadTypeInfo(this->roadtype)->strings.err_remove_road, CcPlaySound_CONSTRUCTION_OTHER, |
| 753 | end_tile, start_tile, _cur_roadtype, _place_road_dir, start_half, _place_road_end_half); |
| 754 | } else { |
| 755 | Command<CMD_BUILD_LONG_ROAD>::Post(GetRoadTypeInfo(this->roadtype)->strings.err_build_road, CcPlaySound_CONSTRUCTION_OTHER, |
| 756 | end_tile, start_tile, _cur_roadtype, _place_road_dir, _one_way_button_clicked ? DRD_NORTHBOUND : DRD_NONE, start_half, _place_road_end_half, false); |
| 757 | } |
| 758 | break; |
| 759 | } |
| 760 | |
| 761 | case DDSP_BUILD_ROAD_WAYPOINT: |
| 762 | case DDSP_REMOVE_ROAD_WAYPOINT: |
| 763 | if (this->IsWidgetLowered(WID_ROT_BUILD_WAYPOINT)) { |
| 764 | if (_remove_button_clicked) { |
| 765 | Command<CMD_REMOVE_FROM_ROAD_WAYPOINT>::Post(STR_ERROR_CAN_T_REMOVE_ROAD_WAYPOINT, CcPlaySound_CONSTRUCTION_OTHER, end_tile, start_tile); |
| 766 | } else { |
| 767 | TileArea ta(start_tile, end_tile); |
| 768 | Axis axis = select_method == VPM_X_LIMITED ? AXIS_X : AXIS_Y; |
| 769 | bool adjacent = _ctrl_pressed; |
| 770 | |
| 771 | auto proc = [=](bool test, StationID to_join) -> bool { |
| 772 | if (test) { |
| 773 | return Command<CMD_BUILD_ROAD_WAYPOINT>::Do(CommandFlagsToDCFlags(GetCommandFlags<CMD_BUILD_ROAD_WAYPOINT>()), ta.tile, axis, ta.w, ta.h, _waypoint_gui.sel_class, _waypoint_gui.sel_type, StationID::Invalid(), adjacent).Succeeded(); |
| 774 | } else { |
| 775 | return Command<CMD_BUILD_ROAD_WAYPOINT>::Post(STR_ERROR_CAN_T_BUILD_ROAD_WAYPOINT, CcPlaySound_CONSTRUCTION_OTHER, ta.tile, axis, ta.w, ta.h, _waypoint_gui.sel_class, _waypoint_gui.sel_type, to_join, adjacent); |
| 776 | } |
| 777 | }; |
| 778 | |
| 779 | ShowSelectRoadWaypointIfNeeded(ta, proc); |
| 780 | } |
| 781 | } |
| 782 | break; |
| 783 | |
| 784 | case DDSP_BUILD_BUSSTOP: |
| 785 | case DDSP_REMOVE_BUSSTOP: |
| 786 | if (this->IsWidgetLowered(WID_ROT_BUS_STATION) && GetIfClassHasNewStopsByType(RoadStopClass::Get(_roadstop_gui.sel_class), RoadStopType::Bus, _cur_roadtype)) { |
| 787 | if (_remove_button_clicked) { |
| 788 | TileArea ta(start_tile, end_tile); |
| 789 | StringID str = GetRoadTypeInfo(this->roadtype)->strings.err_remove_station[to_underlying(RoadStopType::Bus)]; |
no test coverage detected