Changed many places that used RageException to use ReportScriptError instead. Wrote ScreenOptionsExample.ini as documentation example for the OptionRow system. Rewrote gamecommands.txt to include all GameCommands. Fixed Commands::GetOriginalCommandString to insert the semicolons that separated the original commands. Changed nonsensical boolean |= true statements in GameCommand.cpp to just use =. Added protection to ReportScriptError to keep it from recursing through itself when an error occurs in error reporting. Added UseAbort option to ReportScriptError for places that want to use an AbortRetryIgnore dialog to query the user. Added ScriptErrorMessage for places that need to handle the warning/dialog part separately. Added logging flag to MESSAGEMAN so that all messages broadcast can be logged when desired. Changed OptionRowHandler::LoadInternal to return a boolean success value as part of error handling.
This commit is contained in:
@@ -83,7 +83,13 @@ RString Commands::GetOriginalCommandString() const
|
||||
{
|
||||
RString s;
|
||||
FOREACH_CONST( Command, v, c )
|
||||
{
|
||||
if(s != "")
|
||||
{
|
||||
s += ";";
|
||||
}
|
||||
s += c->GetOriginalCommandString();
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
+14
-4
@@ -44,8 +44,13 @@ void ThemeMetricDifficultiesToShow::Read()
|
||||
{
|
||||
Difficulty d = StringToDifficulty( *i );
|
||||
if( d == Difficulty_Invalid )
|
||||
RageException::Throw( "Unknown difficulty \"%s\" in CourseDifficultiesToShow.", i->c_str() );
|
||||
m_v.push_back( d );
|
||||
{
|
||||
LuaHelpers::ReportScriptErrorFmt("Unknown difficulty \"%s\" in CourseDifficultiesToShow.", i->c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
m_v.push_back( d );
|
||||
}
|
||||
}
|
||||
}
|
||||
const vector<Difficulty>& ThemeMetricDifficultiesToShow::GetValue() const { return m_v; }
|
||||
@@ -74,8 +79,13 @@ void ThemeMetricCourseDifficultiesToShow::Read()
|
||||
{
|
||||
CourseDifficulty d = StringToDifficulty( *i );
|
||||
if( d == Difficulty_Invalid )
|
||||
RageException::Throw( "Unknown CourseDifficulty \"%s\" in CourseDifficultiesToShow.", i->c_str() );
|
||||
m_v.push_back( d );
|
||||
{
|
||||
LuaHelpers::ReportScriptErrorFmt("Unknown CourseDifficulty \"%s\" in CourseDifficultiesToShow.", i->c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
m_v.push_back( d );
|
||||
}
|
||||
}
|
||||
}
|
||||
const vector<CourseDifficulty>& ThemeMetricCourseDifficultiesToShow::GetValue() const { return m_v; }
|
||||
|
||||
@@ -26,7 +26,9 @@ void CourseContentsList::LoadFromNode( const XNode* pNode )
|
||||
|
||||
const XNode *pDisplayNode = pNode->GetChild( "Display" );
|
||||
if( pDisplayNode == NULL )
|
||||
RageException::Throw( "%s: CourseContentsList: missing the Display child", ActorUtil::GetWhere(pNode).c_str() );
|
||||
{
|
||||
LuaHelpers::ReportScriptErrorFmt("%s: CourseContentsList: missing the Display child", ActorUtil::GetWhere(pNode).c_str());
|
||||
}
|
||||
|
||||
for( int i=0; i<iMaxSongs; i++ )
|
||||
{
|
||||
|
||||
@@ -44,7 +44,9 @@ void DifficultyIcon::LoadFromNode( const XNode* pNode )
|
||||
{
|
||||
RString sFile;
|
||||
if( !ActorUtil::GetAttrPath(pNode, "File", sFile) )
|
||||
RageException::Throw( "%s: DifficultyIcon: missing the \"File\" attribute.", ActorUtil::GetWhere(pNode).c_str() );
|
||||
{
|
||||
LuaHelpers::ReportScriptErrorFmt("%s: DifficultyIcon: missing the \"File\" attribute.", ActorUtil::GetWhere(pNode).c_str());
|
||||
}
|
||||
|
||||
Load( sFile );
|
||||
|
||||
|
||||
+16
-6
@@ -51,8 +51,13 @@ void StepsDisplayList::LoadFromNode( const XNode* pNode )
|
||||
{
|
||||
const XNode *pChild = pNode->GetChild( ssprintf("CursorP%i",pn+1) );
|
||||
if( pChild == NULL )
|
||||
RageException::Throw( "%s: StepsDisplayList: missing the node \"CursorP%d\"", ActorUtil::GetWhere(pNode).c_str(), pn+1 );
|
||||
m_Cursors[pn].LoadActorFromNode( pChild, this );
|
||||
{
|
||||
LuaHelpers::ReportScriptErrorFmt("%s: StepsDisplayList: missing the node \"CursorP%d\"", ActorUtil::GetWhere(pNode).c_str(), pn+1);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Cursors[pn].LoadActorFromNode( pChild, this );
|
||||
}
|
||||
|
||||
/* Hack: we need to tween cursors both up to down (cursor motion) and visible to
|
||||
* invisible (fading). Cursor motion needs to stoptweening, so multiple motions
|
||||
@@ -62,10 +67,15 @@ void StepsDisplayList::LoadFromNode( const XNode* pNode )
|
||||
* colors; I think we do need a diffuse color stack ... */
|
||||
pChild = pNode->GetChild( ssprintf("CursorP%iFrame",pn+1) );
|
||||
if( pChild == NULL )
|
||||
RageException::Throw( "%s: StepsDisplayList: missing the node \"CursorP%dFrame\"", ActorUtil::GetWhere(pNode).c_str(), pn+1 );
|
||||
m_CursorFrames[pn].LoadFromNode( pChild );
|
||||
m_CursorFrames[pn].AddChild( m_Cursors[pn] );
|
||||
this->AddChild( &m_CursorFrames[pn] );
|
||||
{
|
||||
LuaHelpers::ReportScriptErrorFmt("%s: StepsDisplayList: missing the node \"CursorP%dFrame\"", ActorUtil::GetWhere(pNode).c_str(), pn+1);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_CursorFrames[pn].LoadFromNode( pChild );
|
||||
m_CursorFrames[pn].AddChild( m_Cursors[pn] );
|
||||
this->AddChild( &m_CursorFrames[pn] );
|
||||
}
|
||||
}
|
||||
|
||||
for( unsigned m = 0; m < m_Lines.size(); ++m )
|
||||
|
||||
+35
-23
@@ -251,7 +251,7 @@ void GameCommand::LoadOne( const Command& cmd )
|
||||
if( m_pSong == NULL )
|
||||
{
|
||||
m_sInvalidReason = ssprintf( "Song \"%s\" not found", sValue.c_str() );
|
||||
m_bInvalid |= true;
|
||||
m_bInvalid = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,17 +265,23 @@ void GameCommand::LoadOne( const Command& cmd )
|
||||
Song *pSong = (m_pSong != NULL)? m_pSong:GAMESTATE->m_pCurSong;
|
||||
const Style *pStyle = m_pStyle ? m_pStyle : GAMESTATE->GetCurrentStyle();
|
||||
if( pSong == NULL || pStyle == NULL )
|
||||
RageException::Throw( "Must set Song and Style to set Steps." );
|
||||
|
||||
Difficulty dc = StringToDifficulty( sSteps );
|
||||
if( dc != Difficulty_Edit )
|
||||
m_pSteps = SongUtil::GetStepsByDifficulty( pSong, pStyle->m_StepsType, dc );
|
||||
else
|
||||
m_pSteps = SongUtil::GetStepsByDescription( pSong, pStyle->m_StepsType, sSteps );
|
||||
if( m_pSteps == NULL )
|
||||
{
|
||||
m_sInvalidReason = "steps not found";
|
||||
m_bInvalid |= true;
|
||||
LuaHelpers::ReportScriptError("Must set Song and Style to set Steps.");
|
||||
m_sInvalidReason = "Song or Style not set";
|
||||
m_bInvalid = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Difficulty dc = StringToDifficulty( sSteps );
|
||||
if( dc != Difficulty_Edit )
|
||||
m_pSteps = SongUtil::GetStepsByDifficulty( pSong, pStyle->m_StepsType, dc );
|
||||
else
|
||||
m_pSteps = SongUtil::GetStepsByDescription( pSong, pStyle->m_StepsType, sSteps );
|
||||
if( m_pSteps == NULL )
|
||||
{
|
||||
m_sInvalidReason = "steps not found";
|
||||
m_bInvalid = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -286,7 +292,7 @@ void GameCommand::LoadOne( const Command& cmd )
|
||||
if( m_pCourse == NULL )
|
||||
{
|
||||
m_sInvalidReason = ssprintf( "Course \"%s\" not found", sValue.c_str() );
|
||||
m_bInvalid |= true;
|
||||
m_bInvalid = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,16 +306,22 @@ void GameCommand::LoadOne( const Command& cmd )
|
||||
Course *pCourse = (m_pCourse != NULL)? m_pCourse:GAMESTATE->m_pCurCourse;
|
||||
const Style *pStyle = m_pStyle ? m_pStyle : GAMESTATE->GetCurrentStyle();
|
||||
if( pCourse == NULL || pStyle == NULL )
|
||||
RageException::Throw( "Must set Course and Style to set Steps." );
|
||||
|
||||
const CourseDifficulty cd = StringToDifficulty( sTrail );
|
||||
ASSERT_M( cd != Difficulty_Invalid, ssprintf("Invalid difficulty '%s'", sTrail.c_str()) );
|
||||
|
||||
m_pTrail = pCourse->GetTrail( pStyle->m_StepsType, cd );
|
||||
if( m_pTrail == NULL )
|
||||
{
|
||||
m_sInvalidReason = "trail not found";
|
||||
m_bInvalid |= true;
|
||||
LuaHelpers::ReportScriptError("Must set Course and Style to set Trail.");
|
||||
m_sInvalidReason = "Course or Style not set";
|
||||
m_bInvalid = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
const CourseDifficulty cd = StringToDifficulty( sTrail );
|
||||
ASSERT_M( cd != Difficulty_Invalid, ssprintf("Invalid difficulty '%s'", sTrail.c_str()) );
|
||||
|
||||
m_pTrail = pCourse->GetTrail( pStyle->m_StepsType, cd );
|
||||
if( m_pTrail == NULL )
|
||||
{
|
||||
m_sInvalidReason = "trail not found";
|
||||
m_bInvalid = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -331,7 +343,7 @@ void GameCommand::LoadOne( const Command& cmd )
|
||||
if( m_SortOrder == SortOrder_Invalid )
|
||||
{
|
||||
m_sInvalidReason = ssprintf( "SortOrder \"%s\" is not valid.", sValue.c_str() );
|
||||
m_bInvalid |= true;
|
||||
m_bInvalid = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -406,7 +418,7 @@ void GameCommand::LoadOne( const Command& cmd )
|
||||
if( pPref == NULL )
|
||||
{
|
||||
m_sInvalidReason = ssprintf("unknown preference \"%s\"", cmd.m_vsArgs[1].c_str() );
|
||||
m_bInvalid |= true;
|
||||
m_bInvalid = true;
|
||||
}
|
||||
pPref->FromString(cmd.m_vsArgs[2]);
|
||||
}
|
||||
|
||||
+4
-1
@@ -222,7 +222,10 @@ void GameState::ApplyGameCommand( const RString &sCommand, PlayerNumber pn )
|
||||
|
||||
RString sWhy;
|
||||
if( !m.IsPlayable(&sWhy) )
|
||||
RageException::Throw( "Can't apply mode \"%s\": %s", sCommand.c_str(), sWhy.c_str() );
|
||||
{
|
||||
LuaHelpers::ReportScriptErrorFmt("Can't apply mode \"%s\": %s", sCommand.c_str(), sWhy.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if( pn == PLAYER_INVALID )
|
||||
m.ApplyToAllPlayers();
|
||||
|
||||
@@ -28,7 +28,9 @@ void HoldJudgment::LoadFromNode( const XNode* pNode )
|
||||
{
|
||||
RString sFile;
|
||||
if( ActorUtil::GetAttrPath(pNode, "File", sFile) )
|
||||
RageException::Throw( "%s: HoldJudgment: missing the attribute \"File\"", ActorUtil::GetWhere(pNode).c_str() );
|
||||
{
|
||||
LuaHelpers::ReportScriptErrorFmt("%s: HoldJudgment: missing the attribute \"File\"", ActorUtil::GetWhere(pNode).c_str());
|
||||
}
|
||||
|
||||
CollapsePath( sFile );
|
||||
|
||||
|
||||
+23
-4
@@ -47,6 +47,8 @@ namespace LuaHelpers
|
||||
template<> bool FromStack<float>( Lua *L, float &Object, int iOffset );
|
||||
template<> bool FromStack<int>( Lua *L, int &Object, int iOffset );
|
||||
template<> bool FromStack<RString>( Lua *L, RString &Object, int iOffset );
|
||||
|
||||
bool InReportScriptError= false;
|
||||
}
|
||||
|
||||
void LuaManager::SetGlobal( const RString &sName, int val )
|
||||
@@ -789,7 +791,14 @@ bool LuaHelpers::LoadScript( Lua *L, const RString &sScript, const RString &sNam
|
||||
return true;
|
||||
}
|
||||
|
||||
void LuaHelpers::ReportScriptError(RString const& Error, RString ErrorType)
|
||||
void LuaHelpers::ScriptErrorMessage(RString const& Error)
|
||||
{
|
||||
Message msg("ScriptError");
|
||||
msg.SetParam("Message", Error);
|
||||
MESSAGEMAN->Broadcast(msg);
|
||||
}
|
||||
|
||||
Dialog::Result LuaHelpers::ReportScriptError(RString const& Error, RString ErrorType, bool UseAbort)
|
||||
{
|
||||
size_t line_break_pos= Error.find('\n');
|
||||
RString short_error;
|
||||
@@ -801,11 +810,21 @@ void LuaHelpers::ReportScriptError(RString const& Error, RString ErrorType)
|
||||
{
|
||||
short_error= Error.substr(0, line_break_pos);
|
||||
}
|
||||
Message msg("ScriptError");
|
||||
msg.SetParam("Message", short_error);
|
||||
MESSAGEMAN->Broadcast(msg);
|
||||
// Protect from a recursion loop resulting from a mistake in the error reporting lua.
|
||||
if(!InReportScriptError)
|
||||
{
|
||||
InReportScriptError= true;
|
||||
ScriptErrorMessage(short_error);
|
||||
InReportScriptError= false;
|
||||
}
|
||||
LOG->Warn(Error.c_str());
|
||||
if(UseAbort)
|
||||
{
|
||||
RString with_correct= Error + " Correct this and click Retry, or Cancel to break.";
|
||||
return Dialog::AbortRetryIgnore(with_correct, ErrorType);
|
||||
}
|
||||
Dialog::OK(Error, ErrorType);
|
||||
return Dialog::ok;
|
||||
}
|
||||
|
||||
// For convenience when replacing uses of LOG->Warn.
|
||||
|
||||
+11
-2
@@ -15,6 +15,9 @@ extern "C"
|
||||
#include "../extern/lua-5.1/src/lauxlib.h"
|
||||
}
|
||||
|
||||
// For Dialog::Result
|
||||
#include "arch/Dialog/Dialog.h"
|
||||
|
||||
class LuaManager
|
||||
{
|
||||
public:
|
||||
@@ -58,8 +61,14 @@ namespace LuaHelpers
|
||||
* and the stack is unchanged. */
|
||||
bool LoadScript( Lua *L, const RString &sScript, const RString &sName, RString &sError );
|
||||
|
||||
/* Report the error through the log and on the screen. */
|
||||
void ReportScriptError(RString const& Error, RString ErrorType= "LUA_ERROR");
|
||||
/* Report the error three ways: Broadcast message, Warn, and Dialog. */
|
||||
/* If UseAbort is true, reports the error through Dialog::AbortRetryIgnore
|
||||
and returns the result. */
|
||||
/* If UseAbort is false, reports the error through Dialog::OK and returns
|
||||
Dialog::ok. */
|
||||
Dialog::Result ReportScriptError(RString const& Error, RString ErrorType= "LUA_ERROR", bool UseAbort= false);
|
||||
// Just the broadcast message part, for things that need to do the rest differently.
|
||||
void ScriptErrorMessage(RString const& Error);
|
||||
// For convenience when replacing uses of LOG->Warn.
|
||||
void ReportScriptErrorFmt(const char *fmt, ...);
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "RageThreads.h"
|
||||
#include "EnumHelper.h"
|
||||
#include "LuaManager.h"
|
||||
#include "RageLog.h"
|
||||
|
||||
#include <set>
|
||||
#include <map>
|
||||
@@ -148,6 +149,7 @@ void Message::SetParamFromStack( lua_State *L, const RString &sName )
|
||||
|
||||
MessageManager::MessageManager()
|
||||
{
|
||||
m_Logging= false;
|
||||
// Register with Lua.
|
||||
{
|
||||
Lua *L = LUA->Get();
|
||||
@@ -198,6 +200,11 @@ void MessageManager::Unsubscribe( IMessageSubscriber* pSubscriber, MessageID m )
|
||||
|
||||
void MessageManager::Broadcast( Message &msg ) const
|
||||
{
|
||||
// GAMESTATE is created before MESSAGEMAN, and has several BroadcastOnChangePtr members, so they all broadcast when they're initialized.
|
||||
if(this != NULL && m_Logging)
|
||||
{
|
||||
LOG->Trace("MESSAGEMAN:Broadcast: %s", msg.GetName().c_str());
|
||||
}
|
||||
msg.SetBroadcast(true);
|
||||
|
||||
LockMut(g_Mutex);
|
||||
@@ -295,10 +302,16 @@ public:
|
||||
p->Broadcast( msg );
|
||||
return 0;
|
||||
}
|
||||
static int SetLogging(T* p, lua_State *L)
|
||||
{
|
||||
p->SetLogging(lua_toboolean(L, -1));
|
||||
return 0;
|
||||
}
|
||||
|
||||
LunaMessageManager()
|
||||
{
|
||||
ADD_METHOD( Broadcast );
|
||||
ADD_METHOD( SetLogging );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -198,6 +198,9 @@ public:
|
||||
bool IsSubscribedToMessage( IMessageSubscriber* pSubscriber, const RString &sMessage ) const;
|
||||
inline bool IsSubscribedToMessage( IMessageSubscriber* pSubscriber, MessageID message ) const { return IsSubscribedToMessage( pSubscriber, MessageIDToString(message) ); }
|
||||
|
||||
void SetLogging(bool set) { m_Logging= set; }
|
||||
bool m_Logging;
|
||||
|
||||
// Lua
|
||||
void PushSelf( lua_State *L );
|
||||
};
|
||||
|
||||
@@ -33,8 +33,13 @@ void MeterDisplay::LoadFromNode( const XNode* pNode )
|
||||
|
||||
const XNode *pStream = pNode->GetChild( "Stream" );
|
||||
if( pStream == NULL )
|
||||
RageException::Throw( "%s: MeterDisplay: missing the \"Stream\" attribute", ActorUtil::GetWhere(pNode).c_str() );
|
||||
m_sprStream.LoadActorFromNode( pStream, this );
|
||||
{
|
||||
LuaHelpers::ReportScriptErrorFmt("%s: MeterDisplay: missing the \"Stream\" attribute", ActorUtil::GetWhere(pNode).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
m_sprStream.LoadActorFromNode( pStream, this );
|
||||
}
|
||||
m_sprStream->SetName( "Stream" );
|
||||
//LOAD_ALL_COMMANDS( m_sprStream );
|
||||
this->AddChild( m_sprStream );
|
||||
|
||||
+85
-91
@@ -117,6 +117,18 @@ int OptionRowHandlerUtil::GetOneSelection( const vector<bool> &vbSelected )
|
||||
|
||||
static LocalizedString OFF ( "OptionRowHandler", "Off" );
|
||||
|
||||
#define ROW_INVALID_IF(condition, message, retval) \
|
||||
if(condition) \
|
||||
{ \
|
||||
LuaHelpers::ReportScriptError("Parse error in option row: " message); \
|
||||
return retval; \
|
||||
}
|
||||
|
||||
#define CHECK_WRONG_NUM_ARGS(num) \
|
||||
ROW_INVALID_IF(command.m_vsArgs.size() != num, "Wrong number of args to option row.", false);
|
||||
#define CHECK_BLANK_ARG \
|
||||
ROW_INVALID_IF(sParam.size() == 0, "Blank arg to Steps row.", false);
|
||||
|
||||
// begin OptionRow handlers
|
||||
class OptionRowHandlerList : public OptionRowHandler
|
||||
{
|
||||
@@ -135,31 +147,24 @@ public:
|
||||
m_bUseModNameForIcon = false;
|
||||
m_vsBroadcastOnExport.clear();
|
||||
}
|
||||
virtual void LoadInternal( const Commands &cmds )
|
||||
virtual bool LoadInternal( const Commands &cmds )
|
||||
{
|
||||
ASSERT( cmds.v.size() == 1 );
|
||||
const Command &command = cmds.v[0];
|
||||
RString sParam = command.GetArg(1).s;
|
||||
ASSERT( command.m_vsArgs.size() == 2 );
|
||||
ASSERT( sParam.size() != 0 );
|
||||
|
||||
m_bUseModNameForIcon = true;
|
||||
|
||||
m_Def.m_sName = sParam;
|
||||
|
||||
m_Default.Load( -1, ParseCommands(ENTRY_DEFAULT(sParam)) );
|
||||
|
||||
{
|
||||
// Parse the basic configuration metric.
|
||||
Commands lCmds = ParseCommands( ENTRY(sParam) );
|
||||
if( lCmds.v.size() < 1 )
|
||||
{
|
||||
LuaHelpers::ReportScriptErrorFmt("Parse error in \"ScreenOptionsMaster::%s\".", sParam.c_str());
|
||||
lCmds= ParseCommands("0");
|
||||
}
|
||||
ROW_INVALID_IF(lCmds.v.size() < 1, "Row command is empty.", false);
|
||||
|
||||
m_Def.m_bOneChoiceForAllPlayers = false;
|
||||
ROW_INVALID_IF(lCmds.v[0].m_vsArgs.size() != 1, "Row command has invalid args to number of entries.", false);
|
||||
const int NumCols = StringToInt( lCmds.v[0].m_vsArgs[0] );
|
||||
ROW_INVALID_IF(NumCols < 1, "Not enough entries in list.", false);
|
||||
for( unsigned i=1; i<lCmds.v.size(); i++ )
|
||||
{
|
||||
const Command &cmd = lCmds.v[i];
|
||||
@@ -198,20 +203,9 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
LuaHelpers::ReportScriptErrorFmt( "Unkown row flag \"%s\".", sName.c_str() );
|
||||
LuaHelpers::ReportScriptErrorFmt("Unkown row flag \"%s\".", sName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if(NumCols < 1)
|
||||
{
|
||||
LuaHelpers::ReportScriptErrorFmt(sParam + " has %d choices.", NumCols);
|
||||
GameCommand mc;
|
||||
mc.ApplyCommitsScreens( false );
|
||||
mc.Load( 0, ParseCommands("name,Error") );
|
||||
m_aListEntries.push_back(mc);
|
||||
RString sChoice = mc.m_sName;
|
||||
m_Def.m_vsChoices.push_back( sChoice );
|
||||
}
|
||||
for( int col = 0; col < NumCols; ++col )
|
||||
{
|
||||
GameCommand mc;
|
||||
@@ -223,13 +217,14 @@ public:
|
||||
mc.m_sName = sParam;
|
||||
if( mc.m_sName == "" )
|
||||
{
|
||||
LuaHelpers::ReportScriptErrorFmt("List \"%s\", col %i has no name.", sParam.c_str(), col);
|
||||
LuaHelpers::ReportScriptErrorFmt("List \"%s\", choice %i has no name.", sParam.c_str(), col+1);
|
||||
mc.m_sName= "";
|
||||
}
|
||||
|
||||
if( !mc.IsPlayable() )
|
||||
RString why;
|
||||
if( !mc.IsPlayable(&why) )
|
||||
{
|
||||
LuaHelpers::ReportScriptErrorFmt("\"%s\" is not playable.", sParam.c_str());
|
||||
LuaHelpers::ReportScriptErrorFmt("\"%s\" choice %d is not playable: %s", sParam.c_str(), col, why.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -249,6 +244,7 @@ public:
|
||||
m_Def.m_iDefault = e;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
void ImportOption( OptionRow *pRow, const vector<PlayerNumber> &vpns, vector<bool> vbSelectedOut[NUM_PLAYERS] ) const
|
||||
{
|
||||
@@ -388,7 +384,7 @@ static void SortNoteSkins( vector<RString> &asSkinNames )
|
||||
|
||||
class OptionRowHandlerListNoteSkins : public OptionRowHandlerList
|
||||
{
|
||||
virtual void LoadInternal( const Commands & )
|
||||
virtual bool LoadInternal( const Commands & )
|
||||
{
|
||||
m_Def.m_sName = "NoteSkins";
|
||||
m_Def.m_bOneChoiceForAllPlayers = false;
|
||||
@@ -408,13 +404,14 @@ class OptionRowHandlerListNoteSkins : public OptionRowHandlerList
|
||||
m_aListEntries.push_back( mc );
|
||||
m_Def.m_vsChoices.push_back( arraySkinNames[skin] );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// XXX: very similar to OptionRowHandlerSteps
|
||||
class OptionRowHandlerListSteps : public OptionRowHandlerList
|
||||
{
|
||||
virtual void LoadInternal( const Commands & )
|
||||
virtual bool LoadInternal( const Commands & )
|
||||
{
|
||||
m_Def.m_sName = "Steps";
|
||||
m_Def.m_bAllowThemeItems = false; // we theme the text ourself
|
||||
@@ -423,6 +420,7 @@ class OptionRowHandlerListSteps : public OptionRowHandlerList
|
||||
|
||||
// don't call default
|
||||
// OptionRowHandlerList::LoadInternal( cmds );
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual ReloadChanged Reload()
|
||||
@@ -533,13 +531,12 @@ public:
|
||||
m_vDifficulties.clear();
|
||||
}
|
||||
|
||||
virtual void LoadInternal( const Commands &cmds )
|
||||
virtual bool LoadInternal( const Commands &cmds )
|
||||
{
|
||||
ASSERT( cmds.v.size() == 1 );
|
||||
const Command &command = cmds.v[0];
|
||||
RString sParam = command.GetArg(1).s;
|
||||
ASSERT( command.m_vsArgs.size() == 2 );
|
||||
ASSERT( sParam.size() != 0 );
|
||||
CHECK_WRONG_NUM_ARGS(2);
|
||||
CHECK_BLANK_ARG;
|
||||
|
||||
if( sParam == "EditSteps" )
|
||||
{
|
||||
@@ -558,7 +555,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
LuaHelpers::ReportScriptErrorFmt("Invalid StepsType param \"%s\".", sParam.c_str());
|
||||
ROW_INVALID_IF(true, "Invalid StepsType param \"" + sParam + "\".", false);
|
||||
}
|
||||
|
||||
m_Def.m_sName = sParam;
|
||||
@@ -620,6 +617,7 @@ public:
|
||||
if( m_pDifficultyToFill )
|
||||
m_pDifficultyToFill->Set( m_vDifficulties[0] );
|
||||
m_ppStepsToFill->Set( m_vSteps[0] );
|
||||
return true;
|
||||
}
|
||||
virtual void ImportOption( OptionRow *pRow, const vector<PlayerNumber> &vpns, vector<bool> vbSelectedOut[NUM_PLAYERS] ) const
|
||||
{
|
||||
@@ -679,7 +677,7 @@ public:
|
||||
|
||||
class OptionRowHandlerListCharacters: public OptionRowHandlerList
|
||||
{
|
||||
virtual void LoadInternal( const Commands & )
|
||||
virtual bool LoadInternal( const Commands & )
|
||||
{
|
||||
m_Def.m_bOneChoiceForAllPlayers = false;
|
||||
m_Def.m_bAllowThemeItems = false;
|
||||
@@ -707,12 +705,13 @@ class OptionRowHandlerListCharacters: public OptionRowHandlerList
|
||||
mc.m_pCharacter = pCharacter;
|
||||
m_aListEntries.push_back( mc );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class OptionRowHandlerListStyles: public OptionRowHandlerList
|
||||
{
|
||||
virtual void LoadInternal( const Commands & )
|
||||
virtual bool LoadInternal( const Commands & )
|
||||
{
|
||||
m_Def.m_bOneChoiceForAllPlayers = true;
|
||||
m_Def.m_sName = "Style";
|
||||
@@ -730,12 +729,13 @@ class OptionRowHandlerListStyles: public OptionRowHandlerList
|
||||
}
|
||||
|
||||
m_Default.m_pStyle = vStyles[0];
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class OptionRowHandlerListGroups: public OptionRowHandlerList
|
||||
{
|
||||
virtual void LoadInternal( const Commands & )
|
||||
virtual bool LoadInternal( const Commands & )
|
||||
{
|
||||
m_Def.m_bOneChoiceForAllPlayers = true;
|
||||
m_Def.m_bAllowThemeItems = false; // we theme the text ourself
|
||||
@@ -760,12 +760,13 @@ class OptionRowHandlerListGroups: public OptionRowHandlerList
|
||||
mc.m_sSongGroup = *g;
|
||||
m_aListEntries.push_back( mc );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class OptionRowHandlerListDifficulties: public OptionRowHandlerList
|
||||
{
|
||||
virtual void LoadInternal( const Commands & )
|
||||
virtual bool LoadInternal( const Commands & )
|
||||
{
|
||||
m_Def.m_bOneChoiceForAllPlayers = true;
|
||||
m_Def.m_sName = "Difficulty";
|
||||
@@ -790,13 +791,14 @@ class OptionRowHandlerListDifficulties: public OptionRowHandlerList
|
||||
mc.m_dc = *d;
|
||||
m_aListEntries.push_back( mc );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// XXX: very similar to OptionRowHandlerSongChoices
|
||||
class OptionRowHandlerListSongsInCurrentSongGroup: public OptionRowHandlerList
|
||||
{
|
||||
virtual void LoadInternal( const Commands & )
|
||||
virtual bool LoadInternal( const Commands & )
|
||||
{
|
||||
const vector<Song*> &vpSongs = SONGMAN->GetSongs( GAMESTATE->m_sPreferredSongGroup );
|
||||
|
||||
@@ -815,6 +817,7 @@ class OptionRowHandlerListSongsInCurrentSongGroup: public OptionRowHandlerList
|
||||
mc.m_pSong = *p;
|
||||
m_aListEntries.push_back( mc );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -995,45 +998,25 @@ public:
|
||||
LUA->Release(L);
|
||||
}
|
||||
|
||||
virtual void LoadInternal( const Commands &cmds )
|
||||
virtual bool LoadInternal( const Commands &cmds )
|
||||
{
|
||||
ASSERT( cmds.v.size() == 1 );
|
||||
const Command &command = cmds.v[0];
|
||||
ASSERT( command.m_vsArgs.size() == 2 );
|
||||
RString sLuaFunction = command.m_vsArgs[1];
|
||||
ASSERT( sLuaFunction.size() != 0 );
|
||||
RString sParam = command.GetArg(1).s;
|
||||
CHECK_WRONG_NUM_ARGS(2);
|
||||
CHECK_BLANK_ARG;
|
||||
|
||||
m_Def.m_bAllowThemeItems = false; // Lua options are always dynamic and can theme themselves.
|
||||
|
||||
Lua *L = LUA->Get();
|
||||
|
||||
// Run the Lua expression. It should return a table.
|
||||
m_pLuaTable->SetFromExpression( sLuaFunction );
|
||||
m_TableIsSane= SanityCheckTable(L, sLuaFunction);
|
||||
m_pLuaTable->SetFromExpression( sParam );
|
||||
m_TableIsSane= SanityCheckTable(L, sParam);
|
||||
if(!m_TableIsSane)
|
||||
{
|
||||
m_pLuaTable->PushSelf(L);
|
||||
lua_getfield(L, -1, "Name");
|
||||
const char *pStr = lua_tostring( L, -1 );
|
||||
if(pStr == NULL)
|
||||
{
|
||||
m_Def.m_sName = "Invalid";
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Def.m_sName = pStr;
|
||||
}
|
||||
lua_pop( L, 1 );
|
||||
// Add a fake choice so that there won't be a crash.
|
||||
// This is so that a themer that makes a mistake doesn't have to
|
||||
// completely restart and can just reload scripts.
|
||||
m_Def.m_vsChoices.push_back("Error in row.");
|
||||
// Set m_selectType to SELECT_MULTIPLE so we won't hit the assert in
|
||||
// VerifySelected.
|
||||
m_Def.m_selectType= SELECT_MULTIPLE;
|
||||
lua_settop(L, 0); // Release has an assert that forces a clear stack.
|
||||
LUA->Release(L);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
m_pLuaTable->PushSelf(L);
|
||||
|
||||
@@ -1101,6 +1084,7 @@ public:
|
||||
ASSERT( lua_gettop(L) == 0 );
|
||||
|
||||
LUA->Release(L);
|
||||
return m_TableIsSane;
|
||||
}
|
||||
|
||||
virtual ReloadChanged Reload()
|
||||
@@ -1277,13 +1261,12 @@ public:
|
||||
OptionRowHandler::Init();
|
||||
m_pOpt = NULL;
|
||||
}
|
||||
virtual void LoadInternal( const Commands &cmds )
|
||||
virtual bool LoadInternal( const Commands &cmds )
|
||||
{
|
||||
ASSERT( cmds.v.size() == 1 );
|
||||
const Command &command = cmds.v[0];
|
||||
RString sParam = command.GetArg(1).s;
|
||||
ASSERT( command.m_vsArgs.size() == 2 );
|
||||
ASSERT( sParam.size() != 0 );
|
||||
CHECK_WRONG_NUM_ARGS(2);
|
||||
CHECK_BLANK_ARG;
|
||||
|
||||
Init();
|
||||
|
||||
@@ -1291,12 +1274,7 @@ public:
|
||||
m_Def.m_bOneChoiceForAllPlayers = true;
|
||||
|
||||
ConfOption *pConfOption = ConfOption::Find( sParam );
|
||||
if( pConfOption == NULL )
|
||||
{
|
||||
LuaHelpers::ReportScriptErrorFmt( "Invalid Conf type \"%s\"", sParam.c_str() );
|
||||
pConfOption = ConfOption::Find( "Invalid" );
|
||||
ASSERT_M( pConfOption != NULL, "ConfOption::Find(Invalid)" );
|
||||
}
|
||||
ROW_INVALID_IF(pConfOption == NULL, "Invalid Conf type \"" + sParam + "\".", false);
|
||||
|
||||
pConfOption->UpdateAvailableOptions();
|
||||
|
||||
@@ -1306,6 +1284,7 @@ public:
|
||||
m_Def.m_bAllowThemeItems = m_pOpt->m_bAllowThemeItems;
|
||||
|
||||
m_Def.m_sName = m_pOpt->name;
|
||||
return true;
|
||||
}
|
||||
virtual void ImportOption( OptionRow *, const vector<PlayerNumber> &vpns, vector<bool> vbSelectedOut[NUM_PLAYERS] ) const
|
||||
{
|
||||
@@ -1361,13 +1340,12 @@ public:
|
||||
m_vStepsTypesToShow.clear();
|
||||
}
|
||||
|
||||
virtual void LoadInternal( const Commands &cmds )
|
||||
virtual bool LoadInternal( const Commands &cmds )
|
||||
{
|
||||
ASSERT( cmds.v.size() == 1 );
|
||||
const Command &command = cmds.v[0];
|
||||
RString sParam = command.GetArg(1).s;
|
||||
ASSERT( command.m_vsArgs.size() == 2 );
|
||||
ASSERT( sParam.size() != 0 );
|
||||
CHECK_WRONG_NUM_ARGS(2);
|
||||
CHECK_BLANK_ARG;
|
||||
|
||||
if( sParam == "EditStepsType" )
|
||||
{
|
||||
@@ -1383,7 +1361,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
RageException::Throw( "Invalid StepsType param \"%s\".", sParam.c_str() );
|
||||
ROW_INVALID_IF(true, "Invalid StepsType param \"" + sParam + "\".", false);
|
||||
}
|
||||
|
||||
m_Def.m_sName = sParam;
|
||||
@@ -1404,6 +1382,7 @@ public:
|
||||
|
||||
if( *m_pstToFill == StepsType_Invalid )
|
||||
m_pstToFill->Set( m_vStepsTypesToShow[0] );
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void ImportOption( OptionRow *pRow, const vector<PlayerNumber> &vpns, vector<bool> vbSelectedOut[NUM_PLAYERS] ) const
|
||||
@@ -1455,19 +1434,20 @@ public:
|
||||
m_gc.Init();
|
||||
m_gc.ApplyCommitsScreens( false );
|
||||
}
|
||||
virtual void LoadInternal( const Commands &cmds )
|
||||
virtual bool LoadInternal( const Commands &cmds )
|
||||
{
|
||||
ASSERT( cmds.v.size() > 1 );
|
||||
ROW_INVALID_IF(cmds.v.size() <= 1, "No args to construct GameCommand.", false);
|
||||
|
||||
Commands temp = cmds;
|
||||
temp.v.erase( temp.v.begin() );
|
||||
m_gc.Load( 0, temp );
|
||||
ASSERT( !m_gc.m_sName.empty() );
|
||||
ROW_INVALID_IF(m_gc.m_sName.empty(), "GameCommand row has no name.", false);
|
||||
m_Def.m_sName = m_gc.m_sName;
|
||||
m_Def.m_bOneChoiceForAllPlayers = true;
|
||||
m_Def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW;
|
||||
m_Def.m_selectType = SELECT_NONE;
|
||||
m_Def.m_vsChoices.push_back( "" );
|
||||
return true;
|
||||
}
|
||||
virtual void ImportOption( OptionRow *pRow, const vector<PlayerNumber> &vpns, vector<bool> vbSelectedOut[NUM_PLAYERS] ) const
|
||||
{
|
||||
@@ -1501,20 +1481,21 @@ OptionRowHandler* OptionRowHandlerUtil::Make( const Commands &cmds )
|
||||
{
|
||||
OptionRowHandler* pHand = NULL;
|
||||
|
||||
if( cmds.v.size() == 0 )
|
||||
return NULL;
|
||||
|
||||
ROW_INVALID_IF(cmds.v.size() == 0, "No commands for constructing row.", NULL);
|
||||
const RString &name = cmds.v[0].GetName();
|
||||
ROW_INVALID_IF(name != "gamecommand" && cmds.v.size() != 1,
|
||||
"Row must be constructed from single command.", NULL);
|
||||
|
||||
#define MAKE( type ) { type *p = new type; p->Load( cmds ); pHand = p; }
|
||||
bool load_succeeded= false;
|
||||
#define MAKE( type ) { type *p = new type; load_succeeded= p->Load( cmds ); pHand = p; }
|
||||
|
||||
// XXX: merge these, and merge "Steps" and "list,Steps"
|
||||
if( name == "list" )
|
||||
{
|
||||
const Command &command = cmds.v[0];
|
||||
RString sParam = command.GetArg(1).s;
|
||||
if( command.m_vsArgs.size() != 2 || !sParam.size() )
|
||||
return NULL;
|
||||
ROW_INVALID_IF(command.m_vsArgs.size() != 2 || !sParam.size(),
|
||||
"list row command must be 'list,name' or 'list,type'.", NULL);
|
||||
|
||||
if( sParam.CompareNoCase("NoteSkins")==0 ) MAKE( OptionRowHandlerListNoteSkins )
|
||||
else if( sParam.CompareNoCase("Steps")==0 ) MAKE( OptionRowHandlerListSteps )
|
||||
@@ -1535,16 +1516,29 @@ OptionRowHandler* OptionRowHandlerUtil::Make( const Commands &cmds )
|
||||
else if( name == "stepstype" ) MAKE( OptionRowHandlerStepsType )
|
||||
else if( name == "steps" ) MAKE( OptionRowHandlerSteps )
|
||||
else if( name == "gamecommand" ) MAKE( OptionRowHandlerGameCommand )
|
||||
else
|
||||
{
|
||||
ROW_INVALID_IF(true, "Invalid row type.", NULL);
|
||||
}
|
||||
|
||||
return pHand;
|
||||
if(load_succeeded)
|
||||
{
|
||||
return pHand;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
OptionRowHandler* OptionRowHandlerUtil::MakeNull()
|
||||
{
|
||||
OptionRowHandler* pHand = NULL;
|
||||
bool load_succeeded= false; // Part of the MAKE macro, but unused.
|
||||
Commands cmds;
|
||||
MAKE( OptionRowHandlerNull )
|
||||
return pHand;
|
||||
if(load_succeeded) // Just to get rid of the warning for not using it.
|
||||
{
|
||||
return pHand;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
OptionRowHandler* OptionRowHandlerUtil::MakeSimple( const MenuRowDef &mr )
|
||||
|
||||
@@ -150,15 +150,15 @@ public:
|
||||
m_Def.Init();
|
||||
m_vsReloadRowMessages.clear();
|
||||
}
|
||||
void Load( const Commands &cmds )
|
||||
bool Load( const Commands &cmds )
|
||||
{
|
||||
Init();
|
||||
this->LoadInternal( cmds );
|
||||
return this->LoadInternal( cmds );
|
||||
}
|
||||
RString OptionTitle() const;
|
||||
RString GetThemedItemText( int iChoice ) const;
|
||||
|
||||
virtual void LoadInternal( const Commands & ) { }
|
||||
virtual bool LoadInternal( const Commands & ) { return true; }
|
||||
|
||||
/* We may re-use OptionRowHandlers. This is called before each use. If the
|
||||
* contents of the row are dependent on external state (for example, the
|
||||
|
||||
+4
-1
@@ -218,7 +218,10 @@ void OptionsList::Load( RString sType, PlayerNumber pn )
|
||||
|
||||
OptionRowHandler *pHand = OptionRowHandlerUtil::Make( cmds );
|
||||
if( pHand == NULL )
|
||||
RageException::Throw( "Invalid OptionRowHandler '%s' in %s::Line%s", cmds.GetOriginalCommandString().c_str(), m_sName.c_str(), sLineName.c_str() );
|
||||
{
|
||||
LuaHelpers::ReportScriptErrorFmt("Invalid OptionRowHandler '%s' in %s::Line%s", cmds.GetOriginalCommandString().c_str(), m_sName.c_str(), sLineName.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
m_Rows[sLineName] = pHand;
|
||||
m_asLoadedRows.push_back( sLineName );
|
||||
|
||||
+34
-16
@@ -41,23 +41,41 @@ void PlayerAI::InitFromDisk()
|
||||
{
|
||||
RString sKey = ssprintf("Skill%d", i);
|
||||
XNode* pNode = ini.GetChild(sKey);
|
||||
if( pNode == NULL )
|
||||
RageException::Throw( "AI.ini: \"%s\" doesn't exist.", sKey.c_str() );
|
||||
|
||||
TapScoreDistribution& dist = g_Distributions[i];
|
||||
dist.fPercent[TNS_None] = 0;
|
||||
bSuccess = pNode->GetAttrValue( "WeightMiss", dist.fPercent[TNS_Miss] );
|
||||
ASSERT( bSuccess );
|
||||
bSuccess = pNode->GetAttrValue( "WeightW5", dist.fPercent[TNS_W5] );
|
||||
ASSERT( bSuccess );
|
||||
bSuccess = pNode->GetAttrValue( "WeightW4", dist.fPercent[TNS_W4] );
|
||||
ASSERT( bSuccess );
|
||||
bSuccess = pNode->GetAttrValue( "WeightW3", dist.fPercent[TNS_W3] );
|
||||
ASSERT( bSuccess );
|
||||
bSuccess = pNode->GetAttrValue( "WeightW2", dist.fPercent[TNS_W2] );
|
||||
ASSERT( bSuccess );
|
||||
bSuccess = pNode->GetAttrValue( "WeightW1", dist.fPercent[TNS_W1] );
|
||||
ASSERT( bSuccess );
|
||||
if( pNode == NULL )
|
||||
{
|
||||
LuaHelpers::ReportScriptErrorFmt("AI.ini: \"%s\" doesn't exist.", sKey.c_str());
|
||||
dist.fPercent[TNS_None] = 0;
|
||||
dist.fPercent[TNS_Miss] = 1;
|
||||
dist.fPercent[TNS_W5] = 0;
|
||||
dist.fPercent[TNS_W4] = 0;
|
||||
dist.fPercent[TNS_W3] = 0;
|
||||
dist.fPercent[TNS_W2] = 0;
|
||||
dist.fPercent[TNS_W1] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
#define SET_MALF_IF(condition, tns) \
|
||||
if(condition) \
|
||||
{ \
|
||||
LuaHelpers::ReportScriptError("AI weight for " #tns " not set."); \
|
||||
dist.fPercent[tns]= 0; \
|
||||
}
|
||||
dist.fPercent[TNS_None] = 0;
|
||||
bSuccess = pNode->GetAttrValue( "WeightMiss", dist.fPercent[TNS_Miss] );
|
||||
SET_MALF_IF(!bSuccess, TNS_Miss);
|
||||
bSuccess = pNode->GetAttrValue( "WeightW5", dist.fPercent[TNS_W5] );
|
||||
SET_MALF_IF(!bSuccess, TNS_W5);
|
||||
bSuccess = pNode->GetAttrValue( "WeightW4", dist.fPercent[TNS_W4] );
|
||||
SET_MALF_IF(!bSuccess, TNS_W4);
|
||||
bSuccess = pNode->GetAttrValue( "WeightW3", dist.fPercent[TNS_W3] );
|
||||
SET_MALF_IF(!bSuccess, TNS_W3);
|
||||
bSuccess = pNode->GetAttrValue( "WeightW2", dist.fPercent[TNS_W2] );
|
||||
SET_MALF_IF(!bSuccess, TNS_W2);
|
||||
bSuccess = pNode->GetAttrValue( "WeightW1", dist.fPercent[TNS_W1] );
|
||||
SET_MALF_IF(!bSuccess, TNS_W1);
|
||||
#undef SET_MALF_IF
|
||||
}
|
||||
|
||||
float fSum = 0;
|
||||
for( int j=0; j<NUM_TapNoteScore; j++ )
|
||||
|
||||
+20
-7
@@ -294,9 +294,12 @@ void ScreenManager::ThemeChanged()
|
||||
for( unsigned i=0; i<asOverlays.size(); i++ )
|
||||
{
|
||||
Screen *pScreen = MakeNewScreen( asOverlays[i] );
|
||||
LuaThreadVariable var2( "LoadingScreen", pScreen->GetName() );
|
||||
pScreen->BeginScreen();
|
||||
g_OverlayScreens.push_back( pScreen );
|
||||
if(pScreen)
|
||||
{
|
||||
LuaThreadVariable var2( "LoadingScreen", pScreen->GetName() );
|
||||
pScreen->BeginScreen();
|
||||
g_OverlayScreens.push_back( pScreen );
|
||||
}
|
||||
}
|
||||
|
||||
// reload song manager colors (to avoid crashes) -aj
|
||||
@@ -323,9 +326,12 @@ void ScreenManager::ReloadOverlayScreens()
|
||||
for( unsigned i=0; i<asOverlays.size(); i++ )
|
||||
{
|
||||
Screen *pScreen = MakeNewScreen( asOverlays[i] );
|
||||
LuaThreadVariable var2( "LoadingScreen", pScreen->GetName() );
|
||||
pScreen->BeginScreen();
|
||||
g_OverlayScreens.push_back( pScreen );
|
||||
if(pScreen)
|
||||
{
|
||||
LuaThreadVariable var2( "LoadingScreen", pScreen->GetName() );
|
||||
pScreen->BeginScreen();
|
||||
g_OverlayScreens.push_back( pScreen );
|
||||
}
|
||||
}
|
||||
|
||||
this->RefreshCreditsMessages();
|
||||
@@ -552,7 +558,10 @@ Screen* ScreenManager::MakeNewScreen( const RString &sScreenName )
|
||||
|
||||
map<RString,CreateScreenFn>::iterator iter = g_pmapRegistrees->find( sClassName );
|
||||
if( iter == g_pmapRegistrees->end() )
|
||||
RageException::Throw( "Screen \"%s\" has an invalid class \"%s\".", sScreenName.c_str(), sClassName.c_str() );
|
||||
{
|
||||
LuaHelpers::ReportScriptErrorFmt("Screen \"%s\" has an invalid class \"%s\".", sScreenName.c_str(), sClassName.c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
this->ZeroNextUpdate();
|
||||
|
||||
@@ -571,6 +580,10 @@ void ScreenManager::PrepareScreen( const RString &sScreenName )
|
||||
return;
|
||||
|
||||
Screen* pNewScreen = MakeNewScreen(sScreenName);
|
||||
if(pNewScreen == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
LoadedScreen ls;
|
||||
|
||||
@@ -29,7 +29,9 @@ void ScreenOptionsMaster::Init()
|
||||
vector<RString> asLineNames;
|
||||
split( LINE_NAMES, ",", asLineNames );
|
||||
if( asLineNames.empty() )
|
||||
RageException::Throw( "\"%s::LineNames\" is empty.", m_sName.c_str() );
|
||||
{
|
||||
LuaHelpers::ReportScriptErrorFmt("\"%s:LineNames\" is empty.", m_sName.c_str());
|
||||
}
|
||||
|
||||
if( FORCE_ALL_PLAYERS )
|
||||
{
|
||||
@@ -59,7 +61,7 @@ void ScreenOptionsMaster::Init()
|
||||
OptionRowHandler *pHand = OptionRowHandlerUtil::Make( cmds );
|
||||
if( pHand == NULL )
|
||||
{
|
||||
LuaHelpers::ReportScriptErrorFmt("Invalid OptionRowHandler \"%s\" in \"%s::Line%i\".", cmds.GetOriginalCommandString().c_str(), m_sName.c_str(), i);
|
||||
LuaHelpers::ReportScriptErrorFmt("Invalid OptionRowHandler \"%s\" in \"%s:Line:%s\".", cmds.GetOriginalCommandString().c_str(), m_sName.c_str(), sLineName.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+18
-14
@@ -52,8 +52,10 @@ void ScreenSelect::Init()
|
||||
}
|
||||
}
|
||||
|
||||
if( !m_aGameCommands.size() )
|
||||
RageException::Throw( "Screen \"%s\" does not set any choices.", m_sName.c_str() );
|
||||
if(m_aGameCommands.empty())
|
||||
{
|
||||
LuaHelpers::ReportScriptErrorFmt("Screen \"%s\" does not set any choices.", m_sName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenSelect::BeginScreen()
|
||||
@@ -157,25 +159,27 @@ void ScreenSelect::HandleScreenMessage( const ScreenMessage SM )
|
||||
}
|
||||
}
|
||||
|
||||
if( bAllPlayersChoseTheSame )
|
||||
if(!m_aGameCommands.empty())
|
||||
{
|
||||
const GameCommand &gc = m_aGameCommands[iMastersIndex];
|
||||
m_sNextScreen = gc.m_sScreen;
|
||||
if( !gc.m_bInvalid )
|
||||
gc.ApplyToAllPlayers();
|
||||
}
|
||||
else
|
||||
{
|
||||
FOREACH_HumanPlayer( p )
|
||||
if( bAllPlayersChoseTheSame )
|
||||
{
|
||||
int iIndex = this->GetSelectionIndex(p);
|
||||
const GameCommand &gc = m_aGameCommands[iIndex];
|
||||
const GameCommand &gc = m_aGameCommands[iMastersIndex];
|
||||
m_sNextScreen = gc.m_sScreen;
|
||||
if( !gc.m_bInvalid )
|
||||
gc.ApplyToAllPlayers();
|
||||
}
|
||||
else
|
||||
{
|
||||
FOREACH_HumanPlayer( p )
|
||||
{
|
||||
int iIndex = this->GetSelectionIndex(p);
|
||||
const GameCommand &gc = m_aGameCommands[iIndex];
|
||||
m_sNextScreen = gc.m_sScreen;
|
||||
if( !gc.m_bInvalid )
|
||||
gc.Apply( p );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StopTimer();
|
||||
|
||||
SCREENMAN->RefreshCreditsMessages();
|
||||
|
||||
@@ -369,7 +369,7 @@ void ScreenSelectMaster::UpdateSelectableChoices()
|
||||
* If any options are playable, make sure one is selected. */
|
||||
FOREACH_HumanPlayer( p )
|
||||
{
|
||||
if( !m_aGameCommands[m_iChoice[p]].IsPlayable() )
|
||||
if(!m_aGameCommands.empty() && !m_aGameCommands[m_iChoice[p]].IsPlayable())
|
||||
Move( p, MenuDir_Auto );
|
||||
}
|
||||
}
|
||||
@@ -402,7 +402,7 @@ bool ScreenSelectMaster::Move( PlayerNumber pn, MenuDir dir )
|
||||
if( seen.find(iSwitchToIndex) != seen.end() )
|
||||
return false; // went full circle and none found
|
||||
seen.insert( iSwitchToIndex );
|
||||
} while( !m_aGameCommands[iSwitchToIndex].IsPlayable() && !DO_SWITCH_ANYWAYS );
|
||||
} while(!m_aGameCommands.empty() && !m_aGameCommands[iSwitchToIndex].IsPlayable() && !DO_SWITCH_ANYWAYS);
|
||||
|
||||
return ChangeSelection( pn, dir, iSwitchToIndex );
|
||||
}
|
||||
@@ -821,22 +821,28 @@ bool ScreenSelectMaster::MenuStart( const InputEventPlus &input )
|
||||
return true;
|
||||
}
|
||||
|
||||
const GameCommand &mc = m_aGameCommands[m_iChoice[pn]];
|
||||
GameCommand empty_mc;
|
||||
// This is so we can avoid having problems when the GameCommands in the choices were all invalid or didn't load or similar. -Kyz
|
||||
GameCommand *mc= &empty_mc;
|
||||
if(!m_aGameCommands.empty())
|
||||
{
|
||||
mc = &(m_aGameCommands[m_iChoice[pn]]);
|
||||
}
|
||||
|
||||
/* If no options are playable, then we're just waiting for one to become available.
|
||||
* If any options are playable, then the selection must be playable. */
|
||||
if( !AnyOptionsArePlayable() )
|
||||
return false;
|
||||
|
||||
SOUND->PlayOnceFromDir( ANNOUNCER->GetPathTo(ssprintf("%s comment %s",m_sName.c_str(), mc.m_sName.c_str())) );
|
||||
SOUND->PlayOnceFromDir( ANNOUNCER->GetPathTo(ssprintf("%s comment %s",m_sName.c_str(), mc->m_sName.c_str())) );
|
||||
|
||||
// Play a copy of the sound, so it'll finish playing even if we leave the screen immediately.
|
||||
if( mc.m_sSoundPath.empty() && !m_bDoubleChoiceNoSound )
|
||||
if( mc->m_sSoundPath.empty() && !m_bDoubleChoiceNoSound )
|
||||
m_soundStart.PlayCopy();
|
||||
|
||||
if( mc.m_sScreen.empty() )
|
||||
if( mc->m_sScreen.empty() )
|
||||
{
|
||||
mc.ApplyToAllPlayers();
|
||||
mc->ApplyToAllPlayers();
|
||||
// We want to be able to broadcast a Start message to the theme, in
|
||||
// case a themer wants to handle something. -aj
|
||||
Message msg( MessageIDToString((MessageID)(Message_MenuStartP1+pn)) );
|
||||
|
||||
@@ -239,7 +239,14 @@ void ScreenSelectMusic::BeginScreen()
|
||||
}
|
||||
|
||||
if( GAMESTATE->GetCurrentStyle() == NULL )
|
||||
RageException::Throw( "The Style has not been set. A theme must set the Style before loading ScreenSelectMusic." );
|
||||
{
|
||||
LuaHelpers::ReportScriptError("The Style has not been set. A theme must set the Style before loading ScreenSelectMusic.");
|
||||
// Instead of crashing, set the first compatible style.
|
||||
vector<StepsType> vst;
|
||||
GAMEMAN->GetStepsTypesForGame( GAMESTATE->m_pCurGame, vst );
|
||||
const Style *pStyle = GAMEMAN->GetFirstCompatibleStyle( GAMESTATE->m_pCurGame, GAMESTATE->GetNumSidesJoined(), vst[0] );
|
||||
GAMESTATE->SetCurrentStyle( pStyle );
|
||||
}
|
||||
|
||||
if( GAMESTATE->m_PlayMode == PlayMode_Invalid )
|
||||
{
|
||||
|
||||
+2
-2
@@ -175,7 +175,7 @@ void Sprite::LoadFromNode( const XNode* pNode )
|
||||
|
||||
pFrame->GetAttrValue( "Frame", iFrameIndex );
|
||||
if( iFrameIndex >= m_pTexture->GetNumFrames() )
|
||||
RageException::Throw( "%s: State #%i is frame %d, but the texture \"%s\" only has %d frames",
|
||||
LuaHelpers::ReportScriptErrorFmt( "%s: State #%i is frame %d, but the texture \"%s\" only has %d frames",
|
||||
ActorUtil::GetWhere(pNode).c_str(), i, iFrameIndex, sPath.c_str(), m_pTexture->GetNumFrames() );
|
||||
newState.rect = *m_pTexture->GetTextureCoordRect( iFrameIndex );
|
||||
|
||||
@@ -210,7 +210,7 @@ void Sprite::LoadFromNode( const XNode* pNode )
|
||||
if( !pNode->GetAttrValue(sFrameKey, iFrameIndex) )
|
||||
break;
|
||||
if( iFrameIndex >= m_pTexture->GetNumFrames() )
|
||||
RageException::Throw( "%s: %s is %d, but the texture \"%s\" only has %d frames",
|
||||
LuaHelpers::ReportScriptErrorFmt( "%s: %s is %d, but the texture \"%s\" only has %d frames",
|
||||
ActorUtil::GetWhere(pNode).c_str(), sFrameKey.c_str(), iFrameIndex, sPath.c_str(), m_pTexture->GetNumFrames() );
|
||||
|
||||
newState.rect = *m_pTexture->GetTextureCoordRect( iFrameIndex );
|
||||
|
||||
+25
-17
@@ -669,10 +669,15 @@ bool ThemeManager::GetPathInfoToRaw( PathInfo &out, const RString &sThemeName_,
|
||||
|
||||
RString message = ssprintf(
|
||||
"ThemeManager: There is more than one theme element that matches "
|
||||
"'%s/%s/%s'. Please remove all but one of these matches.",
|
||||
"'%s/%s/%s'. Please remove all but one of these matches: ",
|
||||
sThemeName.c_str(), sCategory.c_str(), MetricsGroupAndElementToFileName(sMetricsGroup,sElement).c_str() );
|
||||
message+= asElementPaths[1];
|
||||
for(size_t i= 1; i < asElementPaths.size(); ++i)
|
||||
{
|
||||
message+= ", " + asElementPaths[i];
|
||||
}
|
||||
|
||||
switch( Dialog::AbortRetryIgnore(message) )
|
||||
switch( LuaHelpers::ReportScriptError(message, "", true) )
|
||||
{
|
||||
case Dialog::abort:
|
||||
RageException::Throw( "%s", message.c_str() );
|
||||
@@ -717,7 +722,7 @@ bool ThemeManager::GetPathInfoToRaw( PathInfo &out, const RString &sThemeName_,
|
||||
"Verify that this redirect is correct.",
|
||||
sPath.c_str(), sNewFileName.c_str());
|
||||
|
||||
switch( Dialog::AbortRetryIgnore(sMessage) )
|
||||
switch( LuaHelpers::ReportScriptError(sMessage) )
|
||||
{
|
||||
case Dialog::retry:
|
||||
ReloadMetrics();
|
||||
@@ -753,11 +758,9 @@ bool ThemeManager::GetPathInfoToAndFallback( PathInfo &out, ElementCategory cate
|
||||
return false;
|
||||
}
|
||||
|
||||
RageException::Throw( "Infinite recursion looking up theme element \"%s\"",
|
||||
MetricsGroupAndElementToFileName(sMetricsGroup, sElement).c_str() );
|
||||
/* Not really reached, but Appple's gcc 4 can't figure that out without
|
||||
* optimization even though RE:Throw() is correctly annotated. */
|
||||
while( true ) {}
|
||||
LuaHelpers::ReportScriptErrorFmt("Infinite recursion looking up theme element \"%s\"",
|
||||
MetricsGroupAndElementToFileName(sMetricsGroup, sElement).c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ThemeManager::GetPathInfo( PathInfo &out, ElementCategory category, const RString &sMetricsGroup_, const RString &sElement_, bool bOptional )
|
||||
@@ -811,10 +814,14 @@ try_element_again:
|
||||
ReloadMetrics();
|
||||
goto try_element_again;
|
||||
case Dialog::ignore:
|
||||
LOG->UserLog( "Theme element", sCategory + '/' + sFileName,
|
||||
"could not be found in \"%s\" or \"%s\".",
|
||||
GetThemeDirFromName(m_sCurThemeName).c_str(),
|
||||
GetThemeDirFromName(SpecialFiles::BASE_THEME_NAME).c_str() );
|
||||
{
|
||||
RString error= ssprintf(sCategory + '/' + sFileName,
|
||||
"could not be found in \"%s\" or \"%s\".",
|
||||
GetThemeDirFromName(m_sCurThemeName).c_str(),
|
||||
GetThemeDirFromName(SpecialFiles::BASE_THEME_NAME).c_str() );
|
||||
LOG->UserLog("Theme element", "%s", error.c_str());
|
||||
LuaHelpers::ScriptErrorMessage(error);
|
||||
}
|
||||
|
||||
// Err?
|
||||
if( sFileName == "_missing" )
|
||||
@@ -918,7 +925,8 @@ bool ThemeManager::GetMetricRawRecursive( const IniFile &ini, const RString &sMe
|
||||
return false;
|
||||
}
|
||||
|
||||
RageException::Throw( "Infinite recursion looking up theme metric \"%s::%s\".", sMetricsGroup.c_str(), sValueName.c_str() );
|
||||
LuaHelpers::ReportScriptErrorFmt("Infinite recursion looking up theme metric \"%s::%s\".", sMetricsGroup.c_str(), sValueName.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
RString ThemeManager::GetMetricRaw( const IniFile &ini, const RString &sMetricsGroup_, const RString &sValueName_ )
|
||||
@@ -945,12 +953,12 @@ RString ThemeManager::GetMetricRaw( const IniFile &ini, const RString &sMetricsG
|
||||
else
|
||||
FAIL_M("");
|
||||
|
||||
RString sMessage = ssprintf( "%s \"%s::%s\" is missing. Correct this and click Retry, or Cancel to break.",
|
||||
sType.c_str(),
|
||||
sMetricsGroup.c_str(),
|
||||
RString sMessage = ssprintf( "%s \"%s::%s\" is missing.",
|
||||
sType.c_str(),
|
||||
sMetricsGroup.c_str(),
|
||||
sValueName.c_str() );
|
||||
|
||||
switch( Dialog::AbortRetryIgnore(sMessage) )
|
||||
switch( LuaHelpers::ReportScriptError(sMessage, "", true) )
|
||||
{
|
||||
case Dialog::abort:
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user