* Handle the click on the unload button. * @param unload_type Unload flag to apply. If matches existing unload type, toggles to default of 'unload if possible'. * @param toggle If we toggle or not (used for hotkey behavior) */
| 641 | * @param toggle If we toggle or not (used for hotkey behavior) |
| 642 | */ |
| 643 | void OrderClick_Unload(OrderUnloadType unload_type, bool toggle = false) |
| 644 | { |
| 645 | VehicleOrderID sel_ord = this->OrderGetSel(); |
| 646 | const Order *order = this->vehicle->GetOrder(sel_ord); |
| 647 | |
| 648 | if (order == nullptr) return; |
| 649 | |
| 650 | if (toggle && order->GetUnloadType() == unload_type) { |
| 651 | unload_type = OrderUnloadType::UnloadIfPossible; |
| 652 | } |
| 653 | if (order->GetUnloadType() == unload_type) return; // If we still match, do nothing |
| 654 | |
| 655 | Command<CMD_MODIFY_ORDER>::Post(STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index, sel_ord, MOF_UNLOAD, to_underlying(unload_type)); |
| 656 | |
| 657 | /* Transfer and unload orders with leave empty as default */ |
| 658 | if (unload_type == OrderUnloadType::Transfer || unload_type == OrderUnloadType::Unload) { |
| 659 | Command<CMD_MODIFY_ORDER>::Post(this->vehicle->tile, this->vehicle->index, sel_ord, MOF_LOAD, to_underlying(OrderLoadType::NoLoad)); |
| 660 | this->SetWidgetDirty(WID_O_FULL_LOAD); |
| 661 | } |
| 662 | } |
| 663 | |
| 664 | /** |
| 665 | * Handle the click on the nonstop button. |
no test coverage detected