ship_gui.c
changeset 4930 708801d486c6
parent 4896 f86350aaaaa5
child 4931 c25335d7e99c
equal deleted inserted replaced
4929:5253a78cee3f 4930:708801d486c6
    25 /**
    25 /**
    26  * Draw the purchase info details of a ship at a given location.
    26  * Draw the purchase info details of a ship at a given location.
    27  * @param x,y location where to draw the info
    27  * @param x,y location where to draw the info
    28  * @param engine_number the engine of which to draw the info of
    28  * @param engine_number the engine of which to draw the info of
    29  */
    29  */
    30 void DrawShipPurchaseInfo(int x, int y, EngineID engine_number)
    30 void DrawShipPurchaseInfo(int x, int y, uint w, EngineID engine_number)
    31 {
    31 {
    32 	YearMonthDay ymd;
    32 	YearMonthDay ymd;
    33 	const ShipVehicleInfo *svi = ShipVehInfo(engine_number);
    33 	const ShipVehicleInfo *svi = ShipVehInfo(engine_number);
    34 	const Engine *e;
    34 	const Engine *e;
    35 
    35 
    63 	SetDParam(0, e->reliability * 100 >> 16);
    63 	SetDParam(0, e->reliability * 100 >> 16);
    64 	DrawString(x,y, STR_PURCHASE_INFO_RELIABILITY, 0);
    64 	DrawString(x,y, STR_PURCHASE_INFO_RELIABILITY, 0);
    65 	y += 10;
    65 	y += 10;
    66 
    66 
    67 	/* Additional text from NewGRF */
    67 	/* Additional text from NewGRF */
    68 	// XXX 227 will become a calculated width...
    68 	y += ShowAdditionalText(x, y, w, engine_number);
    69 	y += ShowAdditionalText(x, y, 227, engine_number);
       
    70 }
    69 }
    71 
    70 
    72 void DrawShipImage(const Vehicle *v, int x, int y, VehicleID selection)
    71 void DrawShipImage(const Vehicle *v, int x, int y, VehicleID selection)
    73 {
    72 {
    74 	DrawSprite(GetShipImage(v, DIR_W) | GetVehiclePalette(v), x + 32, y + 10);
    73 	DrawSprite(GetShipImage(v, DIR_W) | GetVehiclePalette(v), x + 32, y + 10);
   282 			}
   281 			}
   283 
   282 
   284 			WP(w,buildvehicle_d).sel_engine = selected_id;
   283 			WP(w,buildvehicle_d).sel_engine = selected_id;
   285 
   284 
   286 			if (selected_id != INVALID_ENGINE) {
   285 			if (selected_id != INVALID_ENGINE) {
   287 				DrawShipPurchaseInfo(2, w->widget[4].top + 1, selected_id);
   286 				const Widget *wi = &w->widget[4];
       
   287 				DrawShipPurchaseInfo(2, wi->top + 1, wi->right - wi->left - 2, selected_id);
   288 			}
   288 			}
   289 			break;
   289 			break;
   290 		}
   290 		}
   291 
   291 
   292 	case WE_CLICK:
   292 	case WE_CLICK: