From cac3d567306d853a2b65b7acd91735345430c6e9 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sun, 22 May 2005 15:03:03 +0000 Subject: [PATCH] GetModifierNames: use vector not set for easier interaction with Lua --- stepmania/src/CatalogXml.cpp | 4 ++-- stepmania/src/ThemeManager.cpp | 11 +++++++---- stepmania/src/ThemeManager.h | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/stepmania/src/CatalogXml.cpp b/stepmania/src/CatalogXml.cpp index 52aa963c05..2190eb2012 100644 --- a/stepmania/src/CatalogXml.cpp +++ b/stepmania/src/CatalogXml.cpp @@ -305,9 +305,9 @@ void SaveCatalogXml( LoadingWindow *loading_window ) } { - set modifiers; + vector modifiers; THEME->GetModifierNames( modifiers ); - for( set::const_iterator iter = modifiers.begin(); iter != modifiers.end(); iter++ ) + FOREACH_CONST( CString, modifiers, iter ) { XNode* pNode2 = pNode->AppendChild( "Modifier", *iter ); PlayerOptions po; diff --git a/stepmania/src/ThemeManager.cpp b/stepmania/src/ThemeManager.cpp index f68e851a6b..ba0f7590e0 100644 --- a/stepmania/src/ThemeManager.cpp +++ b/stepmania/src/ThemeManager.cpp @@ -808,7 +808,7 @@ CString ThemeManager::GetPathToG( const CString &sFileName, bool bOptional ) { C CString ThemeManager::GetPathToS( const CString &sFileName, bool bOptional ) { CString sClassName, sElement; FileNameToClassAndElement(sFileName,sClassName,sElement); return GetPathS(sClassName,sElement,bOptional); } CString ThemeManager::GetPathToO( const CString &sFileName, bool bOptional ) { CString sClassName, sElement; FileNameToClassAndElement(sFileName,sClassName,sElement); return GetPathO(sClassName,sElement,bOptional); } -void ThemeManager::GetModifierNames( set& AddTo ) +void ThemeManager::GetModifierNames( vector& AddTo ) { for( deque::const_iterator iter = g_vThemes.begin(); iter != g_vThemes.end(); @@ -818,7 +818,7 @@ void ThemeManager::GetModifierNames( set& AddTo ) if( cur ) { FOREACH_CONST_Attr( cur, p ) - AddTo.insert( p->m_sName ); + AddTo.push_back( p->m_sName ); } } } @@ -911,13 +911,16 @@ class LunaThemeManager : public Luna public: LunaThemeManager() { LUA->Register( Register ); } - static int GetMetric( T* p, lua_State *L ) { lua_pushstring(L, p->GetMetric(SArg(1),SArg(2)) ); return 1; } - static int GetPath( T* p, lua_State *L ) { lua_pushstring(L, p->GetPath((ElementCategory)IArg(1),SArg(2),SArg(3)) ); return 1; } + static int GetMetric( T* p, lua_State *L ) { lua_pushstring(L, p->GetMetric(SArg(1),SArg(2)) ); return 1; } + static int GetPath( T* p, lua_State *L ) { lua_pushstring(L, p->GetPath((ElementCategory)IArg(1),SArg(2),SArg(3)) ); return 1; } + static int GetModifierNames( T* p, lua_State *L ) { vector v; p->GetModifierNames(v); LuaHelpers::CreateTableFromArray(v,LUA->L); return 1; } static void Register(lua_State *L) { ADD_METHOD( GetMetric ) ADD_METHOD( GetPath ) + ADD_METHOD( GetModifierNames ) + Luna::Register( L ); // Add global singleton if constructed already. If it's not constructed yet, diff --git a/stepmania/src/ThemeManager.h b/stepmania/src/ThemeManager.h index e4145d5877..48d13523f2 100644 --- a/stepmania/src/ThemeManager.h +++ b/stepmania/src/ThemeManager.h @@ -48,7 +48,7 @@ public: CString GetCurThemeDir() const { return GetThemeDirFromName(m_sCurThemeName); }; void NextTheme(); void ReloadMetrics(); - void GetModifierNames( set& AddTo ); + void GetModifierNames( vector& AddTo ); static void EvaluateString( CString &sText );