* Return the category of an engine. * @param engine Engine to examine. * @return String describing the category ("road veh", "train". "airplane", or "ship") of the engine. */
| 38 | * @return String describing the category ("road veh", "train". "airplane", or "ship") of the engine. |
| 39 | */ |
| 40 | StringID GetEngineCategoryName(EngineID engine) |
| 41 | { |
| 42 | const Engine *e = Engine::Get(engine); |
| 43 | switch (e->type) { |
| 44 | default: NOT_REACHED(); |
| 45 | case VEH_ROAD: |
| 46 | return GetRoadTypeInfo(e->VehInfo<RoadVehicleInfo>().roadtype)->strings.new_engine; |
| 47 | case VEH_AIRCRAFT: return STR_ENGINE_PREVIEW_AIRCRAFT; |
| 48 | case VEH_SHIP: return STR_ENGINE_PREVIEW_SHIP; |
| 49 | case VEH_TRAIN: |
| 50 | assert(e->VehInfo<RailVehicleInfo>().railtypes.Any()); |
| 51 | return GetRailTypeInfo(e->VehInfo<RailVehicleInfo>().railtypes.GetNthSetBit(0).value())->strings.new_loco; |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | static constexpr std::initializer_list<NWidgetPart> _nested_engine_preview_widgets = { |
| 56 | NWidget(NWID_HORIZONTAL), |
no test coverage detected