[ThemeManager] Add global Scripts dir. [originally by shakesoda from broken]
This commit is contained in:
@@ -11,6 +11,7 @@ StepMania 5.0 $next | 2011????
|
|||||||
2011/09/26
|
2011/09/26
|
||||||
----------
|
----------
|
||||||
* [Default theme] Added Song Timing Display user preference. [AJ]
|
* [Default theme] Added Song Timing Display user preference. [AJ]
|
||||||
|
* [ThemeManager] Add global Scripts dir. [shakesoda]
|
||||||
|
|
||||||
2011/09/25
|
2011/09/25
|
||||||
----------
|
----------
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
-- need this here for hg?
|
||||||
@@ -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
|
/* Run all script files with the given mask in Lua for all themes. Start
|
||||||
* from the deepest fallback theme and work outwards. */
|
* 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. */
|
* scripts call GetThemeName(), it'll return the theme the script is in. */
|
||||||
|
|
||||||
m_sCurThemeName = iter->sThemeName;
|
m_sCurThemeName = iter->sThemeName;
|
||||||
const RString &sThemeDir = GetThemeDirFromName( m_sCurThemeName );
|
const RString &sThemeDir = bUseThemeDir ? GetThemeDirFromName( m_sCurThemeName ) : "/";
|
||||||
|
|
||||||
vector<RString> asElementPaths;
|
vector<RString> asElementPaths;
|
||||||
// get files from directories
|
// get files from directories
|
||||||
vector<RString> asElementChildPaths;
|
vector<RString> asElementChildPaths;
|
||||||
vector<RString> arrayScriptDirs;
|
vector<RString> arrayScriptDirs;
|
||||||
GetDirListing( sThemeDir + "Scripts/*", arrayScriptDirs, true );
|
GetDirListing( sScriptDir + "Scripts/*", arrayScriptDirs, true );
|
||||||
SortRStringArray( arrayScriptDirs );
|
SortRStringArray( arrayScriptDirs );
|
||||||
StripCvsAndSvn( arrayScriptDirs );
|
StripCvsAndSvn( arrayScriptDirs );
|
||||||
StripMacResourceForks( arrayScriptDirs );
|
StripMacResourceForks( arrayScriptDirs );
|
||||||
@@ -477,7 +477,7 @@ void ThemeManager::RunLuaScripts( const RString &sMask )
|
|||||||
{
|
{
|
||||||
// Find all Lua files in this directory, add them to asElementPaths
|
// Find all Lua files in this directory, add them to asElementPaths
|
||||||
RString sScriptDirName = *s;
|
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 )
|
for( unsigned i = 0; i < asElementChildPaths.size(); ++i )
|
||||||
{
|
{
|
||||||
// push these Lua files into the main element paths
|
// push these Lua files into the main element paths
|
||||||
@@ -487,7 +487,7 @@ void ThemeManager::RunLuaScripts( const RString &sMask )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get regular Lua files
|
// get regular Lua files
|
||||||
GetDirListing( sThemeDir + "Scripts/" + sMask, asElementPaths, false, true );
|
GetDirListing( sScriptDir + "Scripts/" + sMask, asElementPaths, false, true );
|
||||||
|
|
||||||
// load Lua files
|
// load Lua files
|
||||||
for( unsigned i = 0; i < asElementPaths.size(); ++i )
|
for( unsigned i = 0; i < asElementPaths.size(); ++i )
|
||||||
@@ -513,7 +513,10 @@ void ThemeManager::UpdateLuaGlobals()
|
|||||||
// explicitly refresh cached metrics that we use.
|
// explicitly refresh cached metrics that we use.
|
||||||
ScreenDimensions::ReloadScreenDimensions();
|
ScreenDimensions::ReloadScreenDimensions();
|
||||||
|
|
||||||
|
// run global scripts
|
||||||
RunLuaScripts( "*.lua" );
|
RunLuaScripts( "*.lua" );
|
||||||
|
// run theme scripts
|
||||||
|
RunLuaScripts( "*.lua", true );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -99,7 +99,7 @@ public:
|
|||||||
static RString GetBlankGraphicPath();
|
static RString GetBlankGraphicPath();
|
||||||
|
|
||||||
//needs to be public for its binding to work
|
//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
|
// For self-registering metrics
|
||||||
static void Subscribe( IThemeMetric *p );
|
static void Subscribe( IThemeMetric *p );
|
||||||
|
|||||||
Reference in New Issue
Block a user