Loading

Paste #p1mdw196x

  1. Index: src/autoreplace_gui.cpp
  2. ===================================================================
  3. --- src/autoreplace_gui.cpp (revision 27682)
  4. +++ src/autoreplace_gui.cpp (working copy)
  5. @@ -87,7 +87,7 @@
  6.     byte sort_criteria;           ///< Criteria of sorting vehicles.
  7.     bool descending_sort_order;   ///< Order of sorting vehicles.
  8.     bool show_hidden_engines;     ///< Whether to show the hidden engines.
  9. -   RailType sel_railtype;        ///< Type of rail tracks selected.
  10. +   RailType sel_railtype;        ///< Type of rail tracks selected. INVALID_RAILTYPE to show all.
  11.     Scrollbar *vscroll[2];
  12.  
  13.     /**
  14. @@ -106,7 +106,7 @@
  15.  
  16.         if (draw_left && show_engines) {
  17.             /* Ensure that the railtype is specific to the selected one */
  18. -           if (rvi->railtype != this->sel_railtype) return false;
  19. +           if (this->sel_railtype != INVALID_RAILTYPE && rvi->railtype != this->sel_railtype) return false;
  20.         }
  21.         return true;
  22.     }
  23. @@ -211,24 +211,7 @@
  24.  public:
  25.     ReplaceVehicleWindow(WindowDesc *desc, VehicleType vehicletype, GroupID id_g) : Window(desc)
  26.     {
  27. -       if (vehicletype == VEH_TRAIN) {
  28. -           /* For rail vehicles find the most used vehicle type, which is usually
  29. -            * better than 'just' the first/previous vehicle type. */
  30. -           uint type_count[RAILTYPE_END];
  31. -           memset(type_count, 0, sizeof(type_count));
  32. -
  33. -           const Engine *e;
  34. -           FOR_ALL_ENGINES_OF_TYPE(e, VEH_TRAIN) {
  35. -               if (e->u.rail.railveh_type == RAILVEH_WAGON) continue;
  36. -               type_count[e->u.rail.railtype] += GetGroupNumEngines(_local_company, id_g, e->index);
  37. -           }
  38. -
  39. -           this->sel_railtype = RAILTYPE_BEGIN;
  40. -           for (RailType rt = RAILTYPE_BEGIN; rt < RAILTYPE_END; rt++) {
  41. -               if (type_count[this->sel_railtype] < type_count[rt]) this->sel_railtype = rt;
  42. -           }
  43. -       }
  44. -
  45. +       this->sel_railtype = INVALID_RAILTYPE;
  46.         this->replace_engines  = true; // start with locomotives (all other vehicles will not read this bool)
  47.         this->engines[0].ForceRebuild();
  48.         this->engines[1].ForceRebuild();
  49. @@ -288,12 +271,9 @@
  50.                 break;
  51.             }
  52.  
  53. -           case WID_RV_TRAIN_ENGINEWAGON_TOGGLE: {
  54. -               StringID str = this->GetWidget<NWidgetCore>(widget)->widget_data;
  55. -               SetDParam(0, STR_REPLACE_ENGINES);
  56. -               Dimension d = GetStringBoundingBox(str);
  57. -               SetDParam(0, STR_REPLACE_WAGONS);
  58. -               d = maxdim(d, GetStringBoundingBox(str));
  59. +           case WID_RV_TRAIN_ENGINEWAGON_DROPDOWN: {
  60. +               Dimension d = GetStringBoundingBox(STR_REPLACE_ENGINES);
  61. +               d = maxdim(d, GetStringBoundingBox(STR_REPLACE_WAGONS));
  62.                 d.width += padding.width;
  63.                 d.height += padding.height;
  64.                 *size = maxdim(*size, d);
  65. @@ -367,7 +347,7 @@
  66.                 break;
  67.             }
  68.  
  69. -           case WID_RV_TRAIN_ENGINEWAGON_TOGGLE:
  70. +           case WID_RV_TRAIN_ENGINEWAGON_DROPDOWN:
  71.                 SetDParam(0, this->replace_engines ? STR_REPLACE_ENGINES : STR_REPLACE_WAGONS);
  72.                 break;
  73.         }
  74. @@ -432,12 +412,8 @@
  75.         this->SetWidgetDisabledState(WID_RV_STOP_REPLACE, this->sel_engine[0] == INVALID_ENGINE || !EngineHasReplacementForCompany(c, this->sel_engine[0], this->sel_group));
  76.  
  77.         if (this->window_number == VEH_TRAIN) {
  78. -           /* sets the colour of that art thing */
  79. -           this->GetWidget<NWidgetCore>(WID_RV_TRAIN_FLUFF_LEFT)->colour  = _company_colours[_local_company];
  80. -           this->GetWidget<NWidgetCore>(WID_RV_TRAIN_FLUFF_RIGHT)->colour = _company_colours[_local_company];
  81. -
  82.             /* Show the selected railtype in the pulldown menu */
  83. -           this->GetWidget<NWidgetCore>(WID_RV_TRAIN_RAILTYPE_DROPDOWN)->widget_data = GetRailTypeInfo(sel_railtype)->strings.replace_text;
  84. +           this->GetWidget<NWidgetCore>(WID_RV_TRAIN_RAILTYPE_DROPDOWN)->widget_data = sel_railtype == INVALID_RAILTYPE ? STR_REPLACE_ALL_RAILTYPE : GetRailTypeInfo(sel_railtype)->strings.replace_text;
  85.         }
  86.  
  87.         this->DrawWidgets();
  88. @@ -483,15 +459,21 @@
  89.                 DisplayVehicleSortDropDown(this, static_cast<VehicleType>(this->window_number), this->sort_criteria, WID_RV_SORT_DROPDOWN);
  90.                 break;
  91.  
  92. -           case WID_RV_TRAIN_ENGINEWAGON_TOGGLE:
  93. -               this->replace_engines  = !(this->replace_engines);
  94. -               this->engines[0].ForceRebuild();
  95. -               this->reset_sel_engine = true;
  96. -               this->SetDirty();
  97. +           case WID_RV_TRAIN_ENGINEWAGON_DROPDOWN: {
  98. +               DropDownList *list = new DropDownList();
  99. +
  100. +               DropDownListStringItem *item = new DropDownListStringItem(STR_REPLACE_ENGINES, 1, false);
  101. +               *list->Append() = item;
  102. +
  103. +               item = new DropDownListStringItem(STR_REPLACE_WAGONS, 0, false);
  104. +               *list->Append() = item;
  105. +
  106. +               ShowDropDownList(this, list, this->replace_engines ? 1 : 0, WID_RV_TRAIN_ENGINEWAGON_DROPDOWN);
  107.                 break;
  108. +           }
  109.  
  110.             case WID_RV_TRAIN_RAILTYPE_DROPDOWN: // Railtype selection dropdown menu
  111. -               ShowDropDownList(this, GetRailTypeDropDownList(true), sel_railtype, WID_RV_TRAIN_RAILTYPE_DROPDOWN);
  112. +               ShowDropDownList(this, GetRailTypeDropDownList(true, true), sel_railtype, WID_RV_TRAIN_RAILTYPE_DROPDOWN);
  113.                 break;
  114.  
  115.             case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: // toggle renew_keep_length
  116. @@ -566,6 +548,14 @@
  117.                 break;
  118.             }
  119.  
  120. +           case WID_RV_TRAIN_ENGINEWAGON_DROPDOWN: {
  121. +               this->replace_engines = index != 0;
  122. +               this->engines[0].ForceRebuild();
  123. +               this->reset_sel_engine = true;
  124. +               this->SetDirty();
  125. +               break;
  126. +           }
  127. +
  128.             case WID_RV_START_REPLACE:
  129.                 this->ReplaceClick_StartReplace(index != 0);
  130.                 break;
  131. @@ -611,9 +601,15 @@
  132.         EndContainer(),
  133.     EndContainer(),
  134.     NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
  135. -       NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), EndContainer(),
  136.         NWidget(NWID_VERTICAL),
  137.             NWidget(NWID_HORIZONTAL),
  138. +               NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_TRAIN_RAILTYPE_DROPDOWN), SetMinimalSize(136, 12), SetDataTip(0x0, STR_REPLACE_HELP_RAILTYPE), SetFill(1, 0), SetResize(1, 0),
  139. +               NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_TRAIN_ENGINEWAGON_DROPDOWN), SetDataTip(STR_BLACK_STRING, STR_REPLACE_ENGINE_WAGON_SELECT_HELP),
  140. +           EndContainer(),
  141. +           NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), EndContainer(),
  142. +       EndContainer(),
  143. +       NWidget(NWID_VERTICAL),
  144. +           NWidget(NWID_HORIZONTAL),
  145.                 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_SORT_ASCENDING_DESCENDING), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER), SetFill(1, 1),
  146.                 NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_SORT_DROPDOWN), SetResize(1, 0), SetFill(1, 1), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_SORT_CRITERIA),
  147.             EndContainer(),
  148. @@ -631,7 +627,10 @@
  149.     EndContainer(),
  150.     NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
  151.         NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_LEFT_DETAILS), SetMinimalSize(240, 122), SetResize(1, 0), EndContainer(),
  152. -       NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_RIGHT_DETAILS), SetMinimalSize(240, 122), SetResize(1, 0), EndContainer(),
  153. +       NWidget(NWID_VERTICAL),
  154. +           NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_RIGHT_DETAILS), SetMinimalSize(240, 122), SetResize(1, 0), EndContainer(),
  155. +           NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_TRAIN_WAGONREMOVE_TOGGLE), SetMinimalSize(138, 12), SetDataTip(STR_REPLACE_REMOVE_WAGON, STR_REPLACE_REMOVE_WAGON_HELP), SetFill(1, 0), SetResize(1, 0),
  156. +       EndContainer(),
  157.     EndContainer(),
  158.     NWidget(NWID_HORIZONTAL),
  159.         NWidget(NWID_PUSHBUTTON_DROPDOWN, COLOUR_GREY, WID_RV_START_REPLACE), SetMinimalSize(139, 12), SetDataTip(STR_REPLACE_VEHICLES_START, STR_REPLACE_HELP_START_BUTTON),
  160. @@ -638,13 +637,6 @@
  161.         NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_INFO_TAB), SetMinimalSize(167, 12), SetDataTip(0x0, STR_REPLACE_HELP_REPLACE_INFO_TAB), SetResize(1, 0),
  162.         EndContainer(),
  163.         NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_STOP_REPLACE), SetMinimalSize(150, 12), SetDataTip(STR_REPLACE_VEHICLES_STOP, STR_REPLACE_HELP_STOP_BUTTON),
  164. -   EndContainer(),
  165. -   NWidget(NWID_HORIZONTAL),
  166. -       NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_TRAIN_ENGINEWAGON_TOGGLE), SetMinimalSize(139, 12), SetDataTip(STR_REPLACE_ENGINE_WAGON_SELECT, STR_REPLACE_ENGINE_WAGON_SELECT_HELP),
  167. -       NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_TRAIN_FLUFF_LEFT), SetMinimalSize(15, 12), EndContainer(),
  168. -       NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_TRAIN_RAILTYPE_DROPDOWN), SetMinimalSize(136, 12), SetDataTip(0x0, STR_REPLACE_HELP_RAILTYPE), SetResize(1, 0),
  169. -       NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_TRAIN_FLUFF_RIGHT), SetMinimalSize(16, 12), EndContainer(),
  170. -       NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_TRAIN_WAGONREMOVE_TOGGLE), SetMinimalSize(138, 12), SetDataTip(STR_REPLACE_REMOVE_WAGON, STR_REPLACE_REMOVE_WAGON_HELP),
  171.         NWidget(WWT_RESIZEBOX, COLOUR_GREY),
  172.     EndContainer(),
  173.  };
  174. Index: src/lang/english.txt
  175. ===================================================================
  176. --- src/lang/english.txt    (revision 27682)
  177. +++ src/lang/english.txt    (working copy)
  178. @@ -3557,10 +3557,10 @@
  179.  STR_REPLACE_VEHICLES_STOP                                       :{BLACK}Stop Replacing Vehicles
  180.  STR_REPLACE_HELP_STOP_BUTTON                                    :{BLACK}Press to stop the replacement of the engine type selected on the left
  181.  
  182. -STR_REPLACE_ENGINE_WAGON_SELECT                                 :{BLACK}Replacing: {ORANGE}{STRING}
  183.  STR_REPLACE_ENGINE_WAGON_SELECT_HELP                            :{BLACK}Switch between engine and wagon replacement windows
  184.  STR_REPLACE_ENGINES                                             :Engines
  185.  STR_REPLACE_WAGONS                                              :Wagons
  186. +STR_REPLACE_ALL_RAILTYPE                                        :All rail vehicles
  187.  
  188.  STR_REPLACE_HELP_RAILTYPE                                       :{BLACK}Choose the rail type you want to replace engines for
  189.  STR_REPLACE_HELP_REPLACE_INFO_TAB                               :{BLACK}Displays which engine the left selected engine is being replaced with, if any
  190. Index: src/rail_gui.cpp
  191. ===================================================================
  192. --- src/rail_gui.cpp    (revision 27682)
  193. +++ src/rail_gui.cpp    (working copy)
  194. @@ -1981,9 +1981,10 @@
  195.  /**
  196.   * Create a drop down list for all the rail types of the local company.
  197.   * @param for_replacement Whether this list is for the replacement window.
  198. + * @param all_option Whether to add an 'all types' item.
  199.   * @return The populated and sorted #DropDownList.
  200.   */
  201. -DropDownList *GetRailTypeDropDownList(bool for_replacement)
  202. +DropDownList *GetRailTypeDropDownList(bool for_replacement, bool all_option)
  203.  {
  204.     RailTypes used_railtypes = RAILTYPES_NONE;
  205.  
  206. @@ -2000,6 +2001,12 @@
  207.  
  208.     const Company *c = Company::Get(_local_company);
  209.     DropDownList *list = new DropDownList();
  210. +
  211. +   if (all_option) {
  212. +       DropDownListStringItem *item = new DropDownListStringItem(STR_REPLACE_ALL_RAILTYPE, INVALID_RAILTYPE, false);
  213. +       *list->Append() = item;
  214. +   }
  215. +
  216.     RailType rt;
  217.     FOR_ALL_SORTED_RAILTYPES(rt) {
  218.         /* If it's not used ever, don't show it to the user. */
  219. Index: src/rail_gui.h
  220. ===================================================================
  221. --- src/rail_gui.h  (revision 27682)
  222. +++ src/rail_gui.h  (working copy)
  223. @@ -19,6 +19,6 @@
  224.  void ReinitGuiAfterToggleElrail(bool disable);
  225.  bool ResetSignalVariant(int32 = 0);
  226.  void InitializeRailGUI();
  227. -DropDownList *GetRailTypeDropDownList(bool for_replacement = false);
  228. +DropDownList *GetRailTypeDropDownList(bool for_replacement = false, bool all_option = false);
  229.  
  230.  #endif /* RAIL_GUI_H */
  231. Index: src/widgets/autoreplace_widget.h
  232. ===================================================================
  233. --- src/widgets/autoreplace_widget.h    (revision 27682)
  234. +++ src/widgets/autoreplace_widget.h    (working copy)
  235. @@ -35,10 +35,8 @@
  236.     WID_RV_STOP_REPLACE,             ///< Stop Replacing button.
  237.  
  238.     /* Train only widgets. */
  239. -   WID_RV_TRAIN_ENGINEWAGON_TOGGLE, ///< Button to toggle engines and/or wagons.
  240. -   WID_RV_TRAIN_FLUFF_LEFT,         ///< The fluff on the left.
  241. +   WID_RV_TRAIN_ENGINEWAGON_DROPDOWN, ///< Dropdown to select engines and/or wagons.
  242.     WID_RV_TRAIN_RAILTYPE_DROPDOWN,  ///< Dropdown menu about the railtype.
  243. -   WID_RV_TRAIN_FLUFF_RIGHT,        ///< The fluff on the right.
  244.     WID_RV_TRAIN_WAGONREMOVE_TOGGLE, ///< Button to toggle removing wagons.
  245.  };
  246.  
  247.  

Comments