|
@@ -821,49 +821,49 @@ int DrawVehiclePurchaseInfo(int left, in
|
|
|
|
|
|
/**
|
|
|
* Engine drawing loop
|
|
|
* @param type Type of vehicle (VEH_*)
|
|
|
* @param l The left most location of the list
|
|
|
* @param r The right most location of the list
|
|
|
* @param y The top most location of the list
|
|
|
* @param eng_list What engines to draw
|
|
|
* @param min where to start in the list
|
|
|
* @param max where in the list to end
|
|
|
* @param selected_id what engine to highlight as selected, if any
|
|
|
* @param show_count Whether to show the amount of engines or not
|
|
|
* @param selected_group the group to list the engines of
|
|
|
*/
|
|
|
void DrawEngineList(VehicleType type, int l, int r, int y, const GUIEngineList *eng_list, uint16 min, uint16 max, EngineID selected_id, bool show_count, GroupID selected_group)
|
|
|
{
|
|
|
static const int sprite_widths[] = { 60, 60, 76, 67 };
|
|
|
static const int sprite_y_offsets[] = { -1, -1, -2, -2 };
|
|
|
|
|
|
/* Obligatory sanity checks! */
|
|
|
assert((uint)type < lengthof(sprite_widths));
|
|
|
assert_compile(lengthof(sprite_y_offsets) == lengthof(sprite_widths));
|
|
|
assert(max <= eng_list->Length());
|
|
|
|
|
|
bool rtl = _dynlang.text_dir == TD_RTL;
|
|
|
bool rtl = _current_text_dir == TD_RTL;
|
|
|
int step_size = GetEngineListHeight(type);
|
|
|
int sprite_width = sprite_widths[type];
|
|
|
|
|
|
int sprite_x = (rtl ? r - sprite_width / 2 : l + sprite_width / 2) - 1;
|
|
|
int sprite_y_offset = sprite_y_offsets[type] + step_size / 2;
|
|
|
|
|
|
int text_left = l + (rtl ? WD_FRAMERECT_LEFT : sprite_width);
|
|
|
int text_right = r - (rtl ? sprite_width : WD_FRAMERECT_RIGHT);
|
|
|
|
|
|
int normal_text_y_offset = (step_size - FONT_HEIGHT_NORMAL) / 2;
|
|
|
int small_text_y_offset = step_size - FONT_HEIGHT_SMALL - WD_FRAMERECT_BOTTOM - 1;
|
|
|
|
|
|
for (; min < max; min++, y += step_size) {
|
|
|
const EngineID engine = (*eng_list)[min];
|
|
|
/* Note: num_engines is only used in the autoreplace GUI, so it is correct to use _local_company here. */
|
|
|
const uint num_engines = GetGroupNumEngines(_local_company, selected_group, engine);
|
|
|
|
|
|
SetDParam(0, engine);
|
|
|
DrawString(text_left, text_right, y + normal_text_y_offset, STR_ENGINE_NAME, engine == selected_id ? TC_WHITE : TC_BLACK);
|
|
|
DrawVehicleEngine(l, r, sprite_x, y + sprite_y_offset, engine, (show_count && num_engines == 0) ? PALETTE_CRASH : GetEnginePalette(engine, _local_company));
|
|
|
if (show_count) {
|
|
|
SetDParam(0, num_engines);
|
|
|
DrawString(text_left, text_right, y + small_text_y_offset, STR_TINY_BLACK_COMA, TC_FROMSTRING, SA_RIGHT);
|
|
|
}
|