| 896 | } |
| 897 | |
| 898 | void UpdateButtonState() |
| 899 | { |
| 900 | if (this->vehicle->owner != _local_company) return; // No buttons are displayed with competitor order windows. |
| 901 | |
| 902 | bool shared_orders = this->vehicle->IsOrderListShared(); |
| 903 | VehicleOrderID sel = this->OrderGetSel(); |
| 904 | const Order *order = this->vehicle->GetOrder(sel); |
| 905 | |
| 906 | /* Second row. */ |
| 907 | /* skip */ |
| 908 | this->SetWidgetDisabledState(WID_O_SKIP, this->vehicle->GetNumOrders() <= 1); |
| 909 | |
| 910 | /* delete / stop sharing */ |
| 911 | NWidgetStacked *delete_sel = this->GetWidget<NWidgetStacked>(WID_O_SEL_BOTTOM_MIDDLE); |
| 912 | if (shared_orders && this->selected_order == this->vehicle->GetNumOrders()) { |
| 913 | /* The 'End of Shared Orders' order is selected, show the 'stop sharing' button. */ |
| 914 | delete_sel->SetDisplayedPlane(DP_BOTTOM_MIDDLE_STOP_SHARING); |
| 915 | } else { |
| 916 | /* The 'End of Shared Orders' order isn't selected, show the 'delete' button. */ |
| 917 | delete_sel->SetDisplayedPlane(DP_BOTTOM_MIDDLE_DELETE); |
| 918 | this->SetWidgetDisabledState(WID_O_DELETE, |
| 919 | (uint)this->vehicle->GetNumOrders() + ((shared_orders || this->vehicle->GetNumOrders() != 0) ? 1 : 0) <= (uint)this->selected_order); |
| 920 | |
| 921 | /* Set the tooltip of the 'delete' button depending on whether the |
| 922 | * 'End of Orders' order or a regular order is selected. */ |
| 923 | NWidgetCore *nwi = this->GetWidget<NWidgetCore>(WID_O_DELETE); |
| 924 | if (this->selected_order == this->vehicle->GetNumOrders()) { |
| 925 | nwi->SetStringTip(STR_ORDERS_DELETE_BUTTON, STR_ORDERS_DELETE_ALL_TOOLTIP); |
| 926 | } else { |
| 927 | nwi->SetStringTip(STR_ORDERS_DELETE_BUTTON, STR_ORDERS_DELETE_TOOLTIP); |
| 928 | } |
| 929 | } |
| 930 | |
| 931 | /* First row. */ |
| 932 | this->RaiseWidget(WID_O_FULL_LOAD); |
| 933 | this->RaiseWidget(WID_O_UNLOAD); |
| 934 | |
| 935 | /* Selection widgets. */ |
| 936 | /* Train or road vehicle. */ |
| 937 | NWidgetStacked *train_row_sel = this->GetWidget<NWidgetStacked>(WID_O_SEL_TOP_ROW_GROUNDVEHICLE); |
| 938 | NWidgetStacked *left_sel = this->GetWidget<NWidgetStacked>(WID_O_SEL_TOP_LEFT); |
| 939 | NWidgetStacked *middle_sel = this->GetWidget<NWidgetStacked>(WID_O_SEL_TOP_MIDDLE); |
| 940 | NWidgetStacked *right_sel = this->GetWidget<NWidgetStacked>(WID_O_SEL_TOP_RIGHT); |
| 941 | /* Ship or airplane. */ |
| 942 | NWidgetStacked *row_sel = this->GetWidget<NWidgetStacked>(WID_O_SEL_TOP_ROW); |
| 943 | assert(row_sel != nullptr || (train_row_sel != nullptr && left_sel != nullptr && middle_sel != nullptr && right_sel != nullptr)); |
| 944 | |
| 945 | |
| 946 | if (order == nullptr) { |
| 947 | if (row_sel != nullptr) { |
| 948 | row_sel->SetDisplayedPlane(DP_ROW_LOAD); |
| 949 | } else { |
| 950 | train_row_sel->SetDisplayedPlane(DP_GROUNDVEHICLE_ROW_NORMAL); |
| 951 | left_sel->SetDisplayedPlane(DP_LEFT_LOAD); |
| 952 | middle_sel->SetDisplayedPlane(DP_MIDDLE_UNLOAD); |
| 953 | right_sel->SetDisplayedPlane(DP_RIGHT_EMPTY); |
| 954 | this->DisableWidget(WID_O_NON_STOP); |
| 955 | this->RaiseWidget(WID_O_NON_STOP); |
no test coverage detected