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:
@@ -2712,9 +2712,7 @@ const Game* GameManager::GetGameFromIndex( int index ) const
|
|||||||
|
|
||||||
bool GameManager::IsGameEnabled( const Game *pGame ) const
|
bool GameManager::IsGameEnabled( const Game *pGame ) const
|
||||||
{
|
{
|
||||||
vector<RString> asNoteSkins;
|
return NOTESKIN->DoNoteSkinsExistForGame( pGame );
|
||||||
NOTESKIN->GetNoteSkinNames( pGame, asNoteSkins, false ); /* don't omit default */
|
|
||||||
return asNoteSkins.size() > 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int GameManager::StepsTypeToNumTracks( StepsType st )
|
int GameManager::StepsTypeToNumTracks( StepsType st )
|
||||||
|
|||||||
@@ -17,12 +17,12 @@ NoteSkinManager* NOTESKIN = NULL; // global object accessable from anywhere in t
|
|||||||
|
|
||||||
|
|
||||||
const RString NOTESKINS_DIR = "NoteSkins/";
|
const RString NOTESKINS_DIR = "NoteSkins/";
|
||||||
const RString GAME_BASE_NOTESKIN_NAME = "default";
|
|
||||||
const RString GLOBAL_BASE_NOTESKIN_DIR = NOTESKINS_DIR + "common/default/";
|
const RString GLOBAL_BASE_NOTESKIN_DIR = NOTESKINS_DIR + "common/default/";
|
||||||
static map<RString,RString> g_PathCache;
|
static map<RString,RString> g_PathCache;
|
||||||
|
|
||||||
NoteSkinManager::NoteSkinManager()
|
NoteSkinManager::NoteSkinManager()
|
||||||
{
|
{
|
||||||
|
GAME_BASE_NOTESKIN_NAME.Load( "NoteSkinManager", "GameBaseNoteSkin" );
|
||||||
m_pCurGame = NULL;
|
m_pCurGame = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,6 +102,45 @@ void NoteSkinManager::GetNoteSkinNames( vector<RString> &AddTo )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void NoteSkinManager::GetNoteSkinNames( const Game* pGame, vector<RString> &AddTo, bool bFilterDefault )
|
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 )
|
if( pGame == m_pCurGame )
|
||||||
{
|
{
|
||||||
@@ -118,35 +157,6 @@ void NoteSkinManager::GetNoteSkinNames( const Game* pGame, vector<RString> &AddT
|
|||||||
GetDirListing( sBaseSkinFolder + "*", AddTo, true );
|
GetDirListing( sBaseSkinFolder + "*", AddTo, true );
|
||||||
StripCvs( AddTo );
|
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 )
|
RString NoteSkinManager::GetMetric( const RString &sButtonName, const RString &sValue )
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "RageTypes.h"
|
#include "RageTypes.h"
|
||||||
#include "PlayerNumber.h"
|
#include "PlayerNumber.h"
|
||||||
#include "IniFile.h"
|
#include "IniFile.h"
|
||||||
|
#include "ThemeMetric.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
||||||
@@ -22,6 +23,7 @@ public:
|
|||||||
void GetNoteSkinNames( const Game* game, vector<RString> &AddTo, bool bFilterDefault=true );
|
void GetNoteSkinNames( const Game* game, vector<RString> &AddTo, bool bFilterDefault=true );
|
||||||
void GetNoteSkinNames( vector<RString> &AddTo ); // looks up current const Game* in GAMESTATE
|
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 DoesNoteSkinExist( const RString &sNoteSkin ); // looks up current const Game* in GAMESTATE
|
||||||
|
bool DoNoteSkinsExistForGame( const Game *pGame );
|
||||||
|
|
||||||
void SetCurrentNoteSkin( const RString &sNoteSkin ) { m_sCurrentNoteSkin = sNoteSkin; }
|
void SetCurrentNoteSkin( const RString &sNoteSkin ) { m_sCurrentNoteSkin = sNoteSkin; }
|
||||||
const RString &GetCurrentNoteSkin() { return m_sCurrentNoteSkin; }
|
const RString &GetCurrentNoteSkin() { return m_sCurrentNoteSkin; }
|
||||||
@@ -33,6 +35,7 @@ public:
|
|||||||
float GetMetricF( const RString &sButtonName, const RString &sValueName );
|
float GetMetricF( const RString &sButtonName, const RString &sValueName );
|
||||||
bool GetMetricB( 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
|
// Lua
|
||||||
void PushSelf( lua_State *L );
|
void PushSelf( lua_State *L );
|
||||||
@@ -40,6 +43,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
RString GetNoteSkinDir( const RString &sSkinName );
|
RString GetNoteSkinDir( const RString &sSkinName );
|
||||||
RString GetPathFromDirAndFile( const RString &sDir, const RString &sFileName );
|
RString GetPathFromDirAndFile( const RString &sDir, const RString &sFileName );
|
||||||
|
void GetAllNoteSkinNamesForGame( const Game *pGame, vector<RString> &AddTo );
|
||||||
|
|
||||||
struct NoteSkinData
|
struct NoteSkinData
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user