src/vehicle_gui.cpp
changeset 8614 4c67a883c4c4
parent 8556 ce8d86cc14d2
child 8638 fc86c9704dda
equal deleted inserted replaced
8613:931d28d5c075 8614:4c67a883c4c4
   169 	SpriteID pal;
   169 	SpriteID pal;
   170 
   170 
   171 	/* draw profit-based colored icons */
   171 	/* draw profit-based colored icons */
   172 	if (v->age <= 365 * 2) {
   172 	if (v->age <= 365 * 2) {
   173 		pal = PALETTE_TO_GREY;
   173 		pal = PALETTE_TO_GREY;
   174 	} else if (v->profit_last_year < 0) {
   174 	} else if (v->GetDisplayProfitLastYear() < 0) {
   175 		pal = PALETTE_TO_RED;
   175 		pal = PALETTE_TO_RED;
   176 	} else if (v->profit_last_year >> 8 < 10000) {
   176 	} else if (v->GetDisplayProfitLastYear() < 10000) {
   177 		pal = PALETTE_TO_YELLOW;
   177 		pal = PALETTE_TO_YELLOW;
   178 	} else {
   178 	} else {
   179 		pal = PALETTE_TO_GREEN;
   179 		pal = PALETTE_TO_GREEN;
   180 	}
   180 	}
   181 	DrawSprite(SPR_BLOT, pal, x, y);
   181 	DrawSprite(SPR_BLOT, pal, x, y);
   585 
   585 
   586 static int CDECL VehicleProfitThisYearSorter(const void *a, const void *b)
   586 static int CDECL VehicleProfitThisYearSorter(const void *a, const void *b)
   587 {
   587 {
   588 	const Vehicle* va = *(const Vehicle**)a;
   588 	const Vehicle* va = *(const Vehicle**)a;
   589 	const Vehicle* vb = *(const Vehicle**)b;
   589 	const Vehicle* vb = *(const Vehicle**)b;
   590 	int r = ClampToI32(va->profit_this_year - vb->profit_this_year);
   590 	int r = ClampToI32(va->GetDisplayProfitThisYear() - vb->GetDisplayProfitThisYear());
   591 
   591 
   592 	VEHICLEUNITNUMBERSORTER(r, va, vb);
   592 	VEHICLEUNITNUMBERSORTER(r, va, vb);
   593 
   593 
   594 	return (_internal_sort_order & 1) ? -r : r;
   594 	return (_internal_sort_order & 1) ? -r : r;
   595 }
   595 }
   596 
   596 
   597 static int CDECL VehicleProfitLastYearSorter(const void *a, const void *b)
   597 static int CDECL VehicleProfitLastYearSorter(const void *a, const void *b)
   598 {
   598 {
   599 	const Vehicle* va = *(const Vehicle**)a;
   599 	const Vehicle* va = *(const Vehicle**)a;
   600 	const Vehicle* vb = *(const Vehicle**)b;
   600 	const Vehicle* vb = *(const Vehicle**)b;
   601 	int r = ClampToI32((va->profit_last_year - vb->profit_last_year) >> 8);
   601 	int r = ClampToI32(va->GetDisplayProfitLastYear() - vb->GetDisplayProfitLastYear());
   602 
   602 
   603 	VEHICLEUNITNUMBERSORTER(r, va, vb);
   603 	VEHICLEUNITNUMBERSORTER(r, va, vb);
   604 
   604 
   605 	return (_internal_sort_order & 1) ? -r : r;
   605 	return (_internal_sort_order & 1) ? -r : r;
   606 }
   606 }
   981 	max = min(w->vscroll.pos + w->vscroll.cap, vl->l.list_length);
   981 	max = min(w->vscroll.pos + w->vscroll.cap, vl->l.list_length);
   982 	for (i = w->vscroll.pos; i < max; ++i) {
   982 	for (i = w->vscroll.pos; i < max; ++i) {
   983 		const Vehicle *v = vl->sort_list[i];
   983 		const Vehicle *v = vl->sort_list[i];
   984 		StringID str;
   984 		StringID str;
   985 
   985 
   986 		SetDParam(0, v->profit_this_year >> 8);
   986 		SetDParam(0, v->GetDisplayProfitThisYear());
   987 		SetDParam(1, v->profit_last_year >> 8);
   987 		SetDParam(1, v->GetDisplayProfitLastYear());
   988 
   988 
   989 		DrawVehicleImage(v, x + 19, y + 6, INVALID_VEHICLE, w->widget[VLW_WIDGET_LIST].right - w->widget[VLW_WIDGET_LIST].left - 20, 0);
   989 		DrawVehicleImage(v, x + 19, y + 6, INVALID_VEHICLE, w->widget[VLW_WIDGET_LIST].right - w->widget[VLW_WIDGET_LIST].left - 20, 0);
   990 		DrawString(x + 19, y + w->resize.step_height - 8, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, TC_FROMSTRING);
   990 		DrawString(x + 19, y + w->resize.step_height - 8, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, TC_FROMSTRING);
   991 
   991 
   992 		if (v->name != NULL) {
   992 		if (v->name != NULL) {
  1498 
  1498 
  1499 		default: NOT_REACHED();
  1499 		default: NOT_REACHED();
  1500 	}
  1500 	}
  1501 
  1501 
  1502 	/* Draw profit */
  1502 	/* Draw profit */
  1503 	SetDParam(0, v->profit_this_year >> 8);
  1503 	SetDParam(0, v->GetDisplayProfitThisYear());
  1504 	SetDParam(1, v->profit_last_year >> 8);
  1504 	SetDParam(1, v->GetDisplayProfitLastYear());
  1505 	DrawString(2, 35, _vehicle_translation_table[VST_VEHICLE_PROFIT_THIS_YEAR_LAST_YEAR][v->type], TC_FROMSTRING);
  1505 	DrawString(2, 35, _vehicle_translation_table[VST_VEHICLE_PROFIT_THIS_YEAR_LAST_YEAR][v->type], TC_FROMSTRING);
  1506 
  1506 
  1507 	/* Draw breakdown & reliability */
  1507 	/* Draw breakdown & reliability */
  1508 	SetDParam(0, v->reliability * 100 >> 16);
  1508 	SetDParam(0, v->reliability * 100 >> 16);
  1509 	SetDParam(1, v->breakdowns_since_last_service);
  1509 	SetDParam(1, v->breakdowns_since_last_service);