Display list of cargo types of the engine, for the purchase information window */
| 1356 | |
| 1357 | /** Display list of cargo types of the engine, for the purchase information window */ |
| 1358 | uint ShowRefitOptionsList(int left, int right, int y, EngineID engine) |
| 1359 | { |
| 1360 | /* List of cargo types of this engine */ |
| 1361 | CargoTypes cmask = GetUnionOfArticulatedRefitMasks(engine, false); |
| 1362 | /* List of cargo types available in this climate */ |
| 1363 | CargoTypes lmask = _cargo_mask; |
| 1364 | |
| 1365 | /* Draw nothing if the engine is not refittable */ |
| 1366 | if (HasAtMostOneBit(cmask)) return y; |
| 1367 | |
| 1368 | std::string str; |
| 1369 | if (cmask == lmask) { |
| 1370 | /* Engine can be refitted to all types in this climate */ |
| 1371 | str = GetString(STR_PURCHASE_INFO_REFITTABLE_TO, STR_PURCHASE_INFO_ALL_TYPES, std::monostate{}); |
| 1372 | } else { |
| 1373 | /* Check if we are able to refit to more cargo types and unable to. If |
| 1374 | * so, invert the cargo types to list those that we can't refit to. */ |
| 1375 | if (CountBits(cmask ^ lmask) < CountBits(cmask) && CountBits(cmask ^ lmask) <= 7) { |
| 1376 | cmask ^= lmask; |
| 1377 | str = GetString(STR_PURCHASE_INFO_REFITTABLE_TO, STR_PURCHASE_INFO_ALL_BUT, cmask); |
| 1378 | } else { |
| 1379 | str = GetString(STR_PURCHASE_INFO_REFITTABLE_TO, STR_JUST_CARGO_LIST, cmask); |
| 1380 | } |
| 1381 | } |
| 1382 | |
| 1383 | return DrawStringMultiLine(left, right, y, INT32_MAX, str); |
| 1384 | } |
| 1385 | |
| 1386 | /** Get the cargo subtype text from NewGRF for the vehicle details window. */ |
| 1387 | StringID GetCargoSubtypeText(const Vehicle *v) |
no test coverage detected