File diff r14398:461a80e5f996 → r14399:3f819c0da60a
src/depot_gui.cpp
Show inline comments
 
@@ -666,97 +666,97 @@ struct DepotWindow : Window {
 
	virtual void OnInvalidateData(int data)
 
	{
 
		this->generate_list = true;
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		if (this->generate_list) {
 
			/* Generate the vehicle list
 
			 * It's ok to use the wagon pointers for non-trains as they will be ignored */
 
			BuildDepotVehicleList(this->type, this->window_number, &this->vehicle_list, &this->wagon_list);
 
			this->generate_list = false;
 
			DepotSortList(&this->vehicle_list);
 
		}
 

	
 
		/* determine amount of items for scroller */
 
		if (this->type == VEH_TRAIN) {
 
			uint max_width = VEHICLEINFO_FULL_VEHICLE_WIDTH;
 
			for (uint num = 0; num < this->vehicle_list.Length(); num++) {
 
				uint width = 0;
 
				for (const Train *v = Train::From(this->vehicle_list[num]); v != NULL; v = v->Next()) {
 
					width += v->GetDisplayImageWidth();
 
				}
 
				max_width = max(max_width, width);
 
			}
 
			/* Always have 1 empty row, so people can change the setting of the train */
 
			this->vscroll.SetCount(this->vehicle_list.Length() + this->wagon_list.Length() + 1);
 
			this->hscroll.SetCount(max_width);
 
		} else {
 
			this->vscroll.SetCount((this->vehicle_list.Length() + this->hscroll.GetCapacity() - 1) / this->hscroll.GetCapacity());
 
		}
 

	
 
		/* Setup disabled buttons. */
 
		TileIndex tile = this->window_number;
 
		this->SetWidgetsDisabledState(!IsTileOwner(tile, _local_company),
 
			DEPOT_WIDGET_STOP_ALL,
 
			DEPOT_WIDGET_START_ALL,
 
			DEPOT_WIDGET_SELL,
 
			DEPOT_WIDGET_SELL_CHAIN,
 
			DEPOT_WIDGET_SELL_ALL,
 
			DEPOT_WIDGET_BUILD,
 
			DEPOT_WIDGET_CLONE,
 
			DEPOT_WIDGET_AUTOREPLACE,
 
			WIDGET_LIST_END);
 

	
 
		this->DrawWidgets();
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget)
 
	virtual void OnClick(Point pt, int widget, int click_count)
 
	{
 
		switch (widget) {
 
			case DEPOT_WIDGET_MATRIX: { // List
 
				NWidgetBase *nwi = this->GetWidget<NWidgetBase>(DEPOT_WIDGET_MATRIX);
 
				this->DepotClick(pt.x - nwi->pos_x, pt.y - nwi->pos_y);
 
				break;
 
			}
 

	
 
			case DEPOT_WIDGET_BUILD: // Build vehicle
 
				ResetObjectToPlace();
 
				ShowBuildVehicleWindow(this->window_number, this->type);
 
				break;
 

	
 
			case DEPOT_WIDGET_CLONE: // Clone button
 
				this->SetWidgetDirty(DEPOT_WIDGET_CLONE);
 
				this->ToggleWidgetLoweredState(DEPOT_WIDGET_CLONE);
 

	
 
				if (this->IsWidgetLowered(DEPOT_WIDGET_CLONE)) {
 
					static const CursorID clone_icons[] = {
 
						SPR_CURSOR_CLONE_TRAIN, SPR_CURSOR_CLONE_ROADVEH,
 
						SPR_CURSOR_CLONE_SHIP, SPR_CURSOR_CLONE_AIRPLANE
 
					};
 

	
 
					_place_clicked_vehicle = NULL;
 
					SetObjectToPlaceWnd(clone_icons[this->type], PAL_NONE, HT_RECT, this);
 
				} else {
 
					ResetObjectToPlace();
 
				}
 
					break;
 

	
 
			case DEPOT_WIDGET_LOCATION:
 
				if (_ctrl_pressed) {
 
					ShowExtraViewPortWindow(this->window_number);
 
				} else {
 
					ScrollMainWindowToTile(this->window_number);
 
				}
 
				break;
 

	
 
			case DEPOT_WIDGET_STOP_ALL:
 
			case DEPOT_WIDGET_START_ALL:
 
				DoCommandP(this->window_number, 0, this->type | (widget == DEPOT_WIDGET_START_ALL ? (1 << 5) : 0), CMD_MASS_START_STOP);
 
				break;
 

	
 
			case DEPOT_WIDGET_SELL_ALL:
 
				/* Only open the confimation window if there are anything to sell */
 
				if (this->vehicle_list.Length() != 0 || this->wagon_list.Length() != 0) {
 
					TileIndex tile = this->window_number;
 
					byte vehtype = this->type;