From 2684ff5124b5c0d8ac4ef16896e7c167aed4b3e9 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sat, 4 Dec 2004 22:33:55 +0000 Subject: [PATCH] allow GameCommand to set SortOrder --- stepmania/src/GameCommand.cpp | 19 ++++++++++++++++++- stepmania/src/GameCommand.h | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/stepmania/src/GameCommand.cpp b/stepmania/src/GameCommand.cpp index fd3653f960..9c95b608d9 100644 --- a/stepmania/src/GameCommand.cpp +++ b/stepmania/src/GameCommand.cpp @@ -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; diff --git a/stepmania/src/GameCommand.h b/stepmania/src/GameCommand.h index 3a1b0f3d85..5326458c77 100644 --- a/stepmania/src/GameCommand.h +++ b/stepmania/src/GameCommand.h @@ -48,6 +48,7 @@ struct GameCommand // used in SelectMode Character* m_pCharacter; std::map m_SetEnv; CString m_sSongGroup; + SortOrder m_SortOrder; }; #endif