changeset 15129:a37985a1cfca draft

(svn r19758) -Add: {HEIGHT} string command
author rubidium <rubidium@openttd.org>
date Tue, 04 May 2010 22:04:28 +0000
parents f8fb58b4a217
children 2b703bc86ec8
files src/lang/english.txt src/strings.cpp src/table/control_codes.h src/table/strgen_tables.h
diffstat 4 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -215,6 +215,9 @@
 
 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
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -508,6 +508,9 @@
 	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 @@
 		   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 @@
 		   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 @@
 		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 @@
 				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 @@
 				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;
--- a/src/table/control_codes.h
+++ b/src/table/control_codes.h
@@ -56,6 +56,7 @@
 	SCC_WEIGHT_SHORT,
 	SCC_FORCE,
 	SCC_VELOCITY,
+	SCC_HEIGHT,
 
 	SCC_DATE_TINY,
 	SCC_DATE_SHORT,
--- a/src/table/strgen_tables.h
+++ b/src/table/strgen_tables.h
@@ -77,6 +77,7 @@
 	{"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