src/vehicle_gui.cpp
changeset 8258 9fa31acb07bc
parent 8254 1496654ca5e7
child 8264 b1e85998c7d3
equal deleted inserted replaced
8257:3151fdbc73f9 8258:9fa31acb07bc
   550 	const Vehicle* vb = *(const Vehicle**)b;
   550 	const Vehicle* vb = *(const Vehicle**)b;
   551 	int r;
   551 	int r;
   552 
   552 
   553 	if (va != last_vehicle[0]) {
   553 	if (va != last_vehicle[0]) {
   554 		last_vehicle[0] = va;
   554 		last_vehicle[0] = va;
   555 		if (IsCustomName(va->string_id)) {
   555 		SetDParam(0, va->index);
   556 			GetString(last_name[0], va->string_id, lastof(last_name[0]));
   556 		GetString(last_name[0], STR_VEHICLE_NAME, lastof(last_name[0]));
   557 		} else {
       
   558 			last_name[0][0] = '\0';
       
   559 		}
       
   560 	}
   557 	}
   561 
   558 
   562 	if (vb != last_vehicle[1]) {
   559 	if (vb != last_vehicle[1]) {
   563 		last_vehicle[1] = vb;
   560 		last_vehicle[1] = vb;
   564 		if (IsCustomName(vb->string_id)) {
   561 		SetDParam(1, vb->index);
   565 			GetString(last_name[1], vb->string_id, lastof(last_name[1]));
   562 		GetString(last_name[1], STR_VEHICLE_NAME, lastof(last_name[1]));
   566 		} else {
       
   567 			last_name[1][0] = '\0';
       
   568 		}
       
   569 	}
   563 	}
   570 
   564 
   571 	r = strcmp(last_name[0], last_name[1]); // sort by name
   565 	r = strcmp(last_name[0], last_name[1]); // sort by name
   572 
   566 
   573 	VEHICLEUNITNUMBERSORTER(r, va, vb);
   567 	VEHICLEUNITNUMBERSORTER(r, va, vb);
  1008 		SetDParam(1, v->profit_last_year);
  1002 		SetDParam(1, v->profit_last_year);
  1009 
  1003 
  1010 		DrawVehicleImage(v, x + 19, y + 6, INVALID_VEHICLE, w->widget[VLW_WIDGET_LIST].right - w->widget[VLW_WIDGET_LIST].left - 20, 0);
  1004 		DrawVehicleImage(v, x + 19, y + 6, INVALID_VEHICLE, w->widget[VLW_WIDGET_LIST].right - w->widget[VLW_WIDGET_LIST].left - 20, 0);
  1011 		DrawString(x + 19, y + w->resize.step_height - 8, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, TC_FROMSTRING);
  1005 		DrawString(x + 19, y + w->resize.step_height - 8, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, TC_FROMSTRING);
  1012 
  1006 
  1013 		if ((v->type == VEH_TRAIN    && v->string_id != STR_SV_TRAIN_NAME)   ||
  1007 		if (v->name != NULL) {
  1014 			(v->type == VEH_ROAD     && v->string_id != STR_SV_ROADVEH_NAME) ||
       
  1015 			(v->type == VEH_SHIP     && v->string_id != STR_SV_SHIP_NAME)    ||
       
  1016 			(v->type == VEH_AIRCRAFT && v->string_id != STR_SV_AIRCRAFT_NAME)) {
       
  1017 
       
  1018 			/* The vehicle got a name so we will print it */
  1008 			/* The vehicle got a name so we will print it */
  1019 			SetDParam(0, v->index);
  1009 			SetDParam(0, v->index);
  1020 			DrawString(x + 19, y, STR_01AB, TC_FROMSTRING);
  1010 			DrawString(x + 19, y, STR_01AB, TC_FROMSTRING);
  1021 		}
  1011 		}
  1022 
  1012