home *** CD-ROM | disk | FTP | other *** search
/ Game Level Design / GLDesign.bin / Software / UnrealEngine2Runtime / UE2Runtime-22262001_Demo.exe / Core / Classes / Locale.uc < prev    next >
Text File  |  2003-08-27  |  7KB  |  225 lines

  1. //=============================================================================
  2. /// Locale: Locale management class.
  3. /// Not yet implemented.
  4. /// This is a built-in Unreal class and it shouldn't be modified.
  5. //=============================================================================
  6. class Locale
  7.     extends Object
  8.     transient;
  9.  
  10. /*
  11. //
  12. // Information about this locale.
  13. //
  14.  
  15. //!!System.GetLocale( language, variant, local )
  16. ///@reference: !!look at java getISO3Language for std 3-char language abbreviations
  17. var const string ISO3Language;
  18. var const localized string DisplayLanguage;
  19.  
  20. //
  21. // Locale language support.
  22. //
  23.  
  24. /// Returns the currently active language's ISO 3 language code.
  25. native function string GetLanguage();
  26.  
  27. /// Returns the localized, human-readable display name of the ISO 3 language code Language.
  28. native function string GetDisplayLanguage( string Language );
  29.  
  30. /// Set the current ISO 3 language. Causes all class' and objects' localized variables to be reloaded.
  31. native function bool SetLanguage( string NewLanguage );
  32.  
  33. //
  34. // Locale string processing.
  35. //
  36.  
  37. /// Convert to locale-specific uppercase.
  38. function string ToUpper( string S );
  39.  
  40. /// Convert to locale-specific lowercase.
  41. function string ToLower( string S );
  42.  
  43. /// Compare two strings using locale-specific sorting.
  44. function int Compare( string A, string B );
  45.  
  46. //
  47. // Locale number and currency handling.
  48. //
  49.  
  50. /// Leading and trailing percentage symbols.
  51. var const localized string PrePercent, PostPercent;
  52.  
  53. /// Leading and trailing currency symbols.
  54. var const localized string PreCurrencySymbol, PostCurrencySymbol;
  55.  
  56. /// Percentage scale, i.e. 100 for 100%.
  57. var const localized int PercentScaler;
  58.  
  59. /// Number of digits between "thousands" delimitor.
  60. var const localized int ThousandsCount, ThousandsCountCurrency;
  61.  
  62. /// Positive and negative currency indicators.
  63. var const localized string
  64.     PrePositiveCurrency, PostPositiveCurrency,
  65.     PreNegativeCurrency, PostNegativeCurrency;
  66.  
  67. // Thousands delimitor.
  68. var const localized string ThousandsDelimitor, ThousandsDelimitorCurrency;
  69.  
  70. // Decimal point.
  71. var const localized string Decimal, DecimalCurrency;
  72.  
  73. // Decimal count.
  74. var const localized int DecimalCount;
  75.  
  76. /// Convert a float number to a string using the locale's formatting instructions.
  77. function string NumberToString( float Number );
  78.  
  79. /// Convert a float number to a currency string using the locale's formatting instructions.
  80. function string CurrencyToString( float Currency );
  81.  
  82. /// Convert a fraction from 0.0-1.0 to a percentage string.
  83. function string PercentToString( float Fraction )
  84. {
  85.     return PrePercent $ int(Fraction * PercentScaler) $ PostPercent;
  86. }
  87.  
  88. //
  89. // Locale date and time support.
  90. //
  91.  
  92. /// Human readable names of months.
  93. var const localized string Months[12];
  94.  
  95. /// Human readable names of days-of-week.
  96. var const localized string DaysOfWeek[7];
  97.  
  98. /// Human-readable AM/PM.
  99. var const localized string AMPM[2];
  100.  
  101. /// Whether to display AM/PM, otherwise uses 24-hour notation.
  102. var const localized ShowAMPM;
  103.  
  104. /// List of TimeToMap fields which should be exposed for editing in this locale.
  105. var const localized array<string> EditableTimeFields;
  106.  
  107. /// Format string for generating human-readable time in AM/PM and 24-hour formats; 
  108. /// may be ignored by Locale subclasses who display times using a different calendar,
  109. /// for example Chinese.
  110. var const localized string
  111.     TimeFormatAMPM, TimeFormat24Hour,
  112.     BriefTimeFormatAMPM, BriefTimeFormat24Hour,
  113.     CountdownTimeFormat;
  114.  
  115. /// Format string for generating human-readable dates.
  116. var const localized string DateFormat;
  117.  
  118. /// Return a map containing time parameters suitable for formatting.
  119. function map<string,string> DateTimeToMap( long T )
  120. {
  121.     local map<string,string> M;
  122.     M.Set("Year",       Time.GetYear(T));
  123.     M.Set("Month",      Time.GetMonth(T));
  124.     M.Set("MonthName",  Months(Time.GetMonth(T)));
  125.     M.Set("Day",        Time.GetDay(T));
  126.     M.Set("DayName",    DaysOfWeek(Time.GetDay(T)));
  127.     M.Set("Hour24",     Time.GetHour(T));
  128.     M.Set("Hour12",     Time.GetHour(T)%12);
  129.     M.Set("AMPM",       AMPM(Time.GetHour(T)/12);
  130.     M.Set("Minute",     Time.GetMinute(T));
  131.     M.Set("Second",     Time.GetSecond(T));
  132.     M.Set("MSec",       Time.GetMSec(T));
  133.     M.Set("USec",       Time.GetUSec(T));
  134.     M.Set("NSec",       Time.GetNSec(T));
  135.     return M;
  136. }
  137.  
  138. /// Convert a map of TimeToMap key-values to a time; returns true if successful.
  139. function bool MapToDateTime( map<string,string> Map, out long T )
  140. {
  141.     //!!
  142. }
  143.  
  144. /// Converts the time to a human-readable string, depending on the current locale.
  145. function string TimeToString( long T, bool Brief, bool Countdown )
  146. {
  147.     local string S;
  148.     if( Brief )
  149.     {
  150.         if( ShowAMPM ) S = BriefTimeFormatAMPM;
  151.         else           S = BriefTimeFormat24Hour, 
  152.     }
  153.     else if( !Countdown )
  154.     {
  155.         if( ShowAMPM ) S = TimeFormatAMPM;
  156.         else           S = TimeFormat24Hour, 
  157.     }
  158.     else
  159.     {
  160.         S = CountdownTimeFormat;
  161.     }
  162.     return string.Format( S, DateTimeToMap(T) );
  163. }
  164.  
  165. // Convert the date to a human-readable string, depending on the current locale.
  166. function string DateToString( long T )
  167. {
  168.     return string.Format( DateFormat, DateTimeToMap(T) );
  169. }
  170.  
  171. _defaultproperties
  172. {
  173.     Months(0)=January
  174.     Months(1)=February
  175.     Months(2)=March
  176.     Months(3)=April
  177.     Months(4)=May
  178.     Months(5)=June
  179.     Months(6)=July
  180.     Months(7)=August
  181.     Months(8)=September
  182.     Months(9)=October
  183.     Months(10)=November
  184.     Months(11)=December
  185.     DaysOfWeek(0)=Sunday
  186.     DaysOfWeek(1)=Monday
  187.     DaysOfWeek(2)=Tuesday
  188.     DaysOfWeek(3)=Wednesday
  189.     DaysOfWeek(4)=Thursday
  190.     DaysOfWeek(5)=Friday
  191.     DaysOfWeek(6)=Saturday
  192.     AMPM(0)=AM
  193.     AMPM(1)=PM
  194.     TimeFormatAMPM=%Hour12:02%.%Minute:02%.%Seconds:02% %AMPM%
  195.     TimeFormat24Hour=%Hour24:02%.%Minute:02%.%Seconds:02%
  196.     BriefTimeFormatAMPM=%Hour12:02%.%Minute:02% %AMPM%
  197.     BriefTimeFormat24Hour=%Hour24:02%.%Minute:02%
  198.     CountdownTimeFormat=%Hour24:02%.%Minute:02%.%Seconds:02%
  199.     DateFormat=%DayName% %MonthName% %Day%, %Year%
  200.     EditableTimeFields(0)=Year
  201.     EditableTimeFields(1)=Month
  202.     EditableTimeFields(2)=Day
  203.     EditableTimeFields(3)=Hour12
  204.     EditableTimeFields(4)=AMPM
  205.     EditableTimeFields(5)=Minute
  206.     EditableTimeFields(6)=Second
  207.     PreCurrencySymbol=$
  208.     PostCurrencySymbol=
  209.     PrePercent=
  210.     PostPercent=%
  211.     PercentScaler=100
  212.     ThousandsCount=1000
  213.     ThousandsCountCurrency=1000
  214.     ThousandsDelimitor=","
  215.     ThousandsDelimitorCurrency=","
  216.     Decimal="."
  217.     DecimalCurrency="."
  218.     PrePositiveCurrency=
  219.     PostPositiveCurrency=
  220.     PreNegativeCurrency=-
  221.     PostNegativeCurrency=
  222.     DecimalCount=2
  223. }
  224. */
  225.