diff --git a/Docs/Changelog_sm5.txt b/Docs/Changelog_sm5.txt index 765a6d50cc..f5ffad4fb5 100644 --- a/Docs/Changelog_sm5.txt +++ b/Docs/Changelog_sm5.txt @@ -11,6 +11,7 @@ StepMania 5.0 $next | 2011???? 2011/09/26 ---------- * [Default theme] Added Song Timing Display user preference. [AJ] +* [ThemeManager] Add global Scripts dir. [shakesoda] 2011/09/25 ---------- diff --git a/Scripts/0.lua b/Scripts/0.lua new file mode 100644 index 0000000000..ce25c1c10b --- /dev/null +++ b/Scripts/0.lua @@ -0,0 +1 @@ +-- need this here for hg? \ No newline at end of file diff --git a/src/ThemeManager.cpp b/src/ThemeManager.cpp index a0cb8b2d57..6d714f1234 100644 --- a/src/ThemeManager.cpp +++ b/src/ThemeManager.cpp @@ -445,7 +445,7 @@ void ThemeManager::ClearSubscribers() } } -void ThemeManager::RunLuaScripts( const RString &sMask ) +void ThemeManager::RunLuaScripts( const RString &sMask, bool bUseThemeDir ) { /* Run all script files with the given mask in Lua for all themes. Start * from the deepest fallback theme and work outwards. */ @@ -463,13 +463,13 @@ void ThemeManager::RunLuaScripts( const RString &sMask ) * scripts call GetThemeName(), it'll return the theme the script is in. */ m_sCurThemeName = iter->sThemeName; - const RString &sThemeDir = GetThemeDirFromName( m_sCurThemeName ); + const RString &sThemeDir = bUseThemeDir ? GetThemeDirFromName( m_sCurThemeName ) : "/"; vector asElementPaths; // get files from directories vector asElementChildPaths; vector arrayScriptDirs; - GetDirListing( sThemeDir + "Scripts/*", arrayScriptDirs, true ); + GetDirListing( sScriptDir + "Scripts/*", arrayScriptDirs, true ); SortRStringArray( arrayScriptDirs ); StripCvsAndSvn( arrayScriptDirs ); StripMacResourceForks( arrayScriptDirs ); @@ -477,7 +477,7 @@ void ThemeManager::RunLuaScripts( const RString &sMask ) { // Find all Lua files in this directory, add them to asElementPaths RString sScriptDirName = *s; - GetDirListing( sThemeDir + "Scripts/" + sScriptDirName + "/" + sMask, asElementChildPaths, false, true ); + GetDirListing( sScriptDir + "Scripts/" + sScriptDirName + "/" + sMask, asElementChildPaths, false, true ); for( unsigned i = 0; i < asElementChildPaths.size(); ++i ) { // push these Lua files into the main element paths @@ -487,7 +487,7 @@ void ThemeManager::RunLuaScripts( const RString &sMask ) } // get regular Lua files - GetDirListing( sThemeDir + "Scripts/" + sMask, asElementPaths, false, true ); + GetDirListing( sScriptDir + "Scripts/" + sMask, asElementPaths, false, true ); // load Lua files for( unsigned i = 0; i < asElementPaths.size(); ++i ) @@ -513,7 +513,10 @@ void ThemeManager::UpdateLuaGlobals() // explicitly refresh cached metrics that we use. ScreenDimensions::ReloadScreenDimensions(); + // run global scripts RunLuaScripts( "*.lua" ); + // run theme scripts + RunLuaScripts( "*.lua", true ); #endif } diff --git a/src/ThemeManager.h b/src/ThemeManager.h index 24610521fd..3bb9f3008f 100644 --- a/src/ThemeManager.h +++ b/src/ThemeManager.h @@ -99,7 +99,7 @@ public: static RString GetBlankGraphicPath(); //needs to be public for its binding to work - void RunLuaScripts( const RString &sMask ); + void RunLuaScripts( const RString &sMask, bool bUseThemeDir = false ); // For self-registering metrics static void Subscribe( IThemeMetric *p );