* Build a string of cargo names with suffixes attached. * This is distinct from the CARGO_LIST string formatting code in two ways: * - This cargo list uses the order defined by the industry, rather than alphabetic. * - NewGRF-supplied suffix strings can be attached to each cargo. * * @param cargolist Array of CargoType to display * @param cargo_suffix Array of suffixes to attach t
| 364 | * @return A formatted raw string |
| 365 | */ |
| 366 | std::string MakeCargoListString(const std::span<const CargoType> cargolist, const std::span<const CargoSuffix> cargo_suffix, StringID prefixstr) const |
| 367 | { |
| 368 | assert(cargolist.size() == cargo_suffix.size()); |
| 369 | |
| 370 | std::string cargostring; |
| 371 | std::string_view list_separator = GetListSeparator(); |
| 372 | |
| 373 | for (size_t j = 0; j < cargolist.size(); j++) { |
| 374 | if (!IsValidCargoType(cargolist[j])) continue; |
| 375 | |
| 376 | if (!cargostring.empty()) cargostring += list_separator; |
| 377 | auto params = MakeParameters(CargoSpec::Get(cargolist[j])->name, cargo_suffix[j].text); |
| 378 | AppendStringWithArgsInPlace(cargostring, STR_INDUSTRY_VIEW_CARGO_LIST_EXTENSION, params); |
| 379 | } |
| 380 | |
| 381 | if (cargostring.empty()) AppendStringInPlace(cargostring, STR_JUST_NOTHING); |
| 382 | return GetString(prefixstr, cargostring); |
| 383 | } |
| 384 | |
| 385 | public: |
| 386 | BuildIndustryWindow() : Window(_build_industry_desc) |
no test coverage detected