summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2013-06-24 21:02:26 +0000
committerfrosch <frosch@openttd.org>2013-06-24 21:02:26 +0000
commite1583831186679de1197175522a8bd56de4dffa4 (patch)
treefd2d9721599efcf6b1e8b71565368fc0ef38825f
parent58ae2d5aebc1b7a9ee067c30744ca3f076b61572 (diff)
downloadopenttd-e1583831186679de1197175522a8bd56de4dffa4.tar.xz
(svn r25459) -Fix: Disable the depot-refit button in the order GUI, if the consist is not refittable.
-rw-r--r--src/order_gui.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/order_gui.cpp b/src/order_gui.cpp
index ebf143ee8..8f0ef7a2c 100644
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -28,6 +28,7 @@
#include "core/geometry_func.hpp"
#include "hotkeys.h"
#include "aircraft.h"
+#include "engine_func.h"
#include "widgets/order_widget.h"
@@ -533,6 +534,7 @@ private:
OrderPlaceObjectState goto_type;
const Vehicle *vehicle; ///< Vehicle owning the orders being displayed and manipulated.
Scrollbar *vscroll;
+ bool can_do_refit; ///< Vehicle chain can be refitted in depot.
bool can_do_autorefit; ///< Vehicle chain can be auto-refitted.
/**
@@ -794,8 +796,10 @@ private:
/** Cache auto-refittability of the vehicle chain. */
void UpdateAutoRefitState()
{
+ this->can_do_refit = false;
this->can_do_autorefit = false;
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;
}
}
@@ -1026,7 +1030,7 @@ public:
* Also enable the button if a refit is already set to allow clearing it. */
this->SetWidgetDisabledState(WID_O_REFIT_DROPDOWN,
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;
@@ -1059,7 +1063,9 @@ public:
}
/* 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). */
- 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);
break;