1
0
Fork 0

(svn r25459) -Fix: Disable the depot-refit button in the order GUI, if the consist is not refittable.

release/1.4
frosch 2013-06-24 21:02:26 +00:00
parent 58ae2d5aeb
commit e158383118
1 changed files with 8 additions and 2 deletions

View File

@ -28,6 +28,7 @@
#include "core/geometry_func.hpp" #include "core/geometry_func.hpp"
#include "hotkeys.h" #include "hotkeys.h"
#include "aircraft.h" #include "aircraft.h"
#include "engine_func.h"
#include "widgets/order_widget.h" #include "widgets/order_widget.h"
@ -533,6 +534,7 @@ private:
OrderPlaceObjectState goto_type; OrderPlaceObjectState goto_type;
const Vehicle *vehicle; ///< Vehicle owning the orders being displayed and manipulated. const Vehicle *vehicle; ///< Vehicle owning the orders being displayed and manipulated.
Scrollbar *vscroll; Scrollbar *vscroll;
bool can_do_refit; ///< Vehicle chain can be refitted in depot.
bool can_do_autorefit; ///< Vehicle chain can be auto-refitted. bool can_do_autorefit; ///< Vehicle chain can be auto-refitted.
/** /**
@ -794,8 +796,10 @@ private:
/** Cache auto-refittability of the vehicle chain. */ /** Cache auto-refittability of the vehicle chain. */
void UpdateAutoRefitState() void UpdateAutoRefitState()
{ {
this->can_do_refit = false;
this->can_do_autorefit = false; this->can_do_autorefit = false;
for (const Vehicle *w = this->vehicle; w != NULL; w = w->IsGroundVehicle() ? w->Next() : NULL) { for (const Vehicle *w = this->vehicle; w != NULL; w = w->IsGroundVehicle() ? w->Next() : NULL) {
if (IsEngineRefittable(w->engine_type)) this->can_do_refit = true;
if (HasBit(Engine::Get(w->engine_type)->info.misc_flags, EF_AUTO_REFIT)) this->can_do_autorefit = true; if (HasBit(Engine::Get(w->engine_type)->info.misc_flags, EF_AUTO_REFIT)) this->can_do_autorefit = true;
} }
} }
@ -1026,7 +1030,7 @@ public:
* Also enable the button if a refit is already set to allow clearing it. */ * Also enable the button if a refit is already set to allow clearing it. */
this->SetWidgetDisabledState(WID_O_REFIT_DROPDOWN, this->SetWidgetDisabledState(WID_O_REFIT_DROPDOWN,
order->GetLoadType() == OLFB_NO_LOAD || (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) || order->GetLoadType() == OLFB_NO_LOAD || (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) ||
(!this->can_do_autorefit && !order->IsRefit())); ((!this->can_do_refit || !this->can_do_autorefit) && !order->IsRefit()));
break; break;
@ -1059,7 +1063,9 @@ public:
} }
/* Disable refit button if the order is no 'always go' order. /* Disable refit button if the order is no 'always go' order.
* However, keep the service button enabled for refit-orders to allow clearing refits (without knowing about ctrl). */ * However, keep the service button enabled for refit-orders to allow clearing refits (without knowing about ctrl). */
this->SetWidgetDisabledState(WID_O_REFIT, (order->GetDepotOrderType() & ODTFB_SERVICE) || (order->GetDepotActionType() & ODATFB_HALT)); this->SetWidgetDisabledState(WID_O_REFIT,
(order->GetDepotOrderType() & ODTFB_SERVICE) || (order->GetDepotActionType() & ODATFB_HALT) ||
(!this->can_do_refit && !order->IsRefit()));
this->SetWidgetLoweredState(WID_O_SERVICE, order->GetDepotOrderType() & ODTFB_SERVICE); this->SetWidgetLoweredState(WID_O_SERVICE, order->GetDepotOrderType() & ODTFB_SERVICE);
break; break;