Changed NoteSkinManager to use new error reporting and avoid crashing. Fixed DoChangeTheme to switch to the InitialScreen if the screen doesn't exist in the theme being changed to. Fixed error reporting in MeterDisplay.
This commit is contained in:
@@ -37,7 +37,11 @@ void StepsDisplayList::LoadFromNode( const XNode* pNode )
|
|||||||
{
|
{
|
||||||
ActorFrame::LoadFromNode( pNode );
|
ActorFrame::LoadFromNode( pNode );
|
||||||
|
|
||||||
ASSERT_M( !m_sName.empty(), "StepsDisplayList must have a Name" );
|
if(m_sName.empty())
|
||||||
|
{
|
||||||
|
LuaHelpers::ReportScriptError("StepsDisplayList must have a Name");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ITEMS_SPACING_Y.Load( m_sName, "ItemsSpacingY" );
|
ITEMS_SPACING_Y.Load( m_sName, "ItemsSpacingY" );
|
||||||
NUM_SHOWN_ITEMS.Load( m_sName, "NumShownItems" );
|
NUM_SHOWN_ITEMS.Load( m_sName, "NumShownItems" );
|
||||||
|
|||||||
@@ -145,6 +145,13 @@ namespace
|
|||||||
|
|
||||||
StepMania::ResetGame();
|
StepMania::ResetGame();
|
||||||
SCREENMAN->ThemeChanged();
|
SCREENMAN->ThemeChanged();
|
||||||
|
// Not all themes use the same screen names! Check whether the new
|
||||||
|
// screen is valid in the new theme before setting it. Use the
|
||||||
|
// InitialScreen metric if it's not.
|
||||||
|
if(!SCREENMAN->IsScreenNameValid(g_sNewScreen))
|
||||||
|
{
|
||||||
|
g_sNewScreen= THEME->GetMetric("Common", "InitialScreen");
|
||||||
|
}
|
||||||
SCREENMAN->SetNewScreen( g_sNewScreen );
|
SCREENMAN->SetNewScreen( g_sNewScreen );
|
||||||
|
|
||||||
g_sNewTheme = RString();
|
g_sNewTheme = RString();
|
||||||
|
|||||||
+1
-1
@@ -223,7 +223,7 @@ void GameState::ApplyGameCommand( const RString &sCommand, PlayerNumber pn )
|
|||||||
RString sWhy;
|
RString sWhy;
|
||||||
if( !m.IsPlayable(&sWhy) )
|
if( !m.IsPlayable(&sWhy) )
|
||||||
{
|
{
|
||||||
LuaHelpers::ReportScriptErrorFmt("Can't apply mode \"%s\": %s", sCommand.c_str(), sWhy.c_str());
|
LuaHelpers::ReportScriptErrorFmt("Can't apply GameCommand \"%s\": %s", sCommand.c_str(), sWhy.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,11 +35,9 @@ void MeterDisplay::LoadFromNode( const XNode* pNode )
|
|||||||
if( pStream == NULL )
|
if( pStream == NULL )
|
||||||
{
|
{
|
||||||
LuaHelpers::ReportScriptErrorFmt("%s: MeterDisplay: missing the \"Stream\" attribute", ActorUtil::GetWhere(pNode).c_str());
|
LuaHelpers::ReportScriptErrorFmt("%s: MeterDisplay: missing the \"Stream\" attribute", ActorUtil::GetWhere(pNode).c_str());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
m_sprStream.LoadActorFromNode( pStream, this );
|
m_sprStream.LoadActorFromNode( pStream, this );
|
||||||
}
|
|
||||||
m_sprStream->SetName( "Stream" );
|
m_sprStream->SetName( "Stream" );
|
||||||
//LOAD_ALL_COMMANDS( m_sprStream );
|
//LOAD_ALL_COMMANDS( m_sprStream );
|
||||||
this->AddChild( m_sprStream );
|
this->AddChild( m_sprStream );
|
||||||
|
|||||||
+54
-22
@@ -112,7 +112,11 @@ void NoteSkinManager::LoadNoteSkinDataRecursive( const RString &sNoteSkinName_,
|
|||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
++iDepth;
|
++iDepth;
|
||||||
ASSERT_M( iDepth < 20, "Circular NoteSkin fallback references detected." );
|
if(iDepth >= 20)
|
||||||
|
{
|
||||||
|
LuaHelpers::ReportScriptError("Circular NoteSkin fallback references detected.", "NOTESKIN_ERROR");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
RString sDir = SpecialFiles::NOTESKINS_DIR + m_pCurGame->m_szName + "/" + sNoteSkinName + "/";
|
RString sDir = SpecialFiles::NOTESKINS_DIR + m_pCurGame->m_szName + "/" + sNoteSkinName + "/";
|
||||||
if( !FILEMAN->IsADirectory(sDir) )
|
if( !FILEMAN->IsADirectory(sDir) )
|
||||||
@@ -120,8 +124,9 @@ void NoteSkinManager::LoadNoteSkinDataRecursive( const RString &sNoteSkinName_,
|
|||||||
sDir = GLOBAL_BASE_DIR + sNoteSkinName + "/";
|
sDir = GLOBAL_BASE_DIR + sNoteSkinName + "/";
|
||||||
if( !FILEMAN->IsADirectory(sDir) )
|
if( !FILEMAN->IsADirectory(sDir) )
|
||||||
{
|
{
|
||||||
LOG->Trace( "NoteSkin \"%s\" references skin \"%s\" that is not present",
|
LuaHelpers::ReportScriptError("NoteSkin \"" + data_out.sName +
|
||||||
data_out.sName.c_str(), sNoteSkinName.c_str() );
|
"\" references skin \"" + sNoteSkinName + "\" that is not present",
|
||||||
|
"NOTESKIN_ERROR");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -234,7 +239,11 @@ void NoteSkinManager::GetAllNoteSkinNamesForGame( const Game *pGame, vector<RStr
|
|||||||
|
|
||||||
RString NoteSkinManager::GetMetric( const RString &sButtonName, const RString &sValue )
|
RString NoteSkinManager::GetMetric( const RString &sButtonName, const RString &sValue )
|
||||||
{
|
{
|
||||||
ASSERT( !m_sCurrentNoteSkin.empty() );
|
if(m_sCurrentNoteSkin.empty())
|
||||||
|
{
|
||||||
|
LuaHelpers::ReportScriptError("NOTESKIN:GetMetric: No noteskin currently set.", "NOTESKIN_ERROR");
|
||||||
|
return "";
|
||||||
|
}
|
||||||
RString sNoteSkinName = m_sCurrentNoteSkin;
|
RString sNoteSkinName = m_sCurrentNoteSkin;
|
||||||
sNoteSkinName.MakeLower();
|
sNoteSkinName.MakeLower();
|
||||||
map<RString,NoteSkinData>::const_iterator it = g_mapNameToData.find(sNoteSkinName);
|
map<RString,NoteSkinData>::const_iterator it = g_mapNameToData.find(sNoteSkinName);
|
||||||
@@ -245,8 +254,12 @@ RString NoteSkinManager::GetMetric( const RString &sButtonName, const RString &s
|
|||||||
if( data.metrics.GetValue( sButtonName, sValue, sReturn ) )
|
if( data.metrics.GetValue( sButtonName, sValue, sReturn ) )
|
||||||
return sReturn;
|
return sReturn;
|
||||||
if( !data.metrics.GetValue( "NoteDisplay", sValue, sReturn ) )
|
if( !data.metrics.GetValue( "NoteDisplay", sValue, sReturn ) )
|
||||||
RageException::Throw( "Could not read metric \"%s::%s\" or \"NoteDisplay::%s\" in \"%s\".",
|
{
|
||||||
sButtonName.c_str(), sValue.c_str(), sValue.c_str(), sNoteSkinName.c_str() );
|
LuaHelpers::ReportScriptError("Could not read metric \"" + sButtonName +
|
||||||
|
"::" + sValue + "\" or \"NoteDisplay::" + sValue + "\" in \"" +
|
||||||
|
sNoteSkinName + "\".", "NOTESKIN_ERROR");
|
||||||
|
return "";
|
||||||
|
}
|
||||||
return sReturn;
|
return sReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,15 +333,18 @@ RString NoteSkinManager::GetPath( const RString &sButtonName, const RString &sEl
|
|||||||
sButtonName.c_str(), sElement.c_str(),
|
sButtonName.c_str(), sElement.c_str(),
|
||||||
sPaths.c_str() );
|
sPaths.c_str() );
|
||||||
|
|
||||||
if( Dialog::AbortRetryIgnore(message) == Dialog::retry )
|
switch(LuaHelpers::ReportScriptError(message, "NOTESKIN_ERROR", true))
|
||||||
{
|
{
|
||||||
FOREACH_CONST( RString, data.vsDirSearchOrder, dir )
|
case Dialog::retry:
|
||||||
FILEMAN->FlushDirCache( *dir );
|
FOREACH_CONST(RString, data.vsDirSearchOrder, dir)
|
||||||
|
FILEMAN->FlushDirCache(*dir);
|
||||||
g_PathCache.clear();
|
g_PathCache.clear();
|
||||||
return GetPath( sButtonName, sElement );
|
return GetPath(sButtonName, sElement);
|
||||||
|
case Dialog::abort:
|
||||||
|
RageException::Throw("%s", message.c_str());
|
||||||
|
case Dialog::ignore:
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
RageException::Throw( "%s", message.c_str() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int iLevel = 0;
|
int iLevel = 0;
|
||||||
@@ -355,15 +371,18 @@ RString NoteSkinManager::GetPath( const RString &sButtonName, const RString &sEl
|
|||||||
"Verify that this redirect is correct.",
|
"Verify that this redirect is correct.",
|
||||||
sPath.c_str(), sNewFileName.c_str());
|
sPath.c_str(), sNewFileName.c_str());
|
||||||
|
|
||||||
if( Dialog::AbortRetryIgnore(message) == Dialog::retry )
|
switch(LuaHelpers::ReportScriptError(message, "NOTESKIN_ERROR", true))
|
||||||
{
|
{
|
||||||
FOREACH_CONST( RString, data.vsDirSearchOrder, dir )
|
case Dialog::retry:
|
||||||
FILEMAN->FlushDirCache( *dir );
|
FOREACH_CONST(RString, data.vsDirSearchOrder, dir)
|
||||||
|
FILEMAN->FlushDirCache(*dir);
|
||||||
g_PathCache.clear();
|
g_PathCache.clear();
|
||||||
return GetPath( sButtonName, sElement );
|
return GetPath(sButtonName, sElement);
|
||||||
|
case Dialog::abort:
|
||||||
|
RageException::Throw("%s", message.c_str());
|
||||||
|
case Dialog::ignore:
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
RageException::Throw( "%s", message.c_str() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sPath = sRealPath;
|
sPath = sRealPath;
|
||||||
@@ -376,7 +395,11 @@ RString NoteSkinManager::GetPath( const RString &sButtonName, const RString &sEl
|
|||||||
bool NoteSkinManager::PushActorTemplate( Lua *L, const RString &sButton, const RString &sElement, bool bSpriteOnly )
|
bool NoteSkinManager::PushActorTemplate( Lua *L, const RString &sButton, const RString &sElement, bool bSpriteOnly )
|
||||||
{
|
{
|
||||||
map<RString,NoteSkinData>::const_iterator iter = g_mapNameToData.find( m_sCurrentNoteSkin );
|
map<RString,NoteSkinData>::const_iterator iter = g_mapNameToData.find( m_sCurrentNoteSkin );
|
||||||
ASSERT( iter != g_mapNameToData.end() );
|
if(iter == g_mapNameToData.end())
|
||||||
|
{
|
||||||
|
LuaHelpers::ReportScriptError("No current noteskin set!", "NOTESKIN_ERROR");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
const NoteSkinData &data = iter->second;
|
const NoteSkinData &data = iter->second;
|
||||||
|
|
||||||
LuaThreadVariable varPlayer( "Player", LuaReference::Create(m_PlayerNumber) );
|
LuaThreadVariable varPlayer( "Player", LuaReference::Create(m_PlayerNumber) );
|
||||||
@@ -385,7 +408,11 @@ bool NoteSkinManager::PushActorTemplate( Lua *L, const RString &sButton, const R
|
|||||||
LuaThreadVariable varElement( "Element", sElement );
|
LuaThreadVariable varElement( "Element", sElement );
|
||||||
LuaThreadVariable varSpriteOnly( "SpriteOnly", LuaReference::Create(bSpriteOnly) );
|
LuaThreadVariable varSpriteOnly( "SpriteOnly", LuaReference::Create(bSpriteOnly) );
|
||||||
|
|
||||||
ASSERT( !data.m_Loader.IsNil() );
|
if(data.m_Loader.IsNil())
|
||||||
|
{
|
||||||
|
LuaHelpers::ReportScriptError("No loader for noteskin!", "NOTESKIN_ERROR");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
data.m_Loader.PushSelf( L );
|
data.m_Loader.PushSelf( L );
|
||||||
lua_remove( L, -2 );
|
lua_remove( L, -2 );
|
||||||
lua_getfield( L, -1, "Load" );
|
lua_getfield( L, -1, "Load" );
|
||||||
@@ -437,7 +464,7 @@ RString NoteSkinManager::GetPathFromDirAndFile( const RString &sDir, const RStri
|
|||||||
if( matches.size() > 1 )
|
if( matches.size() > 1 )
|
||||||
{
|
{
|
||||||
RString sError = "Multiple files match '"+sDir+sFileName+"'. Please remove all but one of these files.";
|
RString sError = "Multiple files match '"+sDir+sFileName+"'. Please remove all but one of these files.";
|
||||||
Dialog::OK( sError );
|
LuaHelpers::ReportScriptError(sError, "NOTESKIN_ERROR");
|
||||||
}
|
}
|
||||||
|
|
||||||
return matches[0];
|
return matches[0];
|
||||||
@@ -469,7 +496,12 @@ public:
|
|||||||
static int x ## ForNoteSkin( T* p, lua_State *L ) \
|
static int x ## ForNoteSkin( T* p, lua_State *L ) \
|
||||||
{ \
|
{ \
|
||||||
const RString sOldNoteSkin = p->GetCurrentNoteSkin(); \
|
const RString sOldNoteSkin = p->GetCurrentNoteSkin(); \
|
||||||
p->SetCurrentNoteSkin( SArg(n+1) ); \
|
RString nsname= SArg(n+1); \
|
||||||
|
if(!p->DoesNoteSkinExist(nsname)) \
|
||||||
|
{ \
|
||||||
|
luaL_error(L, "Noteskin \"%s\" does not exist.", nsname.c_str()); \
|
||||||
|
} \
|
||||||
|
p->SetCurrentNoteSkin( nsname ); \
|
||||||
x( p, L ); \
|
x( p, L ); \
|
||||||
p->SetCurrentNoteSkin( sOldNoteSkin ); \
|
p->SetCurrentNoteSkin( sOldNoteSkin ); \
|
||||||
return 1; \
|
return 1; \
|
||||||
|
|||||||
@@ -722,6 +722,11 @@ void ScreenManager::LoadDelayedScreen()
|
|||||||
{
|
{
|
||||||
RString sScreenName = m_sDelayedScreen;
|
RString sScreenName = m_sDelayedScreen;
|
||||||
m_sDelayedScreen = "";
|
m_sDelayedScreen = "";
|
||||||
|
if(!IsScreenNameValid(sScreenName))
|
||||||
|
{
|
||||||
|
LuaHelpers::ReportScriptError("Tried to go to invalid screen: " + sScreenName, "INVALID_SCREEN");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Pop the top screen, if any.
|
// Pop the top screen, if any.
|
||||||
ScreenMessage SM = PopTopScreenInternal();
|
ScreenMessage SM = PopTopScreenInternal();
|
||||||
|
|||||||
Reference in New Issue
Block a user