Fix velocity unit names used in cargo payments graph window
This commit is contained in:
@@ -1501,7 +1501,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow {
|
|||||||
case WID_GRAPH_FOOTER_CUSTOM:
|
case WID_GRAPH_FOOTER_CUSTOM:
|
||||||
if (_cargo_payment_x_mode) {
|
if (_cargo_payment_x_mode) {
|
||||||
SetDParam(0, STR_GRAPH_CARGO_PAYMENT_RATES_X_LABEL_SPEED);
|
SetDParam(0, STR_GRAPH_CARGO_PAYMENT_RATES_X_LABEL_SPEED);
|
||||||
SetDParam(1, STR_UNIT_NAME_VELOCITY_IMPERIAL + _settings_game.locale.units_velocity);
|
SetDParam(1, GetVelocityUnitName(VEH_TRAIN));
|
||||||
} else {
|
} else {
|
||||||
if (_settings_time.time_in_minutes) {
|
if (_settings_time.time_in_minutes) {
|
||||||
SetDParam(0, STR_GRAPH_CARGO_PAYMENT_RATES_X_LABEL_MINUTES);
|
SetDParam(0, STR_GRAPH_CARGO_PAYMENT_RATES_X_LABEL_MINUTES);
|
||||||
|
@@ -858,6 +858,31 @@ static const Units _units_time_years_or_minutes[] = {
|
|||||||
{ { 12 }, STR_UNITS_MINUTES, 0 },
|
{ { 12 }, STR_UNITS_MINUTES, 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
StringID GetVelocityUnitName(VehicleType type)
|
||||||
|
{
|
||||||
|
uint8_t setting = (type == VEH_SHIP || type == VEH_AIRCRAFT) ? _settings_game.locale.units_velocity_nautical : _settings_game.locale.units_velocity;
|
||||||
|
|
||||||
|
assert(setting < lengthof(_units_velocity_calendar));
|
||||||
|
assert(setting < lengthof(_units_velocity_realtime));
|
||||||
|
static_assert(lengthof(_units_velocity_calendar) == 5 && lengthof(_units_velocity_realtime) == 5);
|
||||||
|
|
||||||
|
switch (setting) {
|
||||||
|
case 0:
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
return STR_UNIT_NAME_VELOCITY_IMPERIAL + setting;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
return EconTime::UsingWallclockUnits() ? STR_UNIT_NAME_VELOCITY_GAMEUNITS_WALLCLOCK : STR_UNIT_NAME_VELOCITY_GAMEUNITS;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
return STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_KNOTS;
|
||||||
|
|
||||||
|
default:
|
||||||
|
NOT_REACHED();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the correct velocity units depending on the vehicle type and whether we're using real-time units.
|
* Get the correct velocity units depending on the vehicle type and whether we're using real-time units.
|
||||||
* @param type VehicleType to convert velocity for.
|
* @param type VehicleType to convert velocity for.
|
||||||
|
@@ -71,6 +71,8 @@ uint32_t GetStringGRFID(StringID string);
|
|||||||
uint ConvertKmhishSpeedToDisplaySpeed(uint speed, VehicleType type);
|
uint ConvertKmhishSpeedToDisplaySpeed(uint speed, VehicleType type);
|
||||||
uint ConvertDisplaySpeedToKmhishSpeed(uint speed, VehicleType type);
|
uint ConvertDisplaySpeedToKmhishSpeed(uint speed, VehicleType type);
|
||||||
|
|
||||||
|
StringID GetVelocityUnitName(VehicleType type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pack velocity and vehicle type for use with SCC_VELOCITY string parameter.
|
* Pack velocity and vehicle type for use with SCC_VELOCITY string parameter.
|
||||||
* @param speed Display speed for parameter.
|
* @param speed Display speed for parameter.
|
||||||
|
Reference in New Issue
Block a user