allow GameCommand to set SortOrder

This commit is contained in:
Chris Danford
2004-12-04 22:33:55 +00:00
parent b16cb534c5
commit 2684ff5124
2 changed files with 19 additions and 1 deletions
+18 -1
View File
@@ -38,6 +38,7 @@ void GameCommand::Init()
m_pCourse = NULL;
m_pTrail = NULL;
m_pCharacter = NULL;
m_SortOrder = SORT_INVALID;
}
bool CompareSongOptions( const SongOptions &so1, const SongOptions &so2 );
@@ -95,6 +96,8 @@ bool GameCommand::DescribesCurrentMode( PlayerNumber pn ) const
return false;
if( m_pTrail && GAMESTATE->m_pCurTrail[pn] != m_pTrail )
return false;
if( m_SortOrder && GAMESTATE->m_SortOrder != m_SortOrder )
return false;
return true;
}
@@ -211,6 +214,16 @@ void GameCommand::Load( int iIndex, const Commands& cmds )
m_sSongGroup = sValue;
}
else if( sName == "sort" )
{
m_SortOrder = StringToSortOrder( sValue );
if( m_SortOrder == SORT_INVALID )
{
m_sInvalidReason = ssprintf( "SortOrder \"%s\" is not valid.", sValue.c_str() );
m_bInvalid |= true;
}
}
else
{
CString sWarning = ssprintf( "Command '%s' is not valid.", command->GetOriginalCommandString().c_str() );
@@ -486,6 +499,8 @@ void GameCommand::Apply( PlayerNumber pn ) const
GAMESTATE->m_mapEnv[ i->first ] = i->second;
if( !m_sSongGroup.empty() )
GAMESTATE->m_sPreferredSongGroup = m_sSongGroup;
if( m_SortOrder != SORT_INVALID )
GAMESTATE->m_SortOrder = m_SortOrder;
// HACK: Set life type to BATTERY just once here so it happens once and
// we don't override the user's changes if they back out.
@@ -506,7 +521,9 @@ bool GameCommand::IsZero() const
m_pCourse != NULL ||
m_pTrail != NULL ||
m_pCharacter != NULL ||
m_CourseDifficulty != DIFFICULTY_INVALID )
m_CourseDifficulty != DIFFICULTY_INVALID ||
m_SortOrder != SORT_INVALID
)
return false;
return true;