Tracerestrict: Sort slots by name in vehicle window

This commit is contained in:
Jonathan G Rennison
2024-01-20 22:29:36 +00:00
parent 24fc4e3e3f
commit f03a941b50

View File

@@ -3197,6 +3197,12 @@ struct VehicleDetailsWindow : Window {
std::vector<TraceRestrictSlotID> slots; std::vector<TraceRestrictSlotID> slots;
TraceRestrictGetVehicleSlots(v->index, slots); TraceRestrictGetVehicleSlots(v->index, slots);
std::sort(slots.begin(), slots.end(), [&](TraceRestrictSlotID a, TraceRestrictSlotID b) -> bool {
int r = StrNaturalCompare(TraceRestrictSlot::Get(a)->name, TraceRestrictSlot::Get(b)->name);
if (r == 0) return a < b;
return r < 0;
});
SetDParam(0, slots.size()); SetDParam(0, slots.size());
std::string buffer = GetString(STR_TRACE_RESTRICT_SLOT_LIST_HEADER); std::string buffer = GetString(STR_TRACE_RESTRICT_SLOT_LIST_HEADER);