diff options
author | frosch <frosch@openttd.org> | 2015-11-14 22:54:52 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2015-11-14 22:54:52 +0000 |
commit | f6891ac30e0607eb4d229295a4696aba1b0b5388 (patch) | |
tree | 47bba2dab008b8a6fa6f0236b94ad55cdaa51cb5 | |
parent | d933d35354075045fb166170f44c19e741fc8bac (diff) | |
download | openttd-f6891ac30e0607eb4d229295a4696aba1b0b5388.tar.xz |
(svn r27446) -Feature: Lower the sell-vehicle button in the depot GUI while dragging a vehicle over it. (Eearslya)
-rw-r--r-- | src/depot_gui.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index fe75708dd..1045f15bd 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -229,6 +229,7 @@ struct DepotWindow : Window { VehicleID vehicle_over; ///< Rail vehicle over which another one is dragged, \c INVALID_VEHICLE if none. VehicleType type; bool generate_list; + bool sell_hovered; ///< A vehicle is being dragged/hovered over the sell button. VehicleList vehicle_list; VehicleList wagon_list; uint unitnumber_digits; @@ -243,6 +244,7 @@ struct DepotWindow : Window { this->sel = INVALID_VEHICLE; this->vehicle_over = INVALID_VEHICLE; this->generate_list = true; + this->sell_hovered = false; this->type = type; this->num_columns = 1; // for non-trains this gets set in FinishInitNested() this->unitnumber_digits = 2; @@ -867,11 +869,24 @@ struct DepotWindow : Window { this->sel = INVALID_VEHICLE; this->vehicle_over = INVALID_VEHICLE; this->SetWidgetDirty(WID_D_MATRIX); + + if (this->sell_hovered) { + this->SetWidgetLoweredState(WID_D_SELL, false); + this->SetWidgetDirty(WID_D_SELL); + this->sell_hovered = false; + } } virtual void OnMouseDrag(Point pt, int widget) { - if (this->type != VEH_TRAIN || this->sel == INVALID_VEHICLE) return; + if (this->sel == INVALID_VEHICLE) return; + bool is_sell_widget = widget == WID_D_SELL; + if (is_sell_widget != this->sell_hovered) { + this->sell_hovered = is_sell_widget; + this->SetWidgetLoweredState(WID_D_SELL, is_sell_widget); + this->SetWidgetDirty(WID_D_SELL); + } + if (this->type != VEH_TRAIN) return; /* A rail vehicle is dragged.. */ if (widget != WID_D_MATRIX) { // ..outside of the depot matrix. @@ -958,7 +973,9 @@ struct DepotWindow : Window { default: this->sel = INVALID_VEHICLE; this->SetDirty(); + break; } + this->sell_hovered = false; _cursor.vehchain = false; } |