mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-17 21:25:40 +00:00
Merge branch 'template_train_replacement' into jgrpp
# Conflicts: # src/vehicle_gui.cpp
This commit is contained in:
commit
8f2c595378
@ -218,21 +218,7 @@ public:
|
|||||||
// From BaseVehicleListWindow
|
// From BaseVehicleListWindow
|
||||||
this->unitnumber_digits = unitnumber_digits;
|
this->unitnumber_digits = unitnumber_digits;
|
||||||
|
|
||||||
/* Find the most used vehicle type, which is usually
|
this->sel_railtype = INVALID_RAILTYPE;
|
||||||
* 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->details_height = 10 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
|
this->details_height = 10 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
|
||||||
|
|
||||||
@ -277,7 +263,7 @@ public:
|
|||||||
size->height = 4 * resize->height;
|
size->height = 4 * resize->height;
|
||||||
break;
|
break;
|
||||||
case TRW_WIDGET_TRAIN_RAILTYPE_DROPDOWN: {
|
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++) {
|
for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) {
|
||||||
const RailtypeInfo *rti = GetRailTypeInfo(rt);
|
const RailtypeInfo *rti = GetRailTypeInfo(rt);
|
||||||
// Skip rail type if it has no label
|
// Skip rail type if it has no label
|
||||||
@ -333,7 +319,7 @@ public:
|
|||||||
this->GetWidget<NWidgetCore>(TRW_WIDGET_TRAIN_FLUFF_RIGHT)->colour = _company_colours[_local_company];
|
this->GetWidget<NWidgetCore>(TRW_WIDGET_TRAIN_FLUFF_RIGHT)->colour = _company_colours[_local_company];
|
||||||
|
|
||||||
/* Show the selected railtype in the pulldown menu */
|
/* Show the selected railtype in the pulldown menu */
|
||||||
this->GetWidget<NWidgetCore>(TRW_WIDGET_TRAIN_RAILTYPE_DROPDOWN)->widget_data = GetRailTypeInfo(sel_railtype)->strings.replace_text;
|
this->GetWidget<NWidgetCore>(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())) {
|
if ((this->selected_template_index < 0) || (this->selected_template_index >= (short)this->templates.Length())) {
|
||||||
this->vscroll[2]->SetCount(24);
|
this->vscroll[2]->SetCount(24);
|
||||||
@ -436,7 +422,7 @@ public:
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TRW_WIDGET_TRAIN_RAILTYPE_DROPDOWN: // Railtype selection dropdown menu
|
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;
|
break;
|
||||||
case TRW_WIDGET_TOP_MATRIX: {
|
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();
|
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();
|
||||||
|
@ -225,6 +225,8 @@ TemplateVehicle* GetTemplateVehicleByGroupID(GroupID gid) {
|
|||||||
*/
|
*/
|
||||||
bool TemplateVehicleContainsEngineOfRailtype(const TemplateVehicle *tv, RailType type)
|
bool TemplateVehicleContainsEngineOfRailtype(const TemplateVehicle *tv, RailType type)
|
||||||
{
|
{
|
||||||
|
if (type == INVALID_RAILTYPE) return true;
|
||||||
|
|
||||||
/* For standard rail engines, allow only those */
|
/* For standard rail engines, allow only those */
|
||||||
if (type == RAILTYPE_BEGIN || type == RAILTYPE_RAIL) {
|
if (type == RAILTYPE_BEGIN || type == RAILTYPE_RAIL) {
|
||||||
while (tv) {
|
while (tv) {
|
||||||
|
Loading…
Reference in New Issue
Block a user