Departure boards: Change long vehicle names to traditional if group also shown

pull/510/head
Jonathan G Rennison 1 year ago
parent 4f9aa70c11
commit e7687da4cc

@ -176,7 +176,7 @@ protected:
if (v->name.empty() && !(v->group_id != DEFAULT_GROUP && _settings_client.gui.vehicle_names != 0)) {
if (v->unitnumber > unitnumber_max[v->type]) unitnumber_max[v->type] = v->unitnumber;
} else {
SetDParam(0, (uint64)(v->index));
SetDParam(0, v->index | (_settings_client.gui.departure_show_group ? VEHICLE_NAME_NO_GROUP : 0));
int width = (GetStringBoundingBox(STR_DEPARTURES_VEH)).width + 4;
if (width > this->veh_width) this->veh_width = width;
}
@ -206,7 +206,7 @@ protected:
unitnumber_digits = 3;
}
SetDParamMaxDigits(0, unitnumber_digits);
int width = (GetStringBoundingBox(STR_SV_TRAIN_NAME + i)).width + 4;
int width = (GetStringBoundingBox(((_settings_client.gui.vehicle_names == 1) ? STR_SV_TRAIN_NAME : STR_TRADITIONAL_TRAIN_NAME) + i)).width + 4;
if (width > this->veh_width) this->veh_width = width;
}
}
@ -958,7 +958,7 @@ void DeparturesWindow<Twaypoint>::DrawDeparturesListItems(const Rect &r) const
const int veh_left = ltr ? text_right - PadWidth(toc_width) - PadWidth(group_width) - veh_width : text_left + PadWidth(toc_width) + PadWidth(group_width);
const int veh_right = ltr ? text_right - PadWidth(toc_width) - PadWidth(group_width) : text_left + PadWidth(toc_width) + PadWidth(group_width) + veh_width;
SetDParam(0, (uint64)(d->vehicle->index));
SetDParam(0, d->vehicle->index | (_settings_client.gui.departure_show_group ? VEHICLE_NAME_NO_GROUP : 0));
DrawString(veh_left, veh_right, y + 1, STR_DEPARTURES_VEH);
}

@ -1932,18 +1932,26 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
}
case SCC_VEHICLE_NAME: { // {VEHICLE}
const Vehicle *v = Vehicle::GetIfValid(args->GetInt32(SCC_VEHICLE_NAME));
uint32 id = (uint32)args->GetInt64(SCC_VEHICLE_NAME);
uint8 vehicle_names = _settings_client.gui.vehicle_names;
if (id & VEHICLE_NAME_NO_GROUP) {
id &= ~VEHICLE_NAME_NO_GROUP;
/* Change format from long to traditional */
if (vehicle_names == 2) vehicle_names = 0;
}
const Vehicle *v = Vehicle::GetIfValid(id);
if (v == nullptr) break;
if (!v->name.empty()) {
int64 args_array[] = {(int64)(size_t)v->name.c_str()};
StringParameters tmp_params(args_array);
buff = GetStringWithArgs(buff, STR_JUST_RAW_STRING, &tmp_params, last);
} else if (v->group_id != DEFAULT_GROUP && _settings_client.gui.vehicle_names != 0 && v->type < VEH_COMPANY_END) {
} else if (v->group_id != DEFAULT_GROUP && vehicle_names != 0 && v->type < VEH_COMPANY_END) {
/* The vehicle has no name, but is member of a group, so print group name */
uint32 group_name = v->group_id;
if (_settings_client.gui.show_vehicle_group_hierarchy_name) group_name |= GROUP_NAME_HIERARCHY;
if (_settings_client.gui.vehicle_names == 1) {
if (vehicle_names == 1) {
int64 args_array[] = {group_name, v->unitnumber};
StringParameters tmp_params(args_array);
buff = GetStringWithArgs(buff, STR_FORMAT_GROUP_VEHICLE_NAME, &tmp_params, last);
@ -1958,7 +1966,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
StringID string_id;
if (v->type < VEH_COMPANY_END) {
string_id = ((_settings_client.gui.vehicle_names == 1) ? STR_SV_TRAIN_NAME : STR_TRADITIONAL_TRAIN_NAME) + v->type;
string_id = ((vehicle_names == 1) ? STR_SV_TRAIN_NAME : STR_TRADITIONAL_TRAIN_NAME) + v->type;
} else {
string_id = STR_INVALID_VEHICLE;
}

@ -124,4 +124,6 @@ enum EngineImageType {
EIT_PREVIEW = 0x21, ///< Vehicle drawn in preview window, news, ...
};
static const uint32 VEHICLE_NAME_NO_GROUP = 0x80000000; ///< String constant to not include the vehicle's group name, if using the long name format
#endif /* VEHICLE_TYPE_H */

Loading…
Cancel
Save