Changeset - r16824:4f7bd5624348
[Not reviewed]
master
0 1 0
terkhen - 14 years ago 2010-12-21 14:00:14
terkhen@openttd.org
(svn r21568) -Add: Show the selected consist part at the refit window.
1 file changed with 63 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/vehicle_gui.cpp
Show inline comments
 
@@ -614,6 +614,55 @@ struct RefitWindow : public Window {
 
				DrawVehicleImage(v, this->sprite_left + WD_FRAMERECT_LEFT, this->sprite_right - WD_FRAMERECT_RIGHT,
 
					r.top + WD_FRAMERECT_TOP, INVALID_VEHICLE, this->hscroll != NULL ? this->hscroll->GetPosition() : 0);
 

	
 
				/* Highlight selected vehicles. */
 
				int x = 0;
 
				switch (v->type) {
 
					case VEH_TRAIN: {
 
						VehicleSet vehicles_to_refit;
 
						GetVehicleSet(vehicles_to_refit, Vehicle::Get(this->selected_vehicle), this->num_vehicles);
 

	
 
						int left = INT32_MIN;
 
						int width = 0;
 

	
 
						for (Train *u = Train::From(v); u != NULL; u = u->Next()) {
 
							/* Start checking. */
 
							if (vehicles_to_refit.Contains(u->index) && left == INT32_MIN) {
 
								left = x - this->hscroll->GetPosition() + r.left + this->vehicle_margin;
 
								width = 0;
 
							}
 

	
 
							/* Draw a selection. */
 
							if ((!vehicles_to_refit.Contains(u->index) || u->Next() == NULL) && left != INT32_MIN) {
 
								if (u->Next() == NULL && vehicles_to_refit.Contains(u->index)) {
 
									int current_width = u->GetDisplayImageWidth();
 
									width += current_width;
 
									x += current_width;
 
								}
 

	
 
								int right = Clamp(left + width, 0, r.right);
 
								left = max(0, left);
 

	
 
								if (_current_text_dir == TD_RTL) {
 
									right = this->GetWidget<NWidgetCore>(VRW_VEHICLE_PANEL_DISPLAY)->current_x - left;
 
									left = right - width;
 
								}
 

	
 
								if (left != right) {
 
									DrawFrameRect(left, r.top + WD_FRAMERECT_TOP, right, r.top + WD_FRAMERECT_TOP + 13, COLOUR_WHITE, FR_BORDERONLY);
 
								}
 

	
 
								left = INT32_MIN;
 
							}
 

	
 
							int current_width = u->GetDisplayImageWidth();
 
							width += current_width;
 
							x += current_width;
 
						}
 
						break;
 
					}
 

	
 
					default: break;
 
				}
 
				break;
 
			}
 

	
 
@@ -737,6 +786,7 @@ struct RefitWindow : public Window {
 
				NWidgetBase *nwi = this->GetWidget<NWidgetBase>(VRW_VEHICLE_PANEL_DISPLAY);
 
				this->click_x = GetClickPosition(pt.x - nwi->pos_x);
 
				this->SetSelectedVehicles(pt.x - nwi->pos_x);
 
				this->SetWidgetDirty(VRW_VEHICLE_PANEL_DISPLAY);
 
				SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, HT_DRAG, this);
 
				break;
 
			}
 
@@ -765,6 +815,19 @@ struct RefitWindow : public Window {
 
		}
 
	}
 

	
 
	virtual void OnMouseDrag(Point pt, int widget)
 
	{
 
		switch (widget) {
 
			case VRW_VEHICLE_PANEL_DISPLAY: { // Vehicle image.
 
				if (this->order != INVALID_VEH_ORDER_ID) break;
 
				NWidgetBase *nwi = this->GetWidget<NWidgetBase>(VRW_VEHICLE_PANEL_DISPLAY);
 
				this->SetSelectedVehicles(pt.x - nwi->pos_x);
 
				this->SetWidgetDirty(VRW_VEHICLE_PANEL_DISPLAY);
 
				break;
 
			}
 
		}
 
	}
 

	
 
	virtual void OnDragDrop(Point pt, int widget)
 
	{
 
		switch (widget) {
0 comments (0 inline, 0 general)