diff --git a/src/tbtr_template_gui_main.cpp b/src/tbtr_template_gui_main.cpp index 1179960d55..b3798f8dd9 100644 --- a/src/tbtr_template_gui_main.cpp +++ b/src/tbtr_template_gui_main.cpp @@ -218,21 +218,7 @@ public: // From BaseVehicleListWindow this->unitnumber_digits = unitnumber_digits; - /* Find the most used vehicle type, which is usually - * better than 'just' the first/previous vehicle type. */ - uint type_count[RAILTYPE_END]; - memset(type_count, 0, sizeof(type_count)); - - const Engine *e; - FOR_ALL_ENGINES_OF_TYPE(e, VEH_TRAIN) { - if (e->u.rail.railveh_type == RAILVEH_WAGON) continue; - type_count[e->u.rail.railtype] += GetGroupNumEngines(_local_company, ALL_GROUP, e->index); - } - - this->sel_railtype = RAILTYPE_BEGIN; - for (RailType rt = RAILTYPE_BEGIN; rt < RAILTYPE_END; rt++) { - if (type_count[this->sel_railtype] < type_count[rt]) this->sel_railtype = rt; - } + this->sel_railtype = INVALID_RAILTYPE; this->details_height = 10 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; @@ -277,7 +263,7 @@ public: size->height = 4 * resize->height; break; case TRW_WIDGET_TRAIN_RAILTYPE_DROPDOWN: { - Dimension d = {0, 0}; + Dimension d = GetStringBoundingBox(STR_REPLACE_ALL_RAILTYPE); for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) { const RailtypeInfo *rti = GetRailTypeInfo(rt); // Skip rail type if it has no label @@ -333,7 +319,7 @@ public: this->GetWidget(TRW_WIDGET_TRAIN_FLUFF_RIGHT)->colour = _company_colours[_local_company]; /* Show the selected railtype in the pulldown menu */ - this->GetWidget(TRW_WIDGET_TRAIN_RAILTYPE_DROPDOWN)->widget_data = GetRailTypeInfo(sel_railtype)->strings.replace_text; + this->GetWidget(TRW_WIDGET_TRAIN_RAILTYPE_DROPDOWN)->widget_data = (this->sel_railtype == INVALID_RAILTYPE) ? STR_REPLACE_ALL_RAILTYPE : GetRailTypeInfo(this->sel_railtype)->strings.replace_text; if ((this->selected_template_index < 0) || (this->selected_template_index >= (short)this->templates.Length())) { this->vscroll[2]->SetCount(24); @@ -436,7 +422,7 @@ public: } break; case TRW_WIDGET_TRAIN_RAILTYPE_DROPDOWN: // Railtype selection dropdown menu - ShowDropDownList(this, GetRailTypeDropDownList(true), sel_railtype, TRW_WIDGET_TRAIN_RAILTYPE_DROPDOWN); + ShowDropDownList(this, GetRailTypeDropDownList(true, true), this->sel_railtype, TRW_WIDGET_TRAIN_RAILTYPE_DROPDOWN); break; case TRW_WIDGET_TOP_MATRIX: { uint16 newindex = (uint16)((pt.y - this->nested_array[TRW_WIDGET_TOP_MATRIX]->pos_y) / (WD_MATRIX_TOP + FONT_HEIGHT_NORMAL+ WD_MATRIX_BOTTOM) ) + this->vscroll[0]->GetPosition(); diff --git a/src/tbtr_template_vehicle_func.cpp b/src/tbtr_template_vehicle_func.cpp index 9459366f2e..7be8d42540 100644 --- a/src/tbtr_template_vehicle_func.cpp +++ b/src/tbtr_template_vehicle_func.cpp @@ -225,6 +225,8 @@ TemplateVehicle* GetTemplateVehicleByGroupID(GroupID gid) { */ bool TemplateVehicleContainsEngineOfRailtype(const TemplateVehicle *tv, RailType type) { + if (type == INVALID_RAILTYPE) return true; + /* For standard rail engines, allow only those */ if (type == RAILTYPE_BEGIN || type == RAILTYPE_RAIL) { while (tv) {