From 544820e8cd501581d4ddd0211f8a2f958fe06804 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 2 Feb 2005 06:53:31 +0000 Subject: [PATCH] cache XToThemedString --- stepmania/src/Difficulty.cpp | 6 +++--- stepmania/src/EnumHelper.h | 13 ++++++++++--- stepmania/src/GameConstantsAndTypes.cpp | 14 +++++++------- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/stepmania/src/Difficulty.cpp b/stepmania/src/Difficulty.cpp index 37b6cd4a7b..9986bed873 100644 --- a/stepmania/src/Difficulty.cpp +++ b/stepmania/src/Difficulty.cpp @@ -1,7 +1,7 @@ #include "global.h" #include "Difficulty.h" #include "GameState.h" -#include "ThemeManager.h" +#include "ThemeMetric.h" static const CString DifficultyNames[NUM_DIFFICULTIES] = { @@ -13,7 +13,7 @@ static const CString DifficultyNames[NUM_DIFFICULTIES] = { "Edit", }; XToString( Difficulty ); -XToThemedString( Difficulty ); +XToThemedString( Difficulty, NUM_DIFFICULTIES ); /* We prefer the above names; recognize a number of others, too. (They'l * get normalized when written to SMs, etc.) */ @@ -52,7 +52,7 @@ static const CString CourseDifficultyNames[NUM_DIFFICULTIES] = "(not used)", }; XToString( CourseDifficulty ); -XToThemedString( CourseDifficulty ); +XToThemedString( CourseDifficulty, NUM_DIFFICULTIES ); StringToX( CourseDifficulty ); CourseDifficulty GetNextShownCourseDifficulty( CourseDifficulty cd ) diff --git a/stepmania/src/EnumHelper.h b/stepmania/src/EnumHelper.h index a5f0f468a1..c8bb6884c1 100644 --- a/stepmania/src/EnumHelper.h +++ b/stepmania/src/EnumHelper.h @@ -46,10 +46,17 @@ static const CString EMPTY_STRING; return X##Names[x]; \ } -#define XToThemedString(X) \ +#define XToThemedString(X, CNT) \ + static ThemeMetric g_##X##Name[CNT]; \ CString X##ToThemedString( X x ) \ - { \ - return THEME->GetMetric( #X, X##ToString(x) ); \ + { \ + static bool bInitted = false; \ + if( !bInitted ) { \ + bInitted = true; \ + for( unsigned i = 0; i < CNT; ++i ) \ + g_##X##Name[i].Load( #X, X##ToString((X)i) ); \ + } \ + return g_##X##Name[x]; \ } #define StringToX(X) \ diff --git a/stepmania/src/GameConstantsAndTypes.cpp b/stepmania/src/GameConstantsAndTypes.cpp index 395a2e8665..9ebe490d62 100644 --- a/stepmania/src/GameConstantsAndTypes.cpp +++ b/stepmania/src/GameConstantsAndTypes.cpp @@ -2,7 +2,7 @@ #include "GameConstantsAndTypes.h" #include "GameState.h" #include "RageUtil.h" -#include "ThemeManager.h" +#include "ThemeMetric.h" #include "EnumHelper.h" #include "Foreach.h" #include "PrefsManager.h" @@ -21,7 +21,7 @@ static const CString RadarCategoryNames[NUM_RADAR_CATEGORIES] = { "Hands", }; XToString( RadarCategory ); -XToThemedString( RadarCategory ); +XToThemedString( RadarCategory, NUM_RADAR_CATEGORIES ); static const CString PlayModeNames[NUM_PLAY_MODES] = { @@ -33,7 +33,7 @@ static const CString PlayModeNames[NUM_PLAY_MODES] = { "Rave", }; XToString( PlayMode ); -XToThemedString( PlayMode ); +XToThemedString( PlayMode, NUM_PLAY_MODES ); StringToX( PlayMode ); @@ -107,7 +107,7 @@ static const CString TapNoteScoreNames[NUM_TAP_NOTE_SCORES] = { }; XToString( TapNoteScore ); StringToX( TapNoteScore ); -XToThemedString( TapNoteScore ); +XToThemedString( TapNoteScore, NUM_TAP_NOTE_SCORES ); static const CString HoldNoteScoreNames[NUM_HOLD_NOTE_SCORES] = { @@ -117,7 +117,7 @@ static const CString HoldNoteScoreNames[NUM_HOLD_NOTE_SCORES] = { }; XToString( HoldNoteScore ); StringToX( HoldNoteScore ); -XToThemedString( HoldNoteScore ); +XToThemedString( HoldNoteScore, NUM_HOLD_NOTE_SCORES ); static const CString MemoryCardStateNames[NUM_MEMORY_CARD_STATES] = { @@ -142,7 +142,7 @@ static const CString PerDifficultyAwardNames[NUM_PER_DIFFICULTY_AWARDS] = { "Greats100Percent", }; XToString( PerDifficultyAward ); -XToThemedString( PerDifficultyAward ); +XToThemedString( PerDifficultyAward, NUM_PER_DIFFICULTY_AWARDS ); StringToX( PerDifficultyAward ); @@ -163,7 +163,7 @@ static const CString PeakComboAwardNames[NUM_PEAK_COMBO_AWARDS] = { "Peak10000Combo", }; XToString( PeakComboAward ); -XToThemedString( PeakComboAward ); +XToThemedString( PeakComboAward, NUM_PEAK_COMBO_AWARDS ); StringToX( PeakComboAward );