File diff r16430:b3f65f9bc976 → r16431:ec558deca9d7
src/train_gui.cpp
Show inline comments
 
@@ -46,25 +46,25 @@ void CcBuildWagon(const CommandCost &res
 
	}
 
}
 

	
 
/**
 
 * Highlight the position where a rail vehicle is dragged over by drawing a light gray background.
 
 * @param px        The current x position to draw from.
 
 * @param max_width The maximum space available to draw.
 
 * @param selection Selected vehicle that is dragged.
 
 * @return The width of the highlight mark.
 
 */
 
static int HighlightDragPosition(int px, int max_width, VehicleID selection)
 
{
 
	bool rtl = _dynlang.text_dir == TD_RTL;
 
	bool rtl = _current_text_dir == TD_RTL;
 

	
 
	assert(selection != INVALID_VEHICLE);
 
	Point offset;
 
	int dragged_width = Train::Get(selection)->GetDisplayImageWidth(&offset) + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
 

	
 
	int drag_hlight_left = rtl ? max(px -dragged_width, 0) : px;
 
	int drag_hlight_right = rtl ? px : min(px + dragged_width, max_width);
 
	int drag_hlight_width = max(drag_hlight_right - drag_hlight_left, 0);
 

	
 
	if (drag_hlight_width > 0) {
 
		GfxFillRect(drag_hlight_left + WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP + 1,
 
				drag_hlight_right - WD_FRAMERECT_RIGHT, 13 - WD_FRAMERECT_BOTTOM, _colour_gradient[COLOUR_GREY][7]);
 
@@ -76,25 +76,25 @@ static int HighlightDragPosition(int px,
 
/**
 
 * Draws an image of a whole train
 
 * @param v         Front vehicle
 
 * @param left      The minimum horizontal position
 
 * @param right     The maximum horizontal position
 
 * @param y         Vertical position to draw at
 
 * @param selection Selected vehicle to draw a frame around
 
 * @param skip      Number of pixels to skip at the front (for scrolling)
 
 * @param drag_dest The vehicle another one is dragged over, \c INVALID_VEHICLE if none.
 
 */
 
void DrawTrainImage(const Train *v, int left, int right, int y, VehicleID selection, int skip, VehicleID drag_dest)
 
{
 
	bool rtl = _dynlang.text_dir == TD_RTL;
 
	bool rtl = _current_text_dir == TD_RTL;
 
	Direction dir = rtl ? DIR_E : DIR_W;
 

	
 
	DrawPixelInfo tmp_dpi, *old_dpi;
 
	/* Position of highlight box */
 
	int highlight_l = 0;
 
	int highlight_r = 0;
 
	int max_width = right - left + 1;
 

	
 
	if (!FillDrawPixelInfo(&tmp_dpi, left, y, max_width, 14)) return;
 

	
 
	old_dpi = _cur_dpi;
 
	_cur_dpi = &tmp_dpi;
 
@@ -326,25 +326,25 @@ int GetTrainDetailsWndVScroll(VehicleID 
 
 * @param v     current vehicle
 
 * @param left  The left most coordinate to draw
 
 * @param right The right most coordinate to draw
 
 * @param y     The y coordinate
 
 * @param vscroll_pos Position of scrollbar
 
 * @param vscroll_cap Number of lines currently displayed
 
 * @param det_tab Selected details tab
 
 */
 
void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_pos, uint16 vscroll_cap, TrainDetailsWindowTabs det_tab)
 
{
 
	/* draw the first 3 details tabs */
 
	if (det_tab != TDW_TAB_TOTALS) {
 
		bool rtl = _dynlang.text_dir == TD_RTL;
 
		bool rtl = _current_text_dir == TD_RTL;
 
		Direction dir = rtl ? DIR_E : DIR_W;
 
		int x = rtl ? right : left;
 
		int sprite_y_offset = 4 + (FONT_HEIGHT_NORMAL - 10) / 2;
 
		int line_height = WD_MATRIX_TOP + FONT_HEIGHT_NORMAL + WD_MATRIX_BOTTOM;
 
		for (; v != NULL && vscroll_pos > -vscroll_cap; v = v->GetNextVehicle()) {
 
			GetCargoSummaryOfArticulatedVehicle(v, &_cargo_summary);
 

	
 
			/* Draw sprites */
 
			uint dx = 0;
 
			int px = x;
 
			const Train *u = v;
 
			do {