move some singleton data out of the header
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
#include "PrefsManager.h"
|
#include "PrefsManager.h"
|
||||||
#include "Foreach.h"
|
#include "Foreach.h"
|
||||||
#include "ActorUtil.h"
|
#include "ActorUtil.h"
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
|
||||||
NoteSkinManager* NOTESKIN = NULL; // global object accessable from anywhere in the program
|
NoteSkinManager* NOTESKIN = NULL; // global object accessable from anywhere in the program
|
||||||
@@ -20,6 +21,20 @@ const RString NOTESKINS_DIR = "NoteSkins/";
|
|||||||
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;
|
||||||
|
|
||||||
|
struct NoteSkinData
|
||||||
|
{
|
||||||
|
RString sName;
|
||||||
|
IniFile metrics;
|
||||||
|
|
||||||
|
// When looking for an element, search these dirs from head to tail.
|
||||||
|
vector<RString> vsDirSearchOrder;
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
static map<RString,NoteSkinData> g_mapNameToData;
|
||||||
|
};
|
||||||
|
|
||||||
NoteSkinManager::NoteSkinManager()
|
NoteSkinManager::NoteSkinManager()
|
||||||
{
|
{
|
||||||
GAME_BASE_NOTESKIN_NAME.Load( "NoteSkinManager", "GameBaseNoteSkin" );
|
GAME_BASE_NOTESKIN_NAME.Load( "NoteSkinManager", "GameBaseNoteSkin" );
|
||||||
@@ -39,6 +54,8 @@ NoteSkinManager::~NoteSkinManager()
|
|||||||
{
|
{
|
||||||
// Unregister with Lua.
|
// Unregister with Lua.
|
||||||
LUA->UnsetGlobal( "NOTESKIN" );
|
LUA->UnsetGlobal( "NOTESKIN" );
|
||||||
|
|
||||||
|
g_mapNameToData.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NoteSkinManager::RefreshNoteSkinData( const Game* pGame )
|
void NoteSkinManager::RefreshNoteSkinData( const Game* pGame )
|
||||||
@@ -56,12 +73,12 @@ void NoteSkinManager::RefreshNoteSkinData( const Game* pGame )
|
|||||||
|
|
||||||
StripCvs( asNoteSkinNames );
|
StripCvs( asNoteSkinNames );
|
||||||
|
|
||||||
m_mapNameToData.clear();
|
g_mapNameToData.clear();
|
||||||
for( unsigned j=0; j<asNoteSkinNames.size(); j++ )
|
for( unsigned j=0; j<asNoteSkinNames.size(); j++ )
|
||||||
{
|
{
|
||||||
RString sName = asNoteSkinNames[j];
|
RString sName = asNoteSkinNames[j];
|
||||||
sName.MakeLower();
|
sName.MakeLower();
|
||||||
LoadNoteSkinData( sName, m_mapNameToData[sName] );
|
LoadNoteSkinData( sName, g_mapNameToData[sName] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,8 +172,8 @@ void NoteSkinManager::GetAllNoteSkinNamesForGame( const Game *pGame, vector<RStr
|
|||||||
if( pGame == m_pCurGame )
|
if( pGame == m_pCurGame )
|
||||||
{
|
{
|
||||||
/* Faster: */
|
/* Faster: */
|
||||||
for( map<RString,NoteSkinData>::const_iterator iter = m_mapNameToData.begin();
|
for( map<RString,NoteSkinData>::const_iterator iter = g_mapNameToData.begin();
|
||||||
iter != m_mapNameToData.end(); ++iter )
|
iter != g_mapNameToData.end(); ++iter )
|
||||||
{
|
{
|
||||||
AddTo.push_back( iter->second.sName );
|
AddTo.push_back( iter->second.sName );
|
||||||
}
|
}
|
||||||
@@ -174,8 +191,8 @@ RString NoteSkinManager::GetMetric( const RString &sButtonName, const RString &s
|
|||||||
ASSERT( !m_sCurrentNoteSkin.empty() );
|
ASSERT( !m_sCurrentNoteSkin.empty() );
|
||||||
RString sNoteSkinName = m_sCurrentNoteSkin;
|
RString sNoteSkinName = m_sCurrentNoteSkin;
|
||||||
sNoteSkinName.MakeLower();
|
sNoteSkinName.MakeLower();
|
||||||
map<RString,NoteSkinData>::const_iterator it = m_mapNameToData.find(sNoteSkinName);
|
map<RString,NoteSkinData>::const_iterator it = g_mapNameToData.find(sNoteSkinName);
|
||||||
ASSERT_M( it != m_mapNameToData.end(), sNoteSkinName ); // this NoteSkin doesn't exist!
|
ASSERT_M( it != g_mapNameToData.end(), sNoteSkinName ); // this NoteSkin doesn't exist!
|
||||||
const NoteSkinData& data = it->second;
|
const NoteSkinData& data = it->second;
|
||||||
|
|
||||||
RString sReturn;
|
RString sReturn;
|
||||||
@@ -215,8 +232,8 @@ try_again:
|
|||||||
if( it != g_PathCache.end() )
|
if( it != g_PathCache.end() )
|
||||||
return it->second;
|
return it->second;
|
||||||
|
|
||||||
map<RString,NoteSkinData>::const_iterator iter = m_mapNameToData.find( m_sCurrentNoteSkin );
|
map<RString,NoteSkinData>::const_iterator iter = g_mapNameToData.find( m_sCurrentNoteSkin );
|
||||||
ASSERT( iter != m_mapNameToData.end() );
|
ASSERT( iter != g_mapNameToData.end() );
|
||||||
const NoteSkinData &data = iter->second;
|
const NoteSkinData &data = iter->second;
|
||||||
|
|
||||||
RString sPath; // fill this in below
|
RString sPath; // fill this in below
|
||||||
|
|||||||
@@ -8,9 +8,9 @@
|
|||||||
#include "PlayerNumber.h"
|
#include "PlayerNumber.h"
|
||||||
#include "IniFile.h"
|
#include "IniFile.h"
|
||||||
#include "ThemeMetric.h"
|
#include "ThemeMetric.h"
|
||||||
#include <map>
|
|
||||||
|
|
||||||
class Game;
|
class Game;
|
||||||
|
struct NoteSkinData;
|
||||||
|
|
||||||
class NoteSkinManager
|
class NoteSkinManager
|
||||||
{
|
{
|
||||||
@@ -44,18 +44,9 @@ protected:
|
|||||||
RString GetPathFromDirAndFile( const RString &sDir, const RString &sFileName );
|
RString GetPathFromDirAndFile( const RString &sDir, const RString &sFileName );
|
||||||
void GetAllNoteSkinNamesForGame( const Game *pGame, vector<RString> &AddTo );
|
void GetAllNoteSkinNamesForGame( const Game *pGame, vector<RString> &AddTo );
|
||||||
|
|
||||||
struct NoteSkinData
|
|
||||||
{
|
|
||||||
RString sName;
|
|
||||||
IniFile metrics;
|
|
||||||
|
|
||||||
// When looking for an element, search these dirs from head to tail.
|
|
||||||
vector<RString> vsDirSearchOrder;
|
|
||||||
};
|
|
||||||
void LoadNoteSkinData( const RString &sNoteSkinName, NoteSkinData& data_out );
|
void LoadNoteSkinData( const RString &sNoteSkinName, NoteSkinData& data_out );
|
||||||
void LoadNoteSkinDataRecursive( const RString &sNoteSkinName, NoteSkinData& data_out );
|
void LoadNoteSkinDataRecursive( const RString &sNoteSkinName, NoteSkinData& data_out );
|
||||||
RString m_sCurrentNoteSkin;
|
RString m_sCurrentNoteSkin;
|
||||||
map<RString,NoteSkinData> m_mapNameToData;
|
|
||||||
const Game* m_pCurGame;
|
const Game* m_pCurGame;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user