Files
itgmania212121/stepmania/src/ThemeManager.h
T

157 lines
7.3 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"
2004-07-19 08:05:14 +00:00
#include <set>
2004-08-10 04:33:36 +00:00
#include <deque>
2005-12-29 05:52:50 +00:00
#if !defined(SMPACKAGE)
#include "Actor.h"
2005-12-29 05:52:50 +00:00
#endif
#include "LuaReference.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
{
2005-05-27 09:22:57 +00:00
EC_BGANIMATIONS,
EC_FONTS,
EC_GRAPHICS,
EC_SOUNDS,
EC_OTHER,
NUM_ElementCategory
2005-02-28 04:10:01 +00:00
};
2005-05-27 09:22:57 +00:00
#define FOREACH_ElementCategory( ec ) FOREACH_ENUM( ElementCategory, NUM_ElementCategory, ec )
2005-12-27 17:45:07 +00:00
const RString& ElementCategoryToString( ElementCategory ec );
ElementCategory StringToElementCategory( const RString& s );
2004-08-10 04:33:36 +00:00
struct Theme;
2002-01-16 10:01:32 +00:00
class ThemeManager
{
public:
ThemeManager();
~ThemeManager();
2005-12-27 17:45:07 +00:00
void GetThemeNames( vector<RString>& AddTo );
void GetSelectableThemeNames( vector<RString>& AddTo );
int GetNumSelectableThemes();
2005-12-27 17:45:07 +00:00
bool DoesThemeExist( const RString &sThemeName );
2006-06-14 07:46:31 +00:00
bool IsThemeSelectable( const RString &sThemeName );
RString GetThemeDisplayName( const RString &sThemeName );
2005-12-27 17:45:07 +00:00
void GetLanguages( vector<RString>& AddTo );
bool DoesLanguageExist( const RString &sLanguage );
void SwitchThemeAndLanguage( const RString &sThemeName, const RString &sLanguage, bool bPseudoLocalize );
2005-01-09 01:31:06 +00:00
void UpdateLuaGlobals();
2005-12-27 17:45:07 +00:00
RString GetCurThemeName() const { return m_sCurThemeName; };
bool IsThemeLoaded() const { return !m_sCurThemeName.empty(); };
2005-12-27 17:45:07 +00:00
RString GetCurLanguage() const { return m_sCurLanguage; };
RString GetCurThemeDir() const { return GetThemeDirFromName(m_sCurThemeName); };
2006-09-20 23:10:15 +00:00
RString GetNextTheme();
void ReloadMetrics();
void ReloadSubscribers();
2006-09-20 23:05:52 +00:00
void ClearSubscribers();
void GetOptionNames( vector<RString>& AddTo );
2002-07-23 01:41:40 +00:00
2005-12-27 17:45:07 +00:00
static void EvaluateString( RString &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. */
2005-12-27 17:45:07 +00:00
RString GetPath( ElementCategory category, const RString &sClassName, const RString &sElement, bool bOptional=false );
RString GetPathB( const RString &sClassName, const RString &sElement, bool bOptional=false ) { return GetPath(EC_BGANIMATIONS,sClassName,sElement,bOptional); };
RString GetPathF( const RString &sClassName, const RString &sElement, bool bOptional=false ) { return GetPath(EC_FONTS,sClassName,sElement,bOptional); };
RString GetPathG( const RString &sClassName, const RString &sElement, bool bOptional=false ) { return GetPath(EC_GRAPHICS,sClassName,sElement,bOptional); };
RString GetPathS( const RString &sClassName, const RString &sElement, bool bOptional=false ) { return GetPath(EC_SOUNDS,sClassName,sElement,bOptional); };
RString GetPathO( const RString &sClassName, const RString &sElement, bool bOptional=false ) { return GetPath(EC_OTHER,sClassName,sElement,bOptional); };
2005-03-20 05:39:32 +00:00
void ClearThemePathCache();
2005-12-27 17:45:07 +00:00
bool HasMetric( const RString &sClassName, const RString &sValueName );
RString GetMetric( const RString &sClassName, const RString &sValueName );
2006-06-24 05:13:54 +00:00
int GetMetricI( const RString &sClassName, const RString &sValueName );
2005-12-27 17:45:07 +00:00
float GetMetricF( const RString &sClassName, const RString &sValueName );
bool GetMetricB( const RString &sClassName, const RString &sValueName );
RageColor GetMetricC( const RString &sClassName, const RString &sValueName );
2005-12-29 05:52:50 +00:00
#if !defined(SMPACKAGE)
2005-12-27 17:45:07 +00:00
apActorCommands GetMetricA( const RString &sClassName, const RString &sValueName );
2005-12-29 05:52:50 +00:00
#endif
2005-12-27 17:45:07 +00:00
void GetMetric( const RString &sClassName, const RString &sValueName, RString &valueOut ) { valueOut = GetMetric( sClassName, sValueName ); }
void GetMetric( const RString &sClassName, const RString &sValueName, int &valueOut ) { valueOut = GetMetricI( sClassName, sValueName ); }
void GetMetric( const RString &sClassName, const RString &sValueName, float &valueOut ) { valueOut = GetMetricF( sClassName, sValueName ); }
void GetMetric( const RString &sClassName, const RString &sValueName, bool &valueOut ) { valueOut = GetMetricB( sClassName, sValueName ); }
void GetMetric( const RString &sClassName, const RString &sValueName, RageColor &valueOut ) { valueOut = GetMetricC( sClassName, sValueName ); }
2005-12-29 05:52:50 +00:00
#if !defined(SMPACKAGE)
2005-12-27 17:45:07 +00:00
void GetMetric( const RString &sClassName, const RString &sValueName, apActorCommands &valueOut );
2005-12-29 05:52:50 +00:00
#endif
2005-12-27 17:45:07 +00:00
2006-01-06 20:18:15 +00:00
// Languages
2006-06-24 05:13:54 +00:00
bool HasString( const RString &sClassName, const RString &sValueName );
RString GetString( const RString &sClassName, const RString &sValueName );
void GetString( const RString &sClassName, const RString &sValueName, RString &valueOut ) { valueOut = GetString( sClassName, sValueName ); }
2006-03-02 04:59:37 +00:00
void FilterFileLanguages( vector<RString> &asElementPaths );
2005-12-27 17:45:07 +00:00
void GetMetricsThatBeginWith( const RString &sClassName, const RString &sValueName, set<RString> &vsValueNamesOut );
static RString GetBlankGraphicPath();
2005-05-27 09:22:57 +00:00
//
// 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:
2005-12-27 17:45:07 +00:00
void RunLuaScripts( const RString &sMask );
void LoadThemeMetrics( deque<Theme> &theme, const RString &sThemeName, const RString &sLanguage_ );
2006-09-21 03:39:11 +00:00
RString GetMetricRaw( const IniFile &ini, const RString &sClassName, const RString &sValueName );
2006-06-24 05:13:54 +00:00
bool GetMetricRawRecursive( const IniFile &ini, const RString &sClassName, const RString &sValueName, RString &sRet );
2005-12-27 17:45:07 +00:00
RString GetPathToAndFallback( ElementCategory category, const RString &sClassName, const RString &sFile );
RString GetPathToRaw( const RString &sThemeName, ElementCategory category, const RString &sClassName, const RString &sFile );
static RString GetThemeDirFromName( const RString &sThemeName );
RString GetElementDir( const RString &sThemeName );
static RString GetMetricsIniPath( const RString &sThemeName );
static void GetLanguagesForTheme( const RString &sThemeName, vector<RString>& asLanguagesOut );
static RString GetLanguageIniPath( const RString &sThemeName, const RString &sLanguage );
RString GetDefaultLanguage();
RString m_sCurThemeName;
RString m_sCurLanguage;
bool m_bPseudoLocalize;
2002-01-16 10:01:32 +00:00
};
2003-02-17 12:19:42 +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.
*/