train_gui.c
changeset 4930 708801d486c6
parent 4912 0f51b47cb983
child 4931 c25335d7e99c
equal deleted inserted replaced
4929:5253a78cee3f 4930:708801d486c6
   233 /**
   233 /**
   234  * Draw the purchase info details of train engine at a given location.
   234  * Draw the purchase info details of train engine at a given location.
   235  * @param x,y location where to draw the info
   235  * @param x,y location where to draw the info
   236  * @param engine_number the engine of which to draw the info of
   236  * @param engine_number the engine of which to draw the info of
   237  */
   237  */
   238 void DrawTrainEnginePurchaseInfo(int x, int y, EngineID engine_number)
   238 void DrawTrainEnginePurchaseInfo(int x, int y, uint w, EngineID engine_number)
   239 {
   239 {
   240 	const RailVehicleInfo *rvi = RailVehInfo(engine_number);
   240 	const RailVehicleInfo *rvi = RailVehInfo(engine_number);
   241 	const Engine *e = GetEngine(engine_number);
   241 	const Engine *e = GetEngine(engine_number);
   242 	int multihead = (rvi->flags&RVI_MULTIHEAD?1:0);
   242 	int multihead = (rvi->flags&RVI_MULTIHEAD?1:0);
   243 	YearMonthDay ymd;
   243 	YearMonthDay ymd;
   290 	SetDParam(0, e->reliability * 100 >> 16);
   290 	SetDParam(0, e->reliability * 100 >> 16);
   291 	DrawString(x,y, STR_PURCHASE_INFO_RELIABILITY, 0);
   291 	DrawString(x,y, STR_PURCHASE_INFO_RELIABILITY, 0);
   292 	y += 10;
   292 	y += 10;
   293 
   293 
   294 	/* Additional text from NewGRF */
   294 	/* Additional text from NewGRF */
   295 	// XXX 227 will become a calculated width...
   295 	y += ShowAdditionalText(x, y, w, engine_number);
   296 	y += ShowAdditionalText(x, y, 227, engine_number);
       
   297 }
   296 }
   298 
   297 
   299 /**
   298 /**
   300  * Draw the purchase info details of a train wagon at a given location.
   299  * Draw the purchase info details of a train wagon at a given location.
   301  * @param x,y location where to draw the info
   300  * @param x,y location where to draw the info
   302  * @param engine_number the engine of which to draw the info of
   301  * @param engine_number the engine of which to draw the info of
   303  */
   302  */
   304 void DrawTrainWagonPurchaseInfo(int x, int y, EngineID engine_number)
   303 void DrawTrainWagonPurchaseInfo(int x, int y, uint w, EngineID engine_number)
   305 {
   304 {
   306 	const RailVehicleInfo *rvi = RailVehInfo(engine_number);
   305 	const RailVehicleInfo *rvi = RailVehInfo(engine_number);
   307 	bool refittable = (EngInfo(engine_number)->refit_mask != 0);
   306 	bool refittable = (EngInfo(engine_number)->refit_mask != 0);
   308 
   307 
   309 	/* Purchase cost */
   308 	/* Purchase cost */
   335 		DrawString(x,y, STR_PURCHASE_INFO_SPEED, 0);
   334 		DrawString(x,y, STR_PURCHASE_INFO_SPEED, 0);
   336 		y += 10;
   335 		y += 10;
   337 	}
   336 	}
   338 
   337 
   339 	/* Additional text from NewGRF */
   338 	/* Additional text from NewGRF */
   340 	y += ShowAdditionalText(x, y, 227, engine_number);
   339 	y += ShowAdditionalText(x, y, w, engine_number);
   341 }
   340 }
   342 
   341 
   343 void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2)
   342 void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2)
   344 {
   343 {
   345 	Vehicle *v, *found;
   344 	Vehicle *v, *found;
   517 		engine_drawing_loop(WP(w, buildvehicle_d).list_b,  WP(w, buildvehicle_d).list_b_length,  x, &y, selected_id, &position, max);
   516 		engine_drawing_loop(WP(w, buildvehicle_d).list_b,  WP(w, buildvehicle_d).list_b_length,  x, &y, selected_id, &position, max);
   518 	}
   517 	}
   519 
   518 
   520 	if (selected_id != INVALID_ENGINE) {
   519 	if (selected_id != INVALID_ENGINE) {
   521 		const RailVehicleInfo *rvi = RailVehInfo(selected_id);
   520 		const RailVehicleInfo *rvi = RailVehInfo(selected_id);
       
   521 		const Widget *wi = &w->widget[BUILD_TRAIN_WIDGET_PANEL];
   522 
   522 
   523 		if (rvi->flags & RVI_WAGON) {
   523 		if (rvi->flags & RVI_WAGON) {
   524 			DrawTrainWagonPurchaseInfo(2, w->widget[BUILD_TRAIN_WIDGET_PANEL].top + 1, selected_id);
   524 			DrawTrainWagonPurchaseInfo(2, wi->top + 1, wi->right - wi->left - 2, selected_id);
   525 		} else {
   525 		} else {
   526 			DrawTrainEnginePurchaseInfo(2, w->widget[BUILD_TRAIN_WIDGET_PANEL].top + 1, selected_id);
   526 			DrawTrainEnginePurchaseInfo(2, wi->top + 1, wi->right - wi->left - 2, selected_id);
   527 		}
   527 		}
   528 	}
   528 	}
   529 	DrawString(85, 15, _engine_sort_listing[WP(w,buildvehicle_d).sort_criteria], 0x10);
   529 	DrawString(85, 15, _engine_sort_listing[WP(w,buildvehicle_d).sort_criteria], 0x10);
   530 	DoDrawString(WP(w,buildvehicle_d).decenting_sort_order ? DOWNARROW : UPARROW, 69, 15, 0x10);
   530 	DoDrawString(WP(w,buildvehicle_d).decenting_sort_order ? DOWNARROW : UPARROW, 69, 15, 0x10);
   531 }
   531 }