Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

ThemeManager.h

Go to the documentation of this file.
00001 /* ThemeManager - Manages which graphics and sounds are loaded. Every time a sound or graphic is loaded, it gets the path from the ThemeManager. */ 00002 00003 #ifndef THEMEMANAGER_H 00004 #define THEMEMANAGER_H 00005 00006 #include "RageTypes.h" 00007 #include "RageTimer.h" 00008 #include <set> 00009 #include <deque> 00010 #include "Command.h" 00011 #include "ActorCommands.h" 00012 00013 class IThemeMetric; 00014 class IniFile; 00015 00016 enum ElementCategory { BGAnimations, Fonts, Graphics, Numbers, Sounds, Other, NUM_ELEMENT_CATEGORIES }; 00017 00018 struct Theme; 00019 00020 class ThemeManager 00021 { 00022 public: 00023 ThemeManager(); 00024 ~ThemeManager(); 00025 00026 void GetThemeNames( CStringArray& AddTo ); 00027 bool DoesThemeExist( const CString &sThemeName ); 00028 void GetLanguages( CStringArray& AddTo ); 00029 bool DoesLanguageExist( const CString &sLanguage ); 00030 void SwitchThemeAndLanguage( const CString &sThemeName, const CString &sLanguage ); 00031 void UpdateLuaGlobals(); 00032 CString GetCurThemeName() { return m_sCurThemeName; }; 00033 CString GetCurLanguage() { return m_sCurLanguage; }; 00034 CString GetCurThemeDir() { return GetThemeDirFromName(m_sCurThemeName); }; 00035 void NextTheme(); 00036 void ReloadMetrics(); 00037 void GetModifierNames( set<CString>& AddTo ); 00038 00039 static void EvaluateString( CString &sText ); 00040 00041 /* I renamed these for two reasons. The overload conflicts with the ones below: 00042 * GetPathToB( str, str ) was matching the ones below instead of these. It's also 00043 * easier to search for uses of obsolete functions if they have a different name. */ 00044 CString GetPath( ElementCategory category, const CString &sClassName, const CString &sElement, bool bOptional=false ); 00045 CString GetPathB( const CString &sClassName, const CString &sElement, bool bOptional=false ) { return GetPath(BGAnimations,sClassName,sElement,bOptional); }; 00046 CString GetPathF( const CString &sClassName, const CString &sElement, bool bOptional=false ) { return GetPath(Fonts,sClassName,sElement,bOptional); }; 00047 CString GetPathG( const CString &sClassName, const CString &sElement, bool bOptional=false ) { return GetPath(Graphics,sClassName,sElement,bOptional); }; 00048 CString GetPathS( const CString &sClassName, const CString &sElement, bool bOptional=false ) { return GetPath(Sounds,sClassName,sElement,bOptional); }; 00049 CString GetPathO( const CString &sClassName, const CString &sElement, bool bOptional=false ) { return GetPath(Other,sClassName,sElement,bOptional); }; 00050 00051 // TODO: remove these and update the places that use them 00052 CString GetPathToB( const CString &sFileName, bool bOptional=false ); 00053 CString GetPathToF( const CString &sFileName, bool bOptional=false ); 00054 CString GetPathToG( const CString &sFileName, bool bOptional=false ); 00055 CString GetPathToS( const CString &sFileName, bool bOptional=false ); 00056 CString GetPathToO( const CString &sFileName, bool bOptional=false ); 00057 00058 // TODO: Make these return values const refs. 00059 bool HasMetric( const CString &sClassName, const CString &sValueName ); 00060 CString GetMetricRaw( const CString &sClassName, const CString &sValueName ); 00061 CString GetMetric( const CString &sClassName, const CString &sValueName ); 00062 int GetMetricI( const CString &sClassName, const CString &sValueName ); 00063 float GetMetricF( const CString &sClassName, const CString &sValueName ); 00064 bool GetMetricB( const CString &sClassName, const CString &sValueName ); 00065 RageColor GetMetricC( const CString &sClassName, const CString &sValueName ); 00066 Commands GetMetricM( const CString &sClassName, const CString &sValueName ); 00067 apActorCommands GetMetricA( const CString &sClassName, const CString &sValueName ); 00068 00069 void GetMetric( const CString &sClassName, const CString &sValueName, CString &valueOut ) { valueOut = GetMetric( sClassName, sValueName ); } 00070 void GetMetric( const CString &sClassName, const CString &sValueName, int &valueOut ) { valueOut = GetMetricI( sClassName, sValueName ); } 00071 void GetMetric( const CString &sClassName, const CString &sValueName, float &valueOut ) { valueOut = GetMetricF( sClassName, sValueName ); } 00072 void GetMetric( const CString &sClassName, const CString &sValueName, bool &valueOut ) { valueOut = GetMetricB( sClassName, sValueName ); } 00073 void GetMetric( const CString &sClassName, const CString &sValueName, RageColor &valueOut ) { valueOut = GetMetricC( sClassName, sValueName ); } 00074 void GetMetric( const CString &sClassName, const CString &sValueName, Command &valueOut ); 00075 void GetMetric( const CString &sClassName, const CString &sValueName, apActorCommands &valueOut ); 00076 00077 // 00078 // For self-registering metrics 00079 // 00080 static void Subscribe( IThemeMetric *p ); 00081 static void Unsubscribe( IThemeMetric *p ); 00082 00083 00084 protected: 00085 void LoadThemeRecursive( deque<Theme> &theme, const CString &sThemeName ); 00086 bool GetMetricRaw( const CString &sClassName, const CString &sValueName, CString &ret, int level=0 ); 00087 CString GetPathToAndFallback( const CString &sThemeName, ElementCategory category, const CString &sClassName, const CString &sFile ); 00088 CString GetPathToRaw( const CString &sThemeName, ElementCategory category, const CString &sClassName, const CString &sFile ); 00089 static CString GetThemeDirFromName( const CString &sThemeName ); 00090 CString GetElementDir( const CString &sThemeName ); 00091 static CString GetMetricsIniPath( const CString &sThemeName ); 00092 static void GetLanguagesForTheme( const CString &sThemeName, CStringArray& asLanguagesOut ); 00093 static CString GetLanguageIniPath( const CString &sThemeName, const CString &sLanguage ); 00094 00095 CString m_sCurThemeName; 00096 CString m_sCurLanguage; 00097 }; 00098 00099 extern ThemeManager* THEME; // global and accessable from anywhere in our program 00100 00101 #endif 00102 00103 /* 00104 * (c) 2001-2004 Chris Danford 00105 * All rights reserved. 00106 * 00107 * Permission is hereby granted, free of charge, to any person obtaining a 00108 * copy of this software and associated documentation files (the 00109 * "Software"), to deal in the Software without restriction, including 00110 * without limitation the rights to use, copy, modify, merge, publish, 00111 * distribute, and/or sell copies of the Software, and to permit persons to 00112 * whom the Software is furnished to do so, provided that the above 00113 * copyright notice(s) and this permission notice appear in all copies of 00114 * the Software and that both the above copyright notice(s) and this 00115 * permission notice appear in supporting documentation. 00116 * 00117 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00118 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00119 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF 00120 * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS 00121 * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT 00122 * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 00123 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 00124 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00125 * PERFORMANCE OF THIS SOFTWARE. 00126 */

Generated on Thu Jan 27 20:57:34 2005 for StepMania by doxygen 1.3.7