src/build_vehicle_gui.cpp
changeset 9027 b28d0b8809ad
parent 8962 1b263c69799d
child 9070 dd0121143eba
equal deleted inserted replaced
9026:690846c6ee99 9027:b28d0b8809ad
   933  * @param x,y Where should the list start
   933  * @param x,y Where should the list start
   934  * @param eng_list What engines to draw
   934  * @param eng_list What engines to draw
   935  * @param min where to start in the list
   935  * @param min where to start in the list
   936  * @param max where in the list to end
   936  * @param max where in the list to end
   937  * @param selected_id what engine to highlight as selected, if any
   937  * @param selected_id what engine to highlight as selected, if any
   938  * @param show_count Display the number of vehicles (used by autoreplace)
   938  * @param count_location Offset to print the engine count (used by autoreplace). 0 means it's off
   939  */
   939  */
   940 void DrawEngineList(VehicleType type, int x, int y, const EngineList eng_list, uint16 min, uint16 max, EngineID selected_id, bool show_count, GroupID selected_group)
   940 void DrawEngineList(VehicleType type, int x, int y, const EngineList eng_list, uint16 min, uint16 max, EngineID selected_id, int count_location, GroupID selected_group)
   941 {
   941 {
   942 	byte step_size = GetVehicleListHeight(type);
   942 	byte step_size = GetVehicleListHeight(type);
   943 	byte x_offset = 0;
   943 	byte x_offset = 0;
   944 	byte y_offset = 0;
   944 	byte y_offset = 0;
   945 
   945 
   975 		/* Note: num_engines is only used in the autoreplace GUI, so it is correct to use _local_player here. */
   975 		/* Note: num_engines is only used in the autoreplace GUI, so it is correct to use _local_player here. */
   976 		const uint num_engines = GetGroupNumEngines(_local_player, selected_group, engine);
   976 		const uint num_engines = GetGroupNumEngines(_local_player, selected_group, engine);
   977 
   977 
   978 		SetDParam(0, engine);
   978 		SetDParam(0, engine);
   979 		DrawString(x + x_offset, y, STR_ENGINE_NAME, engine == selected_id ? TC_WHITE : TC_BLACK);
   979 		DrawString(x + x_offset, y, STR_ENGINE_NAME, engine == selected_id ? TC_WHITE : TC_BLACK);
   980 		DrawVehicleEngine(type, x, y + y_offset, engine, (show_count && num_engines == 0) ? PALETTE_CRASH : GetEnginePalette(engine, _local_player));
   980 		DrawVehicleEngine(type, x, y + y_offset, engine, (count_location != 0 && num_engines == 0) ? PALETTE_CRASH : GetEnginePalette(engine, _local_player));
   981 		if (show_count) {
   981 		if (count_location != 0) {
   982 			SetDParam(0, num_engines);
   982 			SetDParam(0, num_engines);
   983 			DrawStringRightAligned(213, y + (GetVehicleListHeight(type) == 14 ? 3 : 8), STR_TINY_BLACK, TC_FROMSTRING);
   983 			DrawStringRightAligned(count_location, y + (GetVehicleListHeight(type) == 14 ? 3 : 8), STR_TINY_BLACK, TC_FROMSTRING);
   984 		}
   984 		}
   985 	}
   985 	}
   986 }
   986 }
   987 
   987 
   988 static void DrawBuildVehicleWindow(Window *w)
   988 static void DrawBuildVehicleWindow(Window *w)
   998 	/* Set text of sort by dropdown */
   998 	/* Set text of sort by dropdown */
   999 	w->widget[BUILD_VEHICLE_WIDGET_SORT_DROPDOWN].data = _sort_listing[bv->vehicle_type][bv->sort_criteria];
   999 	w->widget[BUILD_VEHICLE_WIDGET_SORT_DROPDOWN].data = _sort_listing[bv->vehicle_type][bv->sort_criteria];
  1000 
  1000 
  1001 	DrawWindowWidgets(w);
  1001 	DrawWindowWidgets(w);
  1002 
  1002 
  1003 	DrawEngineList(bv->vehicle_type, w->widget[BUILD_VEHICLE_WIDGET_LIST].left + 2, w->widget[BUILD_VEHICLE_WIDGET_LIST].top + 1, bv->eng_list, w->vscroll.pos, max, bv->sel_engine, false, DEFAULT_GROUP);
  1003 	DrawEngineList(bv->vehicle_type, w->widget[BUILD_VEHICLE_WIDGET_LIST].left + 2, w->widget[BUILD_VEHICLE_WIDGET_LIST].top + 1, bv->eng_list, w->vscroll.pos, max, bv->sel_engine, 0, DEFAULT_GROUP);
  1004 
  1004 
  1005 	if (bv->sel_engine != INVALID_ENGINE) {
  1005 	if (bv->sel_engine != INVALID_ENGINE) {
  1006 		const Widget *wi = &w->widget[BUILD_VEHICLE_WIDGET_PANEL];
  1006 		const Widget *wi = &w->widget[BUILD_VEHICLE_WIDGET_PANEL];
  1007 		int text_end = DrawVehiclePurchaseInfo(2, wi->top + 1, wi->right - wi->left - 2, bv->sel_engine);
  1007 		int text_end = DrawVehiclePurchaseInfo(2, wi->top + 1, wi->right - wi->left - 2, bv->sel_engine);
  1008 
  1008