Loading

aircraft type, sort

  1. Index: src/build_vehicle_gui.cpp
  2. ===================================================================
  3. --- src/build_vehicle_gui.cpp   (revision 27762)
  4. +++ src/build_vehicle_gui.cpp   (working copy)
  5. @@ -416,6 +416,26 @@
  6.     return _engine_sort_direction ? -r : r;
  7.  }
  8.  
  9. +/**
  10. + * Determines order of aircraft by type.
  11. + * @param *a first engine to compare.
  12. + * @param *b second engine to compare.
  13. + * @return for descending order: returns < 0 if a < b and > 0 for a > b. Vice versa for ascending order and 0 for equal.
  14. + */
  15. +static int CDECL AircraftTypeSorter(const EngineID *a, const EngineID *b)
  16. +{
  17. +   const Engine *e_a = Engine::Get(*a);
  18. +   const Engine *e_b = Engine::Get(*b);
  19. +
  20. +   int va = e_a->u.air.subtype;
  21. +   int vb = e_b->u.air.subtype;
  22. +   int r = va - vb;
  23. +
  24. +   /* Use EngineID to sort instead since we want consistent sorting */
  25. +   if (r == 0) return EngineNumberSorter(a, b);
  26. +   return _engine_sort_direction ? -r : r;
  27. +}
  28. +
  29.  /** Sort functions for the vehicle sort criteria, for each vehicle type. */
  30.  EngList_SortTypeFunction * const _engine_sort_functions[][11] = {{
  31.     /* Trains */
  32. @@ -464,6 +484,7 @@
  33.     &EngineReliabilitySorter,
  34.     &AircraftEngineCargoSorter,
  35.     &AircraftRangeSorter,
  36. +   &AircraftTypeSorter,
  37.  }};
  38.  
  39.  /** Dropdown menu strings for the vehicle sort criteria. */
  40. @@ -517,6 +538,7 @@
  41.     STR_SORT_BY_RELIABILITY,
  42.     STR_SORT_BY_CARGO_CAPACITY,
  43.     STR_SORT_BY_RANGE,
  44. +   STR_SORT_BY_AIRCRAFT_TYPE,
  45.     INVALID_STRING_ID
  46.  }};
  47.  
  48. @@ -762,6 +784,11 @@
  49.         y += FONT_HEIGHT_NORMAL;
  50.     }
  51.  
  52. +   /* Aircraft type */
  53. +   SetDParam(0, e->GetDisplayAircraftType());
  54. +   DrawString(left, right, y, STR_PURCHASE_INFO_AIRCRAFT_TYPE);
  55. +   y += FONT_HEIGHT_NORMAL;
  56. +
  57.     return y;
  58.  }
  59.  
  60. Index: src/engine.cpp
  61. ===================================================================
  62. --- src/engine.cpp  (revision 27762)
  63. +++ src/engine.cpp  (working copy)
  64. @@ -464,6 +464,25 @@
  65.  }
  66.  
  67.  /**
  68. + * Get the aircraft type for display purposes.
  69. + * @return Aircraft type as a StringID.
  70. + */
  71. +StringID Engine::GetDisplayAircraftType() const
  72. +{
  73. +   switch (this->type) {
  74. +       case VEH_AIRCRAFT:
  75. +           switch (this->u.air.subtype) {
  76. +               case AIR_HELI: return STR_LIVERY_HELICOPTER;
  77. +               case AIR_CTOL: return STR_LIVERY_SMALL_PLANE;
  78. +               case AIR_CTOL | AIR_FAST: return STR_LIVERY_LARGE_PLANE;
  79. +               default: NOT_REACHED();
  80. +           }
  81. +
  82. +       default: NOT_REACHED();
  83. +   }
  84. +}
  85. +
  86. +/**
  87.   * Initializes the EngineOverrideManager with the default engines.
  88.   */
  89.  void EngineOverrideManager::ResetToDefaultMapping()
  90. Index: src/engine_base.h
  91. ===================================================================
  92. --- src/engine_base.h   (revision 27762)
  93. +++ src/engine_base.h   (working copy)
  94. @@ -111,6 +111,7 @@
  95.     uint GetDisplayMaxTractiveEffort() const;
  96.     Date GetLifeLengthInDays() const;
  97.     uint16 GetRange() const;
  98. +   StringID GetDisplayAircraftType() const;
  99.  
  100.     /**
  101.      * Check whether the engine is hidden in the GUI for the given company.
  102. Index: src/lang/english.txt
  103. ===================================================================
  104. --- src/lang/english.txt    (revision 27762)
  105. +++ src/lang/english.txt    (working copy)
  106. @@ -309,6 +309,7 @@
  107.  STR_SORT_BY_POWER_VS_RUNNING_COST                               :Power/Running cost
  108.  STR_SORT_BY_CARGO_CAPACITY                                      :Cargo capacity
  109.  STR_SORT_BY_RANGE                                               :Range
  110. +STR_SORT_BY_AIRCRAFT_TYPE                                       :Aircraft Type
  111.  STR_SORT_BY_POPULATION                                          :Population
  112.  STR_SORT_BY_RATING                                              :Rating
  113.  
  114. @@ -3398,6 +3399,7 @@
  115.  STR_PURCHASE_INFO_ALL_BUT                                       :All but {CARGO_LIST}
  116.  STR_PURCHASE_INFO_MAX_TE                                        :{BLACK}Max. Tractive Effort: {GOLD}{FORCE}
  117.  STR_PURCHASE_INFO_AIRCRAFT_RANGE                                :{BLACK}Range: {GOLD}{COMMA} tiles
  118. +STR_PURCHASE_INFO_AIRCRAFT_TYPE                                 :{BLACK}Aircraft Type: {GOLD}{STRING}
  119.  
  120.  STR_BUY_VEHICLE_TRAIN_LIST_TOOLTIP                              :{BLACK}Train vehicle selection list. Click on vehicle for information. Ctrl+Click for toggling hiding of the vehicle type
  121.  STR_BUY_VEHICLE_ROAD_VEHICLE_LIST_TOOLTIP                       :{BLACK}Road vehicle selection list. Click on vehicle for information. Ctrl+Click for toggling hiding of the vehicle type

Comments