Changeset - r22258:44facb9494b3
[Not reviewed]
master
0 1 0
frosch - 9 years ago 2015-11-14 22:54:52
frosch@openttd.org
(svn r27446) -Feature: Lower the sell-vehicle button in the depot GUI while dragging a vehicle over it. (Eearslya)
1 file changed with 18 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/depot_gui.cpp
Show inline comments
 
@@ -226,12 +226,13 @@ const Sprite *GetAircraftSprite(EngineID
 

	
 
struct DepotWindow : Window {
 
	VehicleID sel;
 
	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;
 
	uint num_columns;       ///< Number of columns.
 
	Scrollbar *hscroll;     ///< Only for trains.
 
	Scrollbar *vscroll;
 
@@ -240,12 +241,13 @@ struct DepotWindow : Window {
 
	{
 
		assert(IsCompanyBuildableVehicleType(type)); // ensure that we make the call with a valid type
 

	
 
		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;
 

	
 
		this->CreateNestedTree();
 
		this->hscroll = (this->type == VEH_TRAIN ? this->GetScrollbar(WID_D_H_SCROLL) : NULL);
 
@@ -864,17 +866,30 @@ struct DepotWindow : Window {
 
		this->SetWidgetDirty(WID_D_CLONE);
 

	
 
		/* abort drag & drop */
 
		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.
 
			if (this->vehicle_over != INVALID_VEHICLE) {
 
				this->vehicle_over = INVALID_VEHICLE;
 
				this->SetWidgetDirty(WID_D_MATRIX);
 
@@ -955,13 +970,15 @@ struct DepotWindow : Window {
 
				break;
 
			}
 

	
 
			default:
 
				this->sel = INVALID_VEHICLE;
 
				this->SetDirty();
 
				break;
 
		}
 
		this->sell_hovered = false;
 
		_cursor.vehchain = false;
 
	}
 

	
 
	virtual void OnTimeout()
 
	{
 
		if (!this->IsWidgetDisabled(WID_D_SELL)) {
0 comments (0 inline, 0 general)