Changeset - r12364:cbc66d4e5c75
[Not reviewed]
master
0 5 0
frosch - 15 years ago 2009-07-12 16:00:11
frosch@openttd.org
(svn r16799) -Codechange: When drawing articulated road vehicles in the vehicle details window, draw as many parts as the window fits instead of always up to a vehicle length of 80/8.
5 files changed with 40 insertions and 17 deletions:
0 comments (0 inline, 0 general)
src/depot_gui.cpp
Show inline comments
 
@@ -276,7 +276,7 @@ struct DepotWindow : Window {
 
				DrawString(this->widget[DEPOT_WIDGET_MATRIX].left, this->widget[DEPOT_WIDGET_MATRIX].right - 1, y + 4, STR_TINY_BLACK, TC_FROMSTRING, SA_RIGHT); // Draw the counter
 
				break;
 

	
 
			case VEH_ROAD:     DrawRoadVehImage( v, x + 24, sprite_y, this->sel, 1); break;
 
			case VEH_ROAD:     DrawRoadVehImage( v, x + 24, sprite_y, this->sel, 28); break;
 
			case VEH_SHIP:     DrawShipImage(    v, x + 19, sprite_y - 1, this->sel); break;
 
			case VEH_AIRCRAFT: {
 
				const Sprite *spr = GetSprite(v->GetImage(DIR_W), ST_NORMAL);
src/roadveh_gui.cpp
Show inline comments
 
@@ -120,12 +120,17 @@ static inline int RoadVehLengthToPixels(
 
	return (length * 28) / 8;
 
}
 

	
 
void DrawRoadVehImage(const Vehicle *v, int x, int y, VehicleID selection, int count)
 
/**
 
 * Draws an image of a road vehicle chain
 
 * @param v Front vehicle
 
 + @param x x Position to start at
 
 * @param y y Position to draw at
 
 * @param seletion Selected vehicle to draw a border around
 
 * @param max_width Number of pixels space for drawing
 
 */
 
void DrawRoadVehImage(const Vehicle *v, int x, int y, VehicleID selection, int max_width)
 
{
 
	/* Road vehicle lengths are measured in eighths of the standard length, so
 
	 * count is the number of standard vehicles that should be drawn. If it is
 
	 * 0, we draw enough vehicles for 10 standard vehicle lengths. */
 
	int max_length = (count == 0) ? 80 : count * 8;
 
	int max_length = max_width / 28;
 

	
 
	/* Width of highlight box */
 
	int highlight_w = 0;
src/train_gui.cpp
Show inline comments
 
@@ -64,7 +64,16 @@ int WagonLengthToPixels(int len)
 
	return (len * _traininfo_vehicle_width) / 8;
 
}
 

	
 
void DrawTrainImage(const Vehicle *v, int x, int y, VehicleID selection, int count, int skip)
 
/**
 
 * Draws an image of a whole train
 
 * @param v Front vehicle
 
 + @param x x Position to start at
 
 * @param y y Position to draw at
 
 * @param seletion Selected vehicle to draw a frame around
 
 * @param max_width Number of pixels space for drawing
 
 * @param skip Number of pixels to skip at the front (for scrolling)
 
 */
 
void DrawTrainImage(const Vehicle *v, int x, int y, VehicleID selection, int max_width, int skip)
 
{
 
	DrawPixelInfo tmp_dpi, *old_dpi;
 
	int dx = -(skip * 8) / _traininfo_vehicle_width;
 
@@ -72,9 +81,9 @@ void DrawTrainImage(const Vehicle *v, in
 
	int highlight_l = 0;
 
	int highlight_r = 0;
 

	
 
	if (!FillDrawPixelInfo(&tmp_dpi, x - 2, y - 1, count + 1, 14)) return;
 
	if (!FillDrawPixelInfo(&tmp_dpi, x - 2, y - 1, max_width + 1, 14)) return;
 

	
 
	count = (count * 8) / _traininfo_vehicle_width;
 
	int count = (max_width * 8) / _traininfo_vehicle_width;
 

	
 
	old_dpi = _cur_dpi;
 
	_cur_dpi = &tmp_dpi;
src/vehicle_gui.cpp
Show inline comments
 
@@ -798,13 +798,22 @@ static void DrawSmallOrderList(const Veh
 
	}
 
}
 

	
 
static void DrawVehicleImage(const Vehicle *v, int x, int y, VehicleID selection, int count, int skip)
 
/**
 
 * Draws an image of a vehicle chain
 
 * @param v Front vehicle
 
 + @param x x Position to start at
 
 * @param y y Position to draw at
 
 * @param seletion Selected vehicle to draw a frame around
 
 * @param max_width Number of pixels space for drawing
 
 * @param skip Number of pixels to skip at the front (for scrolling)
 
 */
 
static void DrawVehicleImage(const Vehicle *v, int x, int y, VehicleID selection, int max_width, int skip)
 
{
 
	switch (v->type) {
 
		case VEH_TRAIN:    DrawTrainImage(v, x, y, selection, count, skip); break;
 
		case VEH_ROAD:     DrawRoadVehImage(v, x, y, selection, count);     break;
 
		case VEH_SHIP:     DrawShipImage(v, x, y, selection);               break;
 
		case VEH_AIRCRAFT: DrawAircraftImage(v, x, y, selection);           break;
 
		case VEH_TRAIN:    DrawTrainImage(v, x, y, selection, max_width, skip); break;
 
		case VEH_ROAD:     DrawRoadVehImage(v, x, y, selection, max_width);     break;
 
		case VEH_SHIP:     DrawShipImage(v, x, y, selection);                   break;
 
		case VEH_AIRCRAFT: DrawAircraftImage(v, x, y, selection);               break;
 
		default: NOT_REACHED();
 
	}
 
}
 
@@ -1517,7 +1526,7 @@ struct VehicleDetailsWindow : Window {
 
			case VEH_ROAD:
 
			case VEH_SHIP:
 
			case VEH_AIRCRAFT:
 
				DrawVehicleImage(v, matrix->left + 3, matrix->top + 1, INVALID_VEHICLE, 0, 0);
 
				DrawVehicleImage(v, matrix->left + 3, matrix->top + 1, INVALID_VEHICLE, matrix->right - matrix->left - 5, 0);
 
				DrawVehicleDetails(v, matrix->left + 75, matrix->right - 2, matrix->top + 1, this->vscroll.pos, this->vscroll.cap, det_tab);
 
				break;
 

	
src/vehicle_gui.h
Show inline comments
 
@@ -61,8 +61,8 @@ static inline bool ValidVLWFlags(uint16 
 

	
 
int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number);
 

	
 
void DrawTrainImage(const Vehicle *v, int x, int y, VehicleID selection, int count, int skip);
 
void DrawRoadVehImage(const Vehicle *v, int x, int y, VehicleID selection, int count);
 
void DrawTrainImage(const Vehicle *v, int x, int y, VehicleID selection, int max_width, int skip);
 
void DrawRoadVehImage(const Vehicle *v, int x, int y, VehicleID selection, int max_width);
 
void DrawShipImage(const Vehicle *v, int x, int y, VehicleID selection);
 
void DrawAircraftImage(const Vehicle *v, int x, int y, VehicleID selection);
 

	
0 comments (0 inline, 0 general)