Make the default NoteSkin a theme metric. That means we can't call GetNoteSkinNames() before the theme is loaded so split out the code to get the names of the the skins for a particular game.

This commit is contained in:
Steve Checkoway
2006-05-20 08:58:53 +00:00
parent 8de96799ad
commit df6d8cb6ba
3 changed files with 49 additions and 37 deletions
+1 -3
View File
@@ -2712,9 +2712,7 @@ const Game* GameManager::GetGameFromIndex( int index ) const
bool GameManager::IsGameEnabled( const Game *pGame ) const
{
vector<RString> asNoteSkins;
NOTESKIN->GetNoteSkinNames( pGame, asNoteSkins, false ); /* don't omit default */
return asNoteSkins.size() > 0;
return NOTESKIN->DoNoteSkinsExistForGame( pGame );
}
int GameManager::StepsTypeToNumTracks( StepsType st )
+42 -32
View File
@@ -17,12 +17,12 @@ NoteSkinManager* NOTESKIN = NULL; // global object accessable from anywhere in t
const RString NOTESKINS_DIR = "NoteSkins/";
const RString GAME_BASE_NOTESKIN_NAME = "default";
const RString GLOBAL_BASE_NOTESKIN_DIR = NOTESKINS_DIR + "common/default/";
static map<RString,RString> g_PathCache;
NoteSkinManager::NoteSkinManager()
{
GAME_BASE_NOTESKIN_NAME.Load( "NoteSkinManager", "GameBaseNoteSkin" );
m_pCurGame = NULL;
}
@@ -102,12 +102,51 @@ void NoteSkinManager::GetNoteSkinNames( vector<RString> &AddTo )
}
void NoteSkinManager::GetNoteSkinNames( const Game* pGame, vector<RString> &AddTo, bool bFilterDefault )
{
GetAllNoteSkinNamesForGame( pGame, AddTo );
/* Move "default" to the front if it exists. */
vector<RString>::iterator iter = find( AddTo.begin(), AddTo.end(), GAME_BASE_NOTESKIN_NAME.GetValue() );
if( iter != AddTo.end() )
{
AddTo.erase( iter );
if( !bFilterDefault || !PREFSMAN->m_bHideDefaultNoteSkin )
AddTo.insert( AddTo.begin(), GAME_BASE_NOTESKIN_NAME );
}
}
bool NoteSkinManager::DoesNoteSkinExist( const RString &sSkinName )
{
vector<RString> asSkinNames;
GetAllNoteSkinNamesForGame( GAMESTATE->m_pCurGame, asSkinNames );
for( unsigned i=0; i<asSkinNames.size(); i++ )
if( 0==stricmp(sSkinName, asSkinNames[i]) )
return true;
return false;
}
bool NoteSkinManager::DoNoteSkinsExistForGame( const Game *pGame )
{
vector<RString> asSkinNames;
GetAllNoteSkinNamesForGame( pGame, asSkinNames );
return !asSkinNames.empty();
}
RString NoteSkinManager::GetNoteSkinDir( const RString &sSkinName )
{
RString sGame = m_pCurGame->m_szName;
return NOTESKINS_DIR + sGame + "/" + sSkinName + "/";
}
void NoteSkinManager::GetAllNoteSkinNamesForGame( const Game *pGame, vector<RString> &AddTo )
{
if( pGame == m_pCurGame )
{
/* Faster: */
for( map<RString,NoteSkinData>::const_iterator iter = m_mapNameToData.begin();
iter != m_mapNameToData.end(); ++iter )
iter != m_mapNameToData.end(); ++iter )
{
AddTo.push_back( iter->second.sName );
}
@@ -118,36 +157,7 @@ void NoteSkinManager::GetNoteSkinNames( const Game* pGame, vector<RString> &AddT
GetDirListing( sBaseSkinFolder + "*", AddTo, true );
StripCvs( AddTo );
}
/* Move "default" to the front if it exists. */
{
vector<RString>::iterator iter = find( AddTo.begin(), AddTo.end(), "default" );
if( iter != AddTo.end() )
{
AddTo.erase( iter );
if( !bFilterDefault || !PREFSMAN->m_bHideDefaultNoteSkin )
AddTo.insert( AddTo.begin(), "default" );
}
}
}
bool NoteSkinManager::DoesNoteSkinExist( const RString &sSkinName )
{
vector<RString> asSkinNames;
GetNoteSkinNames( asSkinNames );
for( unsigned i=0; i<asSkinNames.size(); i++ )
if( 0==stricmp(sSkinName, asSkinNames[i]) )
return true;
return false;
}
RString NoteSkinManager::GetNoteSkinDir( const RString &sSkinName )
{
RString sGame = m_pCurGame->m_szName;
return NOTESKINS_DIR + sGame + "/" + sSkinName + "/";
}
}
RString NoteSkinManager::GetMetric( const RString &sButtonName, const RString &sValue )
{
+6 -2
View File
@@ -7,6 +7,7 @@
#include "RageTypes.h"
#include "PlayerNumber.h"
#include "IniFile.h"
#include "ThemeMetric.h"
#include <map>
#include <deque>
@@ -22,6 +23,7 @@ public:
void GetNoteSkinNames( const Game* game, vector<RString> &AddTo, bool bFilterDefault=true );
void GetNoteSkinNames( vector<RString> &AddTo ); // looks up current const Game* in GAMESTATE
bool DoesNoteSkinExist( const RString &sNoteSkin ); // looks up current const Game* in GAMESTATE
bool DoNoteSkinsExistForGame( const Game *pGame );
void SetCurrentNoteSkin( const RString &sNoteSkin ) { m_sCurrentNoteSkin = sNoteSkin; }
const RString &GetCurrentNoteSkin() { return m_sCurrentNoteSkin; }
@@ -29,10 +31,11 @@ public:
RString GetPath( const RString &sButtonName, const RString &sElement );
RString GetMetric( const RString &sButtonName, const RString &sValue );
int GetMetricI( const RString &sButtonName, const RString &sValueName );
int GetMetricI( const RString &sButtonName, const RString &sValueName );
float GetMetricF( const RString &sButtonName, const RString &sValueName );
bool GetMetricB( const RString &sButtonName, const RString &sValueName );
apActorCommands GetMetricA( const RString &sButtonName, const RString &sValueName );
apActorCommands GetMetricA( const RString &sButtonName, const RString &sValueName );
ThemeMetric<RString> GAME_BASE_NOTESKIN_NAME;
// Lua
void PushSelf( lua_State *L );
@@ -40,6 +43,7 @@ public:
protected:
RString GetNoteSkinDir( const RString &sSkinName );
RString GetPathFromDirAndFile( const RString &sDir, const RString &sFileName );
void GetAllNoteSkinNamesForGame( const Game *pGame, vector<RString> &AddTo );
struct NoteSkinData
{