Changeset - r22425:2a98eaaaa820
[Not reviewed]
master
0 1 0
frosch - 8 years ago 2016-08-15 18:34:31
frosch@openttd.org
(svn r27632) -Feature: When dragging vehicles in group or depot GUI, draw the complete articulated vehicle.
1 file changed with 20 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/vehicle_gui.cpp
Show inline comments
 
@@ -2877,10 +2877,26 @@ void SetMouseCursorVehicle(const Vehicle
 
{
 
	bool rtl = _current_text_dir == TD_RTL;
 

	
 
	_cursor.sprite_count = 1;
 
	_cursor.sprite_seq[0].sprite = v->GetImage(rtl ? DIR_E : DIR_W, EIT_IN_DEPOT);
 
	_cursor.sprite_seq[0].pal = GetVehiclePalette(v);
 
	_cursor.sprite_pos[0].x = v->IsGroundVehicle() ? (16 - v->GetGroundVehicleCache()->cached_veh_length * 2) * (rtl ? -1 : 1) : 0;
 
	_cursor.sprite_count = 0;
 
	int total_width = 0;
 
	for (; v != NULL; v = v->HasArticulatedPart() ? v->GetNextArticulatedPart() : NULL) {
 
		if (_cursor.sprite_count == lengthof(_cursor.sprite_seq)) break;
 
		if (total_width >= 2 * (int)VEHICLEINFO_FULL_VEHICLE_WIDTH) break;
 

	
 
		_cursor.sprite_seq[_cursor.sprite_count].sprite = v->GetImage(rtl ? DIR_E : DIR_W, image_type);
 
		_cursor.sprite_seq[_cursor.sprite_count].pal = GetVehiclePalette(v);
 
		_cursor.sprite_pos[_cursor.sprite_count].x = rtl ? -total_width : total_width;
 
		_cursor.sprite_pos[_cursor.sprite_count].y = 0;
 

	
 
		total_width += GetSingleVehicleWidth(v, image_type);
 
		_cursor.sprite_count++;
 
	}
 

	
 
	int offs = ((int)VEHICLEINFO_FULL_VEHICLE_WIDTH - total_width) / 2;
 
	if (rtl) offs = -offs;
 
	for (uint i = 0; i < _cursor.sprite_count; ++i) {
 
		_cursor.sprite_pos[i].x += offs;
 
	}
 

	
 
	UpdateCursorSize();
 
}
0 comments (0 inline, 0 general)