"XToThemedString" uses theme metrics. We don't want DateTime

(used by XmlFile) to depend on THEME, so use localized strings.

We may *always* want LocalizedString.  One reason we may not
is if we start using the DynamicThemeMetric paradigm more.
That evaluates expressions when they're used, which allows
metrics to change dynamically.  However, we may really not
want to do that for localized strings, since it would complicate
translation, so we may want to restrict localized strings to
pre-evaluation anyway.
This commit is contained in:
Glenn Maynard
2005-12-30 07:24:30 +00:00
parent b9f3b4a790
commit 6e6fcb746a
3 changed files with 17 additions and 12 deletions
+4 -10
View File
@@ -2,10 +2,8 @@
#include "DateTime.h"
#include "RageUtil.h"
#include "EnumHelper.h"
#if !defined(SMPACKAGE)
#include "ThemeMetric.h"
#endif
#include "LuaFunctions.h"
#include "LocalizedString.h"
DateTime::DateTime()
{
@@ -196,10 +194,8 @@ static const CString MonthNames[] =
"November",
"December",
};
XToString( Month, MONTHS_IN_YEAR );
#if !defined(SMPACKAGE)
XToThemedString( Month, MONTHS_IN_YEAR );
#endif
XToString( Month, NUM_Month );
XToLocalizedString( Month );
CString LastWeekToString( int iLastWeekIndex )
{
@@ -308,9 +304,7 @@ tm GetDayInYearAndYear( int iDayInYearIndex, int iYear )
}
LuaFunction( MonthToString, MonthToString( (Month)IArg(1) ) );
#if !defined(SMPACKAGE)
LuaFunction( MonthToThemedString, MonthToThemedString( (Month)IArg(1) ) );
#endif
LuaFunction( MonthToLocalizedString, MonthToLocalizedString( (Month)IArg(1) ) );
LuaFunction( MonthOfYear, GetLocalTime().tm_mon );
LuaFunction( DayOfMonth, GetLocalTime().tm_mday );
LuaFunction( Hour, GetLocalTime().tm_hour );
+2 -2
View File
@@ -8,7 +8,7 @@ const int NUM_LAST_WEEKS = 52;
const int DAYS_IN_YEAR = 366; // maximum (leap years)
const int HOURS_IN_DAY = 24;
const int DAYS_IN_WEEK = 7;
enum Month { MONTHS_IN_YEAR = 12 };
enum Month { NUM_Month = 12 };
CString DayInYearToString( int iDayInYearIndex );
CString LastDayToString( int iLastDayIndex );
@@ -18,7 +18,7 @@ CString DayOfWeekToThemedString( int iDayOfWeekIndex );
CString HourInDayToString( int iHourIndex );
CString HourInDayToThemedString( int iHourIndex );
const CString &MonthToString( Month month );
const CString &MonthToThemedString( Month month );
const CString &MonthToLocalizedString( Month month );
CString LastWeekToString( int iLastWeekIndex );
CString LastWeekToThemedString( int iLastWeekIndex );
+11
View File
@@ -68,6 +68,17 @@ static const CString EMPTY_STRING;
return g_##X##Name[x]; \
}
#define XToLocalizedString(X) \
const CString &X##ToLocalizedString( X x ) \
{ \
static auto_ptr<LocalizedString> g_##X##Name[NUM_##X]; \
if( g_##X##Name[0].get() == NULL ) { \
for( unsigned i = 0; i < NUM_##X; ++i ) \
g_##X##Name[i].reset( new LocalizedString(#X, X##ToString((X)i)) ); \
} \
return g_##X##Name[x]->GetValue(); \
}
#define StringToX(X) \
X StringTo##X( const CString& s ) \
{ \