Fix input/display of speeds in tracerestrict window in tiles/day mode

This commit is contained in:
Jonathan G Rennison
2022-01-11 21:38:19 +00:00
parent a64a6aeeb8
commit 644bd0a325
2 changed files with 15 additions and 3 deletions

View File

@@ -1394,6 +1394,7 @@ static void ClimateThresholdModeChanged(int32 new_value)
static void VelocityUnitsChanged(int32 new_value) {
InvalidateWindowClassesData(WC_PAYMENT_RATES);
InvalidateWindowClassesData(WC_TRACE_RESTRICT);
MarkWholeScreenDirty();
}

View File

@@ -845,13 +845,15 @@ static bool IsIntegerValueType(TraceRestrictValueType type)
{
switch (type) {
case TRVT_INT:
case TRVT_SPEED:
case TRVT_WEIGHT:
case TRVT_POWER:
case TRVT_FORCE:
case TRVT_PERCENT:
return true;
case TRVT_SPEED:
return _settings_game.locale.units_velocity != 3;
default:
return false;
}
@@ -867,6 +869,9 @@ static bool IsDecimalValueType(TraceRestrictValueType type)
case TRVT_FORCE_WEIGHT_RATIO:
return true;
case TRVT_SPEED:
return _settings_game.locale.units_velocity == 3;
default:
return false;
}
@@ -931,6 +936,11 @@ static void ConvertValueToDecimal(TraceRestrictValueType type, uint in, int64 &v
ConvertForceWeightRatioToDisplay(in, value, decimal);
break;
case TRVT_SPEED:
decimal = _settings_game.locale.units_velocity == 3 ? 1 : 0;
value = ConvertKmhishSpeedToDisplaySpeed(in);
break;
default:
NOT_REACHED();
}
@@ -944,11 +954,12 @@ static uint ConvertDecimalToValue(TraceRestrictValueType type, double in)
switch (type) {
case TRVT_POWER_WEIGHT_RATIO:
return ConvertDisplayToPowerWeightRatio(in);
break;
case TRVT_FORCE_WEIGHT_RATIO:
return ConvertDisplayToForceWeightRatio(in);
break;
case TRVT_SPEED:
return ConvertDisplaySpeedToKmhishSpeed(in * (_settings_game.locale.units_velocity == 3 ? 10 : 1));
default:
NOT_REACHED();