Changeset - r28005:30d4958e88dc
[Not reviewed]
master
0 5 0
Peter Nelson - 14 months ago 2023-10-20 16:32:17
peter1138@openttd.org
Change: Display cargo lists in sorted cargo order. (#11383)
5 files changed with 30 insertions and 27 deletions:
0 comments (0 inline, 0 general)
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -574,11 +574,12 @@ static uint GetCargoWeight(const CargoAr
 

	
 
static int DrawCargoCapacityInfo(int left, int right, int y, TestedEngineDetails &te, bool refittable)
 
{
 
	for (CargoID c = 0; c < NUM_CARGO; c++) {
 
		if (te.all_capacities[c] == 0) continue;
 
	for (const CargoSpec *cs : _sorted_cargo_specs) {
 
		CargoID cid = cs->Index();
 
		if (te.all_capacities[cid] == 0) continue;
 

	
 
		SetDParam(0, c);
 
		SetDParam(1, te.all_capacities[c]);
 
		SetDParam(0, cid);
 
		SetDParam(1, te.all_capacities[cid]);
 
		SetDParam(2, refittable ? STR_PURCHASE_INFO_REFITTABLE : STR_EMPTY);
 
		DrawString(left, right, y, STR_PURCHASE_INFO_CAPACITY);
 
		y += FONT_HEIGHT_NORMAL;
src/depot_gui.cpp
Show inline comments
 
@@ -876,7 +876,8 @@ struct DepotWindow : Window {
 
		static std::string details;
 
		details.clear();
 

	
 
		for (CargoID cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) {
 
		for (const CargoSpec *cs : _sorted_cargo_specs) {
 
			CargoID cargo_type = cs->Index();
 
			if (capacity[cargo_type] == 0) continue;
 

	
 
			SetDParam(0, cargo_type);           // {CARGO} #1
src/misc_gui.cpp
Show inline comments
 
@@ -306,19 +306,20 @@ public:
 
		line << GetString(STR_LAND_AREA_INFORMATION_CARGO_ACCEPTED);
 

	
 
		bool found = false;
 
		for (CargoID i = 0; i < NUM_CARGO; ++i) {
 
			if (acceptance[i] > 0) {
 
		for (const CargoSpec *cs : _sorted_cargo_specs) {
 
			CargoID cid = cs->Index();
 
			if (acceptance[cid] > 0) {
 
				/* Add a comma between each item. */
 
				if (found) line << ", ";
 
				found = true;
 

	
 
				/* If the accepted value is less than 8, show it in 1/8:ths */
 
				if (acceptance[i] < 8) {
 
					SetDParam(0, acceptance[i]);
 
					SetDParam(1, CargoSpec::Get(i)->name);
 
				if (acceptance[cid] < 8) {
 
					SetDParam(0, acceptance[cid]);
 
					SetDParam(1, cs->name);
 
					line << GetString(STR_LAND_AREA_INFORMATION_CARGO_EIGHTS);
 
				} else {
 
					line << GetString(CargoSpec::Get(i)->name);
 
					line << GetString(cs->name);
 
				}
 
			}
 
		}
src/roadveh_gui.cpp
Show inline comments
 
@@ -40,9 +40,7 @@ void DrawRoadVehDetails(const Vehicle *v
 

	
 
	if (v->HasArticulatedPart()) {
 
		CargoArray max_cargo{};
 
		StringID subtype_text[NUM_CARGO];
 

	
 
		memset(subtype_text, 0, sizeof(subtype_text));
 
		std::array<StringID, NUM_CARGO> subtype_text{};
 

	
 
		for (const Vehicle *u = v; u != nullptr; u = u->Next()) {
 
			max_cargo[u->cargo_type] += u->cargo_cap;
 
@@ -55,16 +53,17 @@ void DrawRoadVehDetails(const Vehicle *v
 
		std::string capacity = GetString(STR_VEHICLE_DETAILS_TRAIN_ARTICULATED_RV_CAPACITY);
 

	
 
		bool first = true;
 
		for (CargoID i = 0; i < NUM_CARGO; i++) {
 
			if (max_cargo[i] > 0) {
 
		for (const CargoSpec *cs : _sorted_cargo_specs) {
 
			CargoID cid = cs->Index();
 
			if (max_cargo[cid] > 0) {
 
				if (!first) capacity += ", ";
 

	
 
				SetDParam(0, i);
 
				SetDParam(1, max_cargo[i]);
 
				SetDParam(0, cid);
 
				SetDParam(1, max_cargo[cid]);
 
				capacity += GetString(STR_JUST_CARGO);
 

	
 
				if (subtype_text[i] != 0) {
 
					capacity += GetString(subtype_text[i]);
 
				if (subtype_text[cid] != STR_NULL) {
 
					capacity += GetString(subtype_text[cid]);
 
				}
 

	
 
				first = false;
src/train_gui.cpp
Show inline comments
 
@@ -447,14 +447,15 @@ void DrawTrainDetails(const Train *v, co
 

	
 
		/* Indent the total cargo capacity details */
 
		Rect ir = r.Indent(WidgetDimensions::scaled.hsep_indent, rtl);
 
		for (CargoID i = 0; i < NUM_CARGO; i++) {
 
			if (max_cargo[i] > 0 && --vscroll_pos < 0 && vscroll_pos > -vscroll_cap) {
 
				SetDParam(0, i);            // {CARGO} #1
 
				SetDParam(1, act_cargo[i]); // {CARGO} #2
 
				SetDParam(2, i);            // {SHORTCARGO} #1
 
				SetDParam(3, max_cargo[i]); // {SHORTCARGO} #2
 
		for (const CargoSpec *cs : _sorted_cargo_specs) {
 
			CargoID cid = cs->Index();
 
			if (max_cargo[cid] > 0 && --vscroll_pos < 0 && vscroll_pos > -vscroll_cap) {
 
				SetDParam(0, cid);            // {CARGO} #1
 
				SetDParam(1, act_cargo[cid]); // {CARGO} #2
 
				SetDParam(2, cid);            // {SHORTCARGO} #1
 
				SetDParam(3, max_cargo[cid]); // {SHORTCARGO} #2
 
				SetDParam(4, _settings_game.vehicle.freight_trains);
 
				DrawString(ir.left, ir.right, y + text_y_offset, FreightWagonMult(i) > 1 ? STR_VEHICLE_DETAILS_TRAIN_TOTAL_CAPACITY_MULT : STR_VEHICLE_DETAILS_TRAIN_TOTAL_CAPACITY);
 
				DrawString(ir.left, ir.right, y + text_y_offset, FreightWagonMult(cid) > 1 ? STR_VEHICLE_DETAILS_TRAIN_TOTAL_CAPACITY_MULT : STR_VEHICLE_DETAILS_TRAIN_TOTAL_CAPACITY);
 
				y += line_height;
 
			}
 
		}
0 comments (0 inline, 0 general)