From da13d14d510f1fedcaa1deeef0d6832a99f4b07c Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Wed, 13 Apr 2005 08:07:09 +0000 Subject: [PATCH] fix DifficultyList colors not updated when selecting Random --- stepmania/src/DifficultyMeter.cpp | 67 +++++++++++++------------------ stepmania/src/DifficultyMeter.h | 6 +-- 2 files changed, 30 insertions(+), 43 deletions(-) diff --git a/stepmania/src/DifficultyMeter.cpp b/stepmania/src/DifficultyMeter.cpp index 0aab1704d2..e53b1b9d4e 100644 --- a/stepmania/src/DifficultyMeter.cpp +++ b/stepmania/src/DifficultyMeter.cpp @@ -135,7 +135,7 @@ void DifficultyMeter::SetFromGameState( PlayerNumber pn ) if( pTrail ) SetFromTrail( pTrail ); else - SetFromCourseDifficulty( GAMESTATE->m_PreferredCourseDifficulty[pn] ); + SetFromMeterAndCourseDifficulty( 0, GAMESTATE->m_PreferredCourseDifficulty[pn] ); } else { @@ -143,7 +143,7 @@ void DifficultyMeter::SetFromGameState( PlayerNumber pn ) if( pSteps ) SetFromSteps( pSteps ); else - SetFromDifficulty( GAMESTATE->m_PreferredDifficulty[pn] ); + SetFromMeterAndDifficulty( 0, GAMESTATE->m_PreferredDifficulty[pn] ); } } @@ -156,20 +156,7 @@ void DifficultyMeter::SetFromSteps( const Steps* pSteps ) } Difficulty dc = pSteps->GetDifficulty(); - SetFromMeterAndDifficulty( pSteps->GetMeter(), dc ); - PlayDifficultyCommand( GetDifficultyCommandName( dc ) ); - if( m_bShowEditDescription ) - { - if( dc == DIFFICULTY_EDIT ) - { - m_textEditDescription.SetVisible( true ); - m_textEditDescription.SetText( pSteps->GetDescription() ); - } - else - { - m_textEditDescription.SetVisible( false ); - } - } + SetInternal( pSteps->GetMeter(), dc, GetDifficultyCommandName(dc), dc == DIFFICULTY_EDIT ? pSteps->GetDescription() : CString() ); } void DifficultyMeter::SetFromTrail( const Trail* pTrail ) @@ -181,33 +168,25 @@ void DifficultyMeter::SetFromTrail( const Trail* pTrail ) } CourseDifficulty cd = pTrail->m_CourseDifficulty; - SetFromMeterAndDifficulty( pTrail->GetMeter(), cd ); - PlayDifficultyCommand( GetCourseDifficultyCommandName( cd ) ); - if( m_bShowEditDescription ) - m_textEditDescription.SetVisible( false ); + SetInternal( pTrail->GetMeter(), cd, GetCourseDifficultyCommandName( cd ), CString() ); } void DifficultyMeter::Unset() { - SetFromMeterAndDifficulty( 0, DIFFICULTY_BEGINNER ); - PlayDifficultyCommand( DIFFICULTY_COMMAND_NAME_NONE ); - if( m_bShowEditDescription ) - m_textEditDescription.SetText(""); -} - -void DifficultyMeter::SetFromDifficulty( Difficulty dc ) -{ - SetFromMeterAndDifficulty( 0, DIFFICULTY_BEGINNER ); - PlayDifficultyCommand( GetDifficultyCommandName( dc ) ); -} - -void DifficultyMeter::SetFromCourseDifficulty( CourseDifficulty cd ) -{ - SetFromMeterAndDifficulty( 0, DIFFICULTY_BEGINNER ); - PlayDifficultyCommand( GetCourseDifficultyCommandName( cd ) ); + SetInternal( 0, DIFFICULTY_BEGINNER, DIFFICULTY_COMMAND_NAME_NONE, CString() ); } void DifficultyMeter::SetFromMeterAndDifficulty( int iMeter, Difficulty dc ) +{ + SetInternal( 0, DIFFICULTY_BEGINNER, GetDifficultyCommandName(dc), CString() ); +} + +void DifficultyMeter::SetFromMeterAndCourseDifficulty( int iMeter, CourseDifficulty cd ) +{ + SetInternal( 0, DIFFICULTY_BEGINNER, GetCourseDifficultyCommandName(cd), CString() ); +} + +void DifficultyMeter::SetInternal( int iMeter, Difficulty dc, const CString &sDifficultyCommand, const CString &sDescription ) { if( m_bShowFeet ) { @@ -242,10 +221,20 @@ void DifficultyMeter::SetFromMeterAndDifficulty( int iMeter, Difficulty dc ) m_textMeter.SetText( sMeter ); } } -} -void DifficultyMeter::PlayDifficultyCommand( CString sDifficultyCommand ) -{ + if( m_bShowEditDescription ) + { + if( dc == DIFFICULTY_EDIT ) + { + m_textEditDescription.SetVisible( true ); + m_textEditDescription.SetText( sDescription ); + } + else + { + m_textEditDescription.SetVisible( false ); + } + } + if( m_sCurDifficultyCommand == sDifficultyCommand ) return; m_sCurDifficultyCommand = sDifficultyCommand; diff --git a/stepmania/src/DifficultyMeter.h b/stepmania/src/DifficultyMeter.h index fdc609248c..ee9125d8aa 100644 --- a/stepmania/src/DifficultyMeter.h +++ b/stepmania/src/DifficultyMeter.h @@ -57,6 +57,7 @@ public: void SetFromGameState( PlayerNumber pn ); void SetFromMeterAndDifficulty( int iMeter, Difficulty dc ); + void SetFromMeterAndCourseDifficulty( int iMeter, CourseDifficulty cd ); void SetFromSteps( const Steps* pSteps ); void SetFromTrail( const Trail* pTrail ); void Unset(); @@ -65,10 +66,7 @@ public: void PushSelf( lua_State *L ); private: - void SetFromDifficulty( Difficulty dc ); - void SetFromCourseDifficulty( CourseDifficulty cd ); - - void PlayDifficultyCommand( CString diff ); + void SetInternal( int iMeter, Difficulty dc, const CString &sDifficultyCommand, const CString &sDescription ); BitmapText m_textFeet; // bar CString m_sCurDifficultyCommand;