Loading

Paste #puhsjpjyc

  1. Index: src/autoreplace_cmd.cpp
  2. ===================================================================
  3. --- src/autoreplace_cmd.cpp (revision 27930)
  4. +++ src/autoreplace_cmd.cpp (working copy)
  5. @@ -79,8 +79,12 @@
  6.             break;
  7.  
  8.         case VEH_AIRCRAFT:
  9. -           /* make sure that we do not replace a plane with a helicopter or vice versa */
  10. -           if ((e_from->u.air.subtype & AIR_CTOL) != (e_to->u.air.subtype & AIR_CTOL)) return false;
  11. +           if (_settings_client.gui.autoreplace_match_aircraft_type) {
  12. +               /* make sure that we do not replace a mismatching aircraft type */
  13. +               if ((e_from->u.air.subtype == AIR_CTOL) != (e_to->u.air.subtype == AIR_CTOL)) return false;
  14. +               if ((e_from->u.air.subtype == AIR_HELI) != (e_to->u.air.subtype == AIR_HELI)) return false;
  15. +               if ((e_from->u.air.subtype == (AIR_CTOL | AIR_FAST)) != (e_to->u.air.subtype == (AIR_CTOL | AIR_FAST))) return false;
  16. +           }
  17.             break;
  18.  
  19.         default: break;
  20. Index: src/autoreplace_gui.cpp
  21. ===================================================================
  22. --- src/autoreplace_gui.cpp (revision 27930)
  23. +++ src/autoreplace_gui.cpp (working copy)
  24. @@ -229,6 +229,12 @@
  25.         widget->widget_data = STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN + vehicletype;
  26.         widget->tool_tip    = STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN_TOOLTIP + vehicletype;
  27.         widget->SetLowered(this->show_hidden_engines);
  28. +
  29. +       if (vehicletype == VEH_AIRCRAFT) {
  30. +           widget = this->GetWidget<NWidgetCore>(WID_RV_MATCH_AIRCRAFT_TYPE);
  31. +           widget->SetLowered(_settings_client.gui.autoreplace_match_aircraft_type);
  32. +       }
  33. +
  34.         this->FinishInitNested(vehicletype);
  35.  
  36.         this->sort_criteria = _engine_sort_last_criteria[vehicletype];
  37. @@ -475,6 +481,13 @@
  38.                 DoCommandP(0, GetCompanySettingIndex("company.renew_keep_length"), Company::Get(_local_company)->settings.renew_keep_length ? 0 : 1, CMD_CHANGE_COMPANY_SETTING);
  39.                 break;
  40.  
  41. +           case WID_RV_MATCH_AIRCRAFT_TYPE: // toggle autoreplace_match_aircraft_type
  42. +               IConsoleSetSetting("gui.autoreplace_match_aircraft_type", !_settings_client.gui.autoreplace_match_aircraft_type);
  43. +               this->engines[1].ForceRebuild();
  44. +               this->SetWidgetLoweredState(widget, _settings_client.gui.autoreplace_match_aircraft_type);
  45. +               this->SetDirty();
  46. +               break;
  47. +
  48.             case WID_RV_START_REPLACE: { // Start replacing
  49.                 if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
  50.                     this->HandleButtonClick(WID_RV_START_REPLACE);
  51. @@ -697,6 +710,60 @@
  52.     _nested_replace_vehicle_widgets, lengthof(_nested_replace_vehicle_widgets)
  53.  );
  54.  
  55. +static const NWidgetPart _nested_replace_aircraft_vehicle_widgets[] = {
  56. +   NWidget(NWID_HORIZONTAL),
  57. +       NWidget(WWT_CLOSEBOX, COLOUR_GREY),
  58. +       NWidget(WWT_CAPTION, COLOUR_GREY, WID_RV_CAPTION), SetMinimalSize(433, 14), SetDataTip(STR_REPLACE_VEHICLES_WHITE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
  59. +       NWidget(WWT_SHADEBOX, COLOUR_GREY),
  60. +       NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
  61. +       NWidget(WWT_STICKYBOX, COLOUR_GREY),
  62. +   EndContainer(),
  63. +   NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
  64. +       NWidget(WWT_PANEL, COLOUR_GREY),
  65. +           NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_REPLACE_VEHICLE_VEHICLES_IN_USE, STR_REPLACE_VEHICLE_VEHICLES_IN_USE_TOOLTIP), SetFill(1, 1), SetMinimalSize(0, 12), SetResize(1, 0),
  66. +       EndContainer(),
  67. +       NWidget(WWT_PANEL, COLOUR_GREY),
  68. +           NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_REPLACE_VEHICLE_AVAILABLE_VEHICLES, STR_REPLACE_VEHICLE_AVAILABLE_VEHICLES_TOOLTIP), SetFill(1, 1), SetMinimalSize(0, 12), SetResize(1, 0),
  69. +       EndContainer(),
  70. +   EndContainer(),
  71. +   NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
  72. +       NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), EndContainer(),
  73. +       NWidget(NWID_VERTICAL),
  74. +           NWidget(NWID_HORIZONTAL),
  75. +               NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_SORT_ASCENDING_DESCENDING), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER),
  76. +               NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_SORT_DROPDOWN), SetResize(1, 0), SetFill(1, 1), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_SORT_CRITERIA),
  77. +           EndContainer(),
  78. +           NWidget(NWID_HORIZONTAL),
  79. +               NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_RV_SHOW_HIDDEN_ENGINES), SetDataTip(STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN, STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN_TOOLTIP),
  80. +               NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_RV_MATCH_AIRCRAFT_TYPE), SetDataTip(STR_REPLACE_MATCH_AIRCRAFT_TYPE, STR_REPLACE_MATCH_AIRCRAFT_TYPE_HELP), SetResize(1, 0), SetFill(1, 1),
  81. +           EndContainer(),
  82. +       EndContainer(),
  83. +   EndContainer(),
  84. +   NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
  85. +       NWidget(WWT_MATRIX, COLOUR_GREY, WID_RV_LEFT_MATRIX), SetMinimalSize(216, 0), SetFill(1, 1), SetMatrixDataTip(1, 0, STR_REPLACE_HELP_LEFT_ARRAY), SetResize(1, 1), SetScrollbar(WID_RV_LEFT_SCROLLBAR),
  86. +       NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_RV_LEFT_SCROLLBAR),
  87. +       NWidget(WWT_MATRIX, COLOUR_GREY, WID_RV_RIGHT_MATRIX), SetMinimalSize(216, 0), SetFill(1, 1), SetMatrixDataTip(1, 0, STR_REPLACE_HELP_RIGHT_ARRAY), SetResize(1, 1), SetScrollbar(WID_RV_RIGHT_SCROLLBAR),
  88. +       NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_RV_RIGHT_SCROLLBAR),
  89. +   EndContainer(),
  90. +   NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
  91. +       NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_LEFT_DETAILS), SetMinimalSize(228, 92), SetResize(1, 0), EndContainer(),
  92. +       NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_RIGHT_DETAILS), SetMinimalSize(228, 92), SetResize(1, 0), EndContainer(),
  93. +   EndContainer(),
  94. +   NWidget(NWID_HORIZONTAL),
  95. +       NWidget(NWID_PUSHBUTTON_DROPDOWN, COLOUR_GREY, WID_RV_START_REPLACE), SetMinimalSize(139, 12), SetDataTip(STR_REPLACE_VEHICLES_START, STR_REPLACE_HELP_START_BUTTON),
  96. +       NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_INFO_TAB), SetMinimalSize(167, 12), SetDataTip(0x0, STR_REPLACE_HELP_REPLACE_INFO_TAB), SetResize(1, 0), EndContainer(),
  97. +       NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_STOP_REPLACE), SetMinimalSize(138, 12), SetDataTip(STR_REPLACE_VEHICLES_STOP, STR_REPLACE_HELP_STOP_BUTTON),
  98. +       NWidget(WWT_RESIZEBOX, COLOUR_GREY),
  99. +   EndContainer(),
  100. +};
  101. +
  102. +static WindowDesc _replace_aircraft_vehicle_desc(
  103. +   WDP_AUTO, "replace_vehicle_aircraft", 456, 118,
  104. +   WC_REPLACE_VEHICLE, WC_NONE,
  105. +   WDF_CONSTRUCTION,
  106. +   _nested_replace_aircraft_vehicle_widgets, lengthof(_nested_replace_aircraft_vehicle_widgets)
  107. +);
  108. +
  109.  /**
  110.   * Show the autoreplace configuration window for a particular group.
  111.   * @param id_g The group to replace the vehicles for.
  112. @@ -705,5 +772,11 @@
  113.  void ShowReplaceGroupVehicleWindow(GroupID id_g, VehicleType vehicletype)
  114.  {
  115.     DeleteWindowById(WC_REPLACE_VEHICLE, vehicletype);
  116. -   new ReplaceVehicleWindow(vehicletype == VEH_TRAIN ? &_replace_rail_vehicle_desc : &_replace_vehicle_desc, vehicletype, id_g);
  117. +   if (vehicletype == VEH_TRAIN) {
  118. +       new ReplaceVehicleWindow(&_replace_rail_vehicle_desc, vehicletype, id_g);
  119. +   } else if (vehicletype == VEH_AIRCRAFT) {
  120. +       new ReplaceVehicleWindow(&_replace_aircraft_vehicle_desc, vehicletype, id_g);
  121. +   } else {
  122. +       new ReplaceVehicleWindow(&_replace_vehicle_desc, vehicletype, id_g);
  123. +   }
  124.  }
  125. Index: src/lang/english.txt
  126. ===================================================================
  127. --- src/lang/english.txt    (revision 27930)
  128. +++ src/lang/english.txt    (working copy)
  129. @@ -3585,6 +3585,9 @@
  130.  STR_REPLACE_REMOVE_WAGON                                        :{BLACK}Wagon removal: {ORANGE}{STRING}
  131.  STR_REPLACE_REMOVE_WAGON_HELP                                   :{BLACK}Make autoreplace keep the length of a train the same by removing wagons (starting at the front), if replacing the engine would make the train longer
  132.  
  133. +STR_REPLACE_MATCH_AIRCRAFT_TYPE                                 :{BLACK}Match aircraft type
  134. +STR_REPLACE_MATCH_AIRCRAFT_TYPE_HELP                            :{BLACK}By enabling this button, only aircraft matching the same type as the one selected for replacement are displayed
  135. +
  136.  # Vehicle view
  137.  STR_VEHICLE_VIEW_CAPTION                                        :{WHITE}{VEHICLE}
  138.  
  139. Index: src/script/api/game/game_window.hpp.sq
  140. ===================================================================
  141. --- src/script/api/game/game_window.hpp.sq  (revision 27930)
  142. +++ src/script/api/game/game_window.hpp.sq  (working copy)
  143. @@ -216,6 +216,7 @@
  144.     SQGSWindow.DefSQConst(engine, ScriptWindow::WID_RV_SORT_ASCENDING_DESCENDING,          "WID_RV_SORT_ASCENDING_DESCENDING");
  145.     SQGSWindow.DefSQConst(engine, ScriptWindow::WID_RV_SHOW_HIDDEN_ENGINES,                "WID_RV_SHOW_HIDDEN_ENGINES");
  146.     SQGSWindow.DefSQConst(engine, ScriptWindow::WID_RV_SORT_DROPDOWN,                      "WID_RV_SORT_DROPDOWN");
  147. +   SQGSWindow.DefSQConst(engine, ScriptWindow::WID_RV_MATCH_AIRCRAFT_TYPE,                "WID_RV_MATCH_AIRCRAFT_TYPE");
  148.     SQGSWindow.DefSQConst(engine, ScriptWindow::WID_RV_LEFT_MATRIX,                        "WID_RV_LEFT_MATRIX");
  149.     SQGSWindow.DefSQConst(engine, ScriptWindow::WID_RV_LEFT_SCROLLBAR,                     "WID_RV_LEFT_SCROLLBAR");
  150.     SQGSWindow.DefSQConst(engine, ScriptWindow::WID_RV_RIGHT_MATRIX,                       "WID_RV_RIGHT_MATRIX");
  151. Index: src/script/api/script_window.hpp
  152. ===================================================================
  153. --- src/script/api/script_window.hpp    (revision 27930)
  154. +++ src/script/api/script_window.hpp    (working copy)
  155. @@ -927,6 +927,7 @@
  156.         WID_RV_SORT_ASCENDING_DESCENDING             = ::WID_RV_SORT_ASCENDING_DESCENDING,             ///< Ascending/descending sort order button.
  157.         WID_RV_SHOW_HIDDEN_ENGINES                   = ::WID_RV_SHOW_HIDDEN_ENGINES,                   ///< Toggle whether to display the hidden vehicles.
  158.         WID_RV_SORT_DROPDOWN                         = ::WID_RV_SORT_DROPDOWN,                         ///< Dropdown for the sort criteria.
  159. +       WID_RV_MATCH_AIRCRAFT_TYPE                   = ::WID_RV_MATCH_AIRCRAFT_TYPE,                   ///< Toggle whether to match aircraft type.
  160.  
  161.         /* Left and right matrix + details. */
  162.         WID_RV_LEFT_MATRIX                           = ::WID_RV_LEFT_MATRIX,                           ///< The matrix on the left.
  163. Index: src/settings_type.h
  164. ===================================================================
  165. --- src/settings_type.h (revision 27930)
  166. +++ src/settings_type.h (working copy)
  167. @@ -133,6 +133,7 @@
  168.     bool   station_show_coverage;            ///< whether to highlight coverage area
  169.     bool   persistent_buildingtools;         ///< keep the building tools active after usage
  170.     bool   expenses_layout;                  ///< layout of expenses window
  171. +   bool   autoreplace_match_aircraft_type;  ///< whether to match aircraft type for autoreplace
  172.     uint32 last_newgrf_count;                ///< the numbers of NewGRFs we found during the last scan
  173.     byte   missing_strings_threshold;        ///< the number of missing strings before showing the warning
  174.     uint8  graph_line_thickness;             ///< the thickness of the lines in the various graph guis
  175. Index: src/table/settings.ini
  176. ===================================================================
  177. --- src/table/settings.ini  (revision 27930)
  178. +++ src/table/settings.ini  (working copy)
  179. @@ -3093,6 +3093,11 @@
  180.  strhelp  = STR_CONFIG_SETTING_EXPENSES_LAYOUT_HELPTEXT
  181.  proc     = RedrawScreen
  182.  
  183. +[SDTC_BOOL]
  184. +var      = gui.autoreplace_match_aircraft_type
  185. +flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
  186. +def      = true
  187. +
  188.  [SDTC_VAR]
  189.  var      = gui.station_gui_group_order
  190.  type     = SLE_UINT8
  191. Index: src/widgets/autoreplace_widget.h
  192. ===================================================================
  193. --- src/widgets/autoreplace_widget.h    (revision 27930)
  194. +++ src/widgets/autoreplace_widget.h    (working copy)
  195. @@ -20,6 +20,7 @@
  196.     WID_RV_SORT_ASCENDING_DESCENDING, ///< Ascending/descending sort order button.
  197.     WID_RV_SHOW_HIDDEN_ENGINES,       ///< Toggle whether to display the hidden vehicles.
  198.     WID_RV_SORT_DROPDOWN,             ///< Dropdown for the sort criteria.
  199. +   WID_RV_MATCH_AIRCRAFT_TYPE,       ///< Toggle whether to match aircraft type.
  200.  
  201.     /* Left and right matrix + details. */
  202.     WID_RV_LEFT_MATRIX,              ///< The matrix on the left.

Comments