diff --git a/stepmania/src/ThemeManager.cpp b/stepmania/src/ThemeManager.cpp index d9afe606ac..a87496d0d3 100644 --- a/stepmania/src/ThemeManager.cpp +++ b/stepmania/src/ThemeManager.cpp @@ -32,7 +32,7 @@ static const CString ElementCategoryNames[] = { "Sounds", "Other" }; -XToString( ElementCategory, NUM_ELEMENT_CATEGORIES ); +XToString( ElementCategory, NUM_ElementCategory ); StringToX( ElementCategory ); static void LuaElementCategory(lua_State* L) { @@ -40,7 +40,7 @@ static void LuaElementCategory(lua_State* L) { CString s = ElementCategoryNames[ec]; s.MakeUpper(); - LUA->SetGlobal( "ELEMENT_CATEGORY_"+s, ec ); + LUA->SetGlobal( "EC_"+s, ec ); } } REGISTER_WITH_LUA_FUNCTION( LuaElementCategory ); @@ -89,10 +89,10 @@ void ThemeManager::Unsubscribe( IThemeMetric *p ) /* We spend a lot of time doing redundant theme path lookups. Cache results. */ -static map g_ThemePathCache[NUM_ELEMENT_CATEGORIES]; +static map g_ThemePathCache[NUM_ElementCategory]; void ThemeManager::ClearThemePathCache() { - for( int i = 0; i < NUM_ELEMENT_CATEGORIES; ++i ) + for( int i = 0; i < NUM_ElementCategory; ++i ) g_ThemePathCache[i].clear(); } @@ -245,7 +245,7 @@ void ThemeManager::SwitchThemeAndLanguage( const CString &sThemeName, const CStr m_sCurLanguage = sLang; // clear theme path cache - for( int i = 0; i < NUM_ELEMENT_CATEGORIES; ++i ) + for( int i = 0; i < NUM_ElementCategory; ++i ) g_ThemePathCache[i].clear(); g_vThemes.clear(); @@ -391,7 +391,7 @@ try_element_again: for( unsigned p = 0; p < asPaths.size(); ++p ) { - static const char *masks[NUM_ELEMENT_CATEGORIES][13] = { + static const char *masks[NUM_ElementCategory][13] = { { "", "actor", "xml", NULL }, { "ini", NULL }, { "xml", "actor", "sprite", "png", "jpg", "bmp", "gif","avi", "mpg", "mpeg", "txt", "", NULL}, @@ -420,7 +420,7 @@ try_element_again: } } - if( category == ELEMENT_CATEGORY_FONTS ) + if( category == EC_FONTS ) Font::WeedFontNames(asElementPaths, ClassAndElementToFileName(sClassName,sElement)); } @@ -428,8 +428,8 @@ try_element_again: if( asElementPaths.size() == 0 ) { // HACK: have Fonts fall back to Numbers. Eventually Numbers will be removed. - if( category == ELEMENT_CATEGORY_FONTS ) - return GetPathToRaw( sThemeName, ELEMENT_CATEGORY_NUMBERS, sClassName, sElement ) ; + if( category == EC_FONTS ) + return GetPathToRaw( sThemeName, EC_NUMBERS, sClassName, sElement ) ; return ""; // This isn't fatal. } @@ -474,7 +474,7 @@ try_element_again: FileNameToClassAndElement(sNewFileName, sNewClassName, sNewFile); /* backwards-compatibility hack */ - if( category == ELEMENT_CATEGORY_FONTS ) + if( category == EC_FONTS ) sNewFileName.Replace(" 16x16.png", ""); /* Search again. For example, themes/default/Fonts/foo might redir @@ -554,7 +554,7 @@ try_element_again: /* We can't fall back on _missing in Other: the file types are unknown. */ CString sMessage = "The theme element \"" + sCategory + "/" + sFileName +"\" is missing."; Dialog::Result res; - if( category != ELEMENT_CATEGORY_OTHER ) + if( category != EC_OTHER ) res = Dialog::AbortRetryIgnore(sMessage, "MissingThemeElement"); else res = Dialog::AbortRetry(sMessage, "MissingThemeElement"); @@ -617,7 +617,7 @@ void ThemeManager::ReloadMetrics() // // clear theme path cache // - for( int i = 0; i < NUM_ELEMENT_CATEGORIES; ++i ) + for( int i = 0; i < NUM_ElementCategory; ++i ) g_ThemePathCache[i].clear(); } @@ -905,6 +905,11 @@ void ThemeManager::LoadPreferencesFromSection( const CString &sClassName ) } } +CString ThemeManager::GetBlankGraphicPath() +{ + return THEMES_DIR + BASE_THEME_NAME + "/" + ElementCategoryToString(EC_GRAPHICS) + "/_blank"; +} + // lua start #include "LuaBinding.h" diff --git a/stepmania/src/ThemeManager.h b/stepmania/src/ThemeManager.h index 48d13523f2..bc810336ec 100644 --- a/stepmania/src/ThemeManager.h +++ b/stepmania/src/ThemeManager.h @@ -16,15 +16,15 @@ struct lua_State; enum ElementCategory { - ELEMENT_CATEGORY_BGANIMATIONS, - ELEMENT_CATEGORY_FONTS, - ELEMENT_CATEGORY_GRAPHICS, - ELEMENT_CATEGORY_NUMBERS, - ELEMENT_CATEGORY_SOUNDS, - ELEMENT_CATEGORY_OTHER, - NUM_ELEMENT_CATEGORIES + EC_BGANIMATIONS, + EC_FONTS, + EC_GRAPHICS, + EC_NUMBERS, + EC_SOUNDS, + EC_OTHER, + NUM_ElementCategory }; -#define FOREACH_ElementCategory( ec ) FOREACH_ENUM( ElementCategory, NUM_ELEMENT_CATEGORIES, ec ) +#define FOREACH_ElementCategory( ec ) FOREACH_ENUM( ElementCategory, NUM_ElementCategory, ec ) const CString& ElementCategoryToString( ElementCategory ec ); ElementCategory StringToElementCategory( const CString& s ); @@ -56,11 +56,11 @@ public: * GetPathToB( str, str ) was matching the ones below instead of these. It's also * easier to search for uses of obsolete functions if they have a different name. */ CString GetPath( ElementCategory category, const CString &sClassName, const CString &sElement, bool bOptional=false ); - CString GetPathB( const CString &sClassName, const CString &sElement, bool bOptional=false ) { return GetPath(ELEMENT_CATEGORY_BGANIMATIONS,sClassName,sElement,bOptional); }; - CString GetPathF( const CString &sClassName, const CString &sElement, bool bOptional=false ) { return GetPath(ELEMENT_CATEGORY_FONTS,sClassName,sElement,bOptional); }; - CString GetPathG( const CString &sClassName, const CString &sElement, bool bOptional=false ) { return GetPath(ELEMENT_CATEGORY_GRAPHICS,sClassName,sElement,bOptional); }; - CString GetPathS( const CString &sClassName, const CString &sElement, bool bOptional=false ) { return GetPath(ELEMENT_CATEGORY_SOUNDS,sClassName,sElement,bOptional); }; - CString GetPathO( const CString &sClassName, const CString &sElement, bool bOptional=false ) { return GetPath(ELEMENT_CATEGORY_OTHER,sClassName,sElement,bOptional); }; + CString GetPathB( const CString &sClassName, const CString &sElement, bool bOptional=false ) { return GetPath(EC_BGANIMATIONS,sClassName,sElement,bOptional); }; + CString GetPathF( const CString &sClassName, const CString &sElement, bool bOptional=false ) { return GetPath(EC_FONTS,sClassName,sElement,bOptional); }; + CString GetPathG( const CString &sClassName, const CString &sElement, bool bOptional=false ) { return GetPath(EC_GRAPHICS,sClassName,sElement,bOptional); }; + CString GetPathS( const CString &sClassName, const CString &sElement, bool bOptional=false ) { return GetPath(EC_SOUNDS,sClassName,sElement,bOptional); }; + CString GetPathO( const CString &sClassName, const CString &sElement, bool bOptional=false ) { return GetPath(EC_OTHER,sClassName,sElement,bOptional); }; void ClearThemePathCache(); // TODO: remove these and update the places that use them @@ -93,6 +93,8 @@ public: void GetMetricsThatBeginWith( const CString &sClassName, const CString &sValueName, set &vsValueNamesOut ); void LoadPreferencesFromSection( const CString &sClassName ); + static CString GetBlankGraphicPath(); + // // For self-registering metrics //