Files
itgmania212121/stepmania/src/ThemeManager.h
T

148 lines
7.4 KiB
C++
Raw Normal View History

2005-02-13 02:45:47 +00:00
/* ThemeManager - Manages theme paths and metrics. */
2004-06-08 01:24:17 +00:00
#ifndef THEMEMANAGER_H
#define THEMEMANAGER_H
2002-01-16 10:01:32 +00:00
#include "RageTypes.h"
#include "RageTimer.h"
2004-07-19 08:05:14 +00:00
#include <set>
2004-08-10 04:33:36 +00:00
#include <deque>
2005-01-26 11:21:43 +00:00
#include "Command.h"
#include "ActorCommands.h"
2002-01-16 10:01:32 +00:00
class IThemeMetric;
2002-09-07 11:45:15 +00:00
class IniFile;
2005-02-12 22:52:24 +00:00
struct lua_State;
2002-01-16 10:01:32 +00:00
2005-02-28 04:10:01 +00:00
enum ElementCategory
{
ELEMENT_CATEGORY_BGANIMATIONS,
ELEMENT_CATEGORY_FONTS,
ELEMENT_CATEGORY_GRAPHICS,
ELEMENT_CATEGORY_NUMBERS,
ELEMENT_CATEGORY_SOUNDS,
ELEMENT_CATEGORY_OTHER,
NUM_ELEMENT_CATEGORIES
};
#define FOREACH_ElementCategory( ec ) FOREACH_ENUM( ElementCategory, NUM_ELEMENT_CATEGORIES, ec )
const CString& ElementCategoryToString( ElementCategory ec );
ElementCategory StringToElementCategory( const CString& s );
2004-08-10 04:33:36 +00:00
struct Theme;
2002-01-16 10:01:32 +00:00
class ThemeManager
{
public:
ThemeManager();
~ThemeManager();
void GetThemeNames( CStringArray& AddTo );
2004-11-06 06:34:21 +00:00
bool DoesThemeExist( const CString &sThemeName );
2003-08-19 08:01:15 +00:00
void GetLanguages( CStringArray& AddTo );
2004-11-06 06:34:21 +00:00
bool DoesLanguageExist( const CString &sLanguage );
void SwitchThemeAndLanguage( const CString &sThemeName, const CString &sLanguage );
2005-01-09 01:31:06 +00:00
void UpdateLuaGlobals();
CString GetCurThemeName() const { return m_sCurThemeName; };
bool IsThemeLoaded() const { return !m_sCurThemeName.empty(); };
CString GetCurLanguage() const { return m_sCurLanguage; };
CString GetCurThemeDir() const { return GetThemeDirFromName(m_sCurThemeName); };
void NextTheme();
void ReloadMetrics();
2004-07-19 08:05:14 +00:00
void GetModifierNames( set<CString>& AddTo );
2002-07-23 01:41:40 +00:00
static void EvaluateString( CString &sText );
/* I renamed these for two reasons. The overload conflicts with the ones below:
* 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. */
2004-11-06 06:34:21 +00:00
CString GetPath( ElementCategory category, const CString &sClassName, const CString &sElement, bool bOptional=false );
2005-02-28 04:10:01 +00:00
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); };
2005-03-20 05:39:32 +00:00
void ClearThemePathCache();
// TODO: remove these and update the places that use them
2004-11-06 06:34:21 +00:00
CString GetPathToB( const CString &sFileName, bool bOptional=false );
CString GetPathToF( const CString &sFileName, bool bOptional=false );
CString GetPathToG( const CString &sFileName, bool bOptional=false );
CString GetPathToS( const CString &sFileName, bool bOptional=false );
CString GetPathToO( const CString &sFileName, bool bOptional=false );
// TODO: Make these return values const refs.
2004-11-06 06:34:21 +00:00
bool HasMetric( const CString &sClassName, const CString &sValueName );
CString GetMetricRaw( const CString &sClassName, const CString &sValueName );
CString GetMetric( const CString &sClassName, const CString &sValueName );
int GetMetricI( const CString &sClassName, const CString &sValueName );
float GetMetricF( const CString &sClassName, const CString &sValueName );
bool GetMetricB( const CString &sClassName, const CString &sValueName );
RageColor GetMetricC( const CString &sClassName, const CString &sValueName );
2005-01-26 11:21:43 +00:00
Commands GetMetricM( const CString &sClassName, const CString &sValueName );
apActorCommands GetMetricA( const CString &sClassName, const CString &sValueName );
void GetMetric( const CString &sClassName, const CString &sValueName, CString &valueOut ) { valueOut = GetMetric( sClassName, sValueName ); }
void GetMetric( const CString &sClassName, const CString &sValueName, int &valueOut ) { valueOut = GetMetricI( sClassName, sValueName ); }
void GetMetric( const CString &sClassName, const CString &sValueName, float &valueOut ) { valueOut = GetMetricF( sClassName, sValueName ); }
void GetMetric( const CString &sClassName, const CString &sValueName, bool &valueOut ) { valueOut = GetMetricB( sClassName, sValueName ); }
void GetMetric( const CString &sClassName, const CString &sValueName, RageColor &valueOut ) { valueOut = GetMetricC( sClassName, sValueName ); }
2005-01-26 11:21:43 +00:00
void GetMetric( const CString &sClassName, const CString &sValueName, Command &valueOut );
2005-02-17 06:09:08 +00:00
void GetMetric( const CString &sClassName, const CString &sValueName, LuaExpression &valueOut );
2005-01-26 11:21:43 +00:00
void GetMetric( const CString &sClassName, const CString &sValueName, apActorCommands &valueOut );
void GetMetricsThatBeginWith( const CString &sClassName, const CString &sValueName, set<CString> &vsValueNamesOut );
//
// For self-registering metrics
//
static void Subscribe( IThemeMetric *p );
static void Unsubscribe( IThemeMetric *p );
2005-02-12 22:52:24 +00:00
// Lua
void PushSelf( lua_State *L );
2002-01-16 10:01:32 +00:00
protected:
void RunLuaScripts( const CString &sMask );
2004-11-06 06:34:21 +00:00
void LoadThemeRecursive( deque<Theme> &theme, const CString &sThemeName );
bool GetMetricRaw( const CString &sClassName, const CString &sValueName, CString &ret, int level=0 );
CString GetPathToAndFallback( const CString &sThemeName, ElementCategory category, const CString &sClassName, const CString &sFile );
CString GetPathToRaw( const CString &sThemeName, ElementCategory category, const CString &sClassName, const CString &sFile );
2003-01-23 04:41:57 +00:00
static CString GetThemeDirFromName( const CString &sThemeName );
2004-11-06 06:34:21 +00:00
CString GetElementDir( const CString &sThemeName );
static CString GetMetricsIniPath( const CString &sThemeName );
static void GetLanguagesForTheme( const CString &sThemeName, CStringArray& asLanguagesOut );
static CString GetLanguageIniPath( const CString &sThemeName, const CString &sLanguage );
2002-01-16 10:01:32 +00:00
CString m_sCurThemeName;
2003-08-19 08:01:15 +00:00
CString m_sCurLanguage;
2002-01-16 10:01:32 +00:00
};
extern ThemeManager* THEME; // global and accessable from anywhere in our program
#endif
2004-06-08 01:24:17 +00:00
/*
* (c) 2001-2004 Chris Danford
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/