(svn r19758) -Add: {HEIGHT} string command

This commit is contained in:
rubidium 2010-05-04 22:04:28 +00:00
parent 5db70ad649
commit b11dfa8cb8
4 changed files with 19 additions and 1 deletions

View File

@ -215,6 +215,9 @@ STR_UNITS_VOLUME_LONG_SI :{COMMA} m³
STR_UNITS_FORCE_SI :{COMMA} kN
STR_UNITS_HEIGHT_IMPERIAL :{COMMA} ft
STR_UNITS_HEIGHT_SI :{COMMA} m
# Common window strings
STR_LIST_FILTER_OSKTITLE :{BLACK}Enter filter string
STR_LIST_FILTER_TOOLTIP :{BLACK}Enter a keyword to filter the list for

View File

@ -508,6 +508,9 @@ struct Units {
int f_m; ///< Multiplier for force
int f_s; ///< Shift for force
StringID force; ///< String for force
int h_m; ///< Multiplier for height
int h_s; ///< Shift for height
StringID height; ///< String for height
};
/* Unit conversions */
@ -518,6 +521,7 @@ static const Units units[] = {
1, 0, STR_UNITS_WEIGHT_SHORT_METRIC, STR_UNITS_WEIGHT_LONG_METRIC,
1000, 0, STR_UNITS_VOLUME_SHORT_METRIC, STR_UNITS_VOLUME_LONG_METRIC,
1, 0, STR_UNITS_FORCE_SI,
3, 0, STR_UNITS_HEIGHT_IMPERIAL,
},
{ // Metric (km/h, hp, metric ton, litre, kN)
103, 6, STR_UNITS_VELOCITY_METRIC,
@ -525,6 +529,7 @@ static const Units units[] = {
1, 0, STR_UNITS_WEIGHT_SHORT_METRIC, STR_UNITS_WEIGHT_LONG_METRIC,
1000, 0, STR_UNITS_VOLUME_SHORT_METRIC, STR_UNITS_VOLUME_LONG_METRIC,
1, 0, STR_UNITS_FORCE_SI,
1, 0, STR_UNITS_HEIGHT_SI,
},
{ // SI (m/s, kilowatt, kilogram, cubic metres, kilonewton)
1831, 12, STR_UNITS_VELOCITY_SI,
@ -532,6 +537,7 @@ static const Units units[] = {
1000, 0, STR_UNITS_WEIGHT_SHORT_SI, STR_UNITS_WEIGHT_LONG_SI,
1, 0, STR_UNITS_VOLUME_SHORT_SI, STR_UNITS_VOLUME_LONG_SI,
1, 0, STR_UNITS_FORCE_SI,
1, 0, STR_UNITS_HEIGHT_SI,
},
};
@ -603,7 +609,7 @@ static char *FormatString(char *buff, const char *str, int64 *argv, uint casei,
buff = FormatMonthAndYear(buff, GetInt32(&argv), last);
break;
case SCC_VELOCITY: {// {VELOCITY}
case SCC_VELOCITY: { // {VELOCITY}
int64 args[1];
assert(_settings_game.locale.units < lengthof(units));
args[0] = ConvertSpeedToDisplaySpeed(GetInt32(&argv) * 10 / 16);
@ -612,6 +618,13 @@ static char *FormatString(char *buff, const char *str, int64 *argv, uint casei,
break;
}
case SCC_HEIGHT: { // {HEIGHT}
int64 args[1] = {GetInt32(&argv) * units[_settings_game.locale.units].h_m >> units[_settings_game.locale.units].h_s};
buff = FormatString(buff, GetStringPtr(units[_settings_game.locale.units].height), args, modifier >> 24, last);
modifier = 0;
break;
}
case SCC_CURRENCY_COMPACT: // {CURRCOMPACT}
buff = FormatGenericCurrency(buff, _currency, GetInt64(&argv), true, last);
break;

View File

@ -56,6 +56,7 @@ enum StringControlCode {
SCC_WEIGHT_SHORT,
SCC_FORCE,
SCC_VELOCITY,
SCC_HEIGHT,
SCC_DATE_TINY,
SCC_DATE_SHORT,

View File

@ -77,6 +77,7 @@ static const CmdStruct _cmd_structs[] = {
{"WEIGHT_S", EmitSingleChar, SCC_WEIGHT_SHORT, 1, C_NONE},
{"FORCE", EmitSingleChar, SCC_FORCE, 1, C_NONE},
{"VELOCITY", EmitSingleChar, SCC_VELOCITY, 1, C_NONE},
{"HEIGHT", EmitSingleChar, SCC_HEIGHT, 1, C_NONE},
{"P", EmitPlural, 0, 0, C_DONTCOUNT}, // plural specifier
{"G", EmitGender, 0, 0, C_DONTCOUNT}, // gender specifier