From 08ade0ee805a8140bf35936bd9e172c32fd95aed Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Mon, 27 Mar 2006 10:58:37 +0000 Subject: [PATCH] add ranking manual scroll sound fix weird scrolling if num songs < num lines shown --- stepmania/src/ScreenRanking.cpp | 28 ++++++++++++++++++++++++---- stepmania/src/ScreenRanking.h | 14 +++++++++----- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/stepmania/src/ScreenRanking.cpp b/stepmania/src/ScreenRanking.cpp index 9fcb0a9e81..92fd2b9731 100644 --- a/stepmania/src/ScreenRanking.cpp +++ b/stepmania/src/ScreenRanking.cpp @@ -201,6 +201,16 @@ float ScreenRanking::SetPage( const PageToShow &pts ) return 0; } +void ScreenRankingScroller::DoScroll( int iDir ) +{ + if( m_ListScoreRowItems.Scroll(iDir) ) + m_soundChange.Play(); + else + SCREENMAN->PlayInvalidSound(); +} + +///////////////////////////////////////////// + ScoreScroller::ScoreScroller() { this->DeleteChildrenWhenDone(); @@ -221,17 +231,25 @@ void ScoreScroller::SetStepsType( StepsType st, RageColor color ) ShiftSubActors( INT_MAX ); } -void ScoreScroller::Scroll( int iDir ) +bool ScoreScroller::Scroll( int iDir ) { + if( m_vScoreRowItemData.size() <= m_metricSongScoreRowsToDraw ) + return false; + float fDest = GetDestinationItem(); float fOldDest = fDest; fDest += iDir; - CLAMP( fDest, (m_metricSongScoreRowsToDraw-1)/2.0f, m_vScoreRowItemData.size()-(m_metricSongScoreRowsToDraw-1)/2.0f-1 ); + float fLowClamp = (m_metricSongScoreRowsToDraw-1)/2.0f; + float fHighClamp = m_vScoreRowItemData.size()-(m_metricSongScoreRowsToDraw-1)/2.0f-1; + CLAMP( fDest, fLowClamp, fHighClamp ); if( fOldDest != fDest ) { - // TODO: play sound - SetDestinationItem( fDest ); SetDestinationItem( fDest ); + return true; + } + else + { + return false(); } } @@ -425,6 +443,8 @@ void ScreenRankingScroller::Init() pts.st = STEPS_TYPES_TO_SHOW.GetValue()[i]; m_vPagesToShow.push_back( pts ); } + + m_soundChange.Load( THEME->GetPathS(m_sName,"change") ); } void ScreenRankingScroller::BeginScreen() diff --git a/stepmania/src/ScreenRanking.h b/stepmania/src/ScreenRanking.h index 0ae8736e16..b849875a75 100644 --- a/stepmania/src/ScreenRanking.h +++ b/stepmania/src/ScreenRanking.h @@ -12,6 +12,7 @@ #include "Difficulty.h" #include "ThemeMetric.h" #include "CommonMetrics.h" +#include "RageSound.h" class Course; class Song; @@ -98,7 +99,7 @@ public: const vector &DifficultiesToShow, float fItemHeight ); void SetStepsType( StepsType st, RageColor color ); - void Scroll( int iDir ); + bool Scroll( int iDir ); void ScrollTop(); protected: @@ -140,12 +141,13 @@ public: virtual void Init(); virtual void BeginScreen(); - virtual void MenuLeft( const InputEventPlus &input ) { m_ListScoreRowItems.Scroll(-1); } - virtual void MenuRight( const InputEventPlus &input ) { m_ListScoreRowItems.Scroll(+1); } - virtual void MenuUp( const InputEventPlus &input ) { m_ListScoreRowItems.Scroll(-1); } - virtual void MenuDown( const InputEventPlus &input ) { m_ListScoreRowItems.Scroll(+1); } + virtual void MenuLeft( const InputEventPlus &input ) { DoScroll(-1); } + virtual void MenuRight( const InputEventPlus &input ) { DoScroll(+1); } + virtual void MenuUp( const InputEventPlus &input ) { DoScroll(-1); } + virtual void MenuDown( const InputEventPlus &input ) { DoScroll(+1); } private: + void DoScroll( int iDir ); virtual float SetPage( const PageToShow &pts ); ScoreScroller m_ListScoreRowItems; @@ -159,6 +161,8 @@ private: ThemeMetric DIFFICULTY_START_X; ThemeMetric DIFFICULTY_Y; ThemeMetric NUM_MOST_RECENT_SCORES_TO_SHOW; + + RageSound m_soundChange; }; static const int NUM_RANKING_LINES = 5;