From ef6ea34f697c48891fca528625fd32f6b13ea344 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Fri, 22 Apr 2005 20:59:01 +0000 Subject: [PATCH] cursor: tween width at the same time as tweening the position for smoother motion --- stepmania/src/OptionsCursor.cpp | 31 ++++++++++++++++++------------- stepmania/src/OptionsCursor.h | 4 +++- stepmania/src/ScreenOptions.cpp | 2 +- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/stepmania/src/OptionsCursor.cpp b/stepmania/src/OptionsCursor.cpp index d56d2192b1..5cdbf1baa3 100644 --- a/stepmania/src/OptionsCursor.cpp +++ b/stepmania/src/OptionsCursor.cpp @@ -44,6 +44,24 @@ void OptionsCursor::Set( PlayerNumber pn ) m_sprRight.SetState( iBaseFrameNo+2 ); } +void OptionsCursor::StopTweening() +{ + ActorFrame::StopTweening(); + + m_sprLeft.StopTweening(); + m_sprMiddle.StopTweening(); + m_sprRight.StopTweening(); +} + +void OptionsCursor::BeginTweening( float fSecs ) +{ + ActorFrame::BeginTweening( fSecs ); + + m_sprLeft.BeginTweening( fSecs ); + m_sprMiddle.BeginTweening( fSecs ); + m_sprRight.BeginTweening( fSecs ); +} + void OptionsCursor::SetBarWidth( int iWidth ) { if( iWidth%2 == 1 ) @@ -56,19 +74,6 @@ void OptionsCursor::SetBarWidth( int iWidth ) m_sprRight.SetX( +iWidth/2 + fFrameWidth/2 ); } -void OptionsCursor::TweenBarWidth( int iNewWidth ) -{ - m_sprLeft.StopTweening(); - m_sprMiddle.StopTweening(); - m_sprRight.StopTweening(); - - m_sprLeft.BeginTweening( 0.2f ); - m_sprMiddle.BeginTweening( 0.2f ); - m_sprRight.BeginTweening( 0.2f ); - - SetBarWidth( iNewWidth ); -} - /* * (c) 2001-2003 Chris Danford * All rights reserved. diff --git a/stepmania/src/OptionsCursor.h b/stepmania/src/OptionsCursor.h index 1f42f9bc2c..16664c52fa 100644 --- a/stepmania/src/OptionsCursor.h +++ b/stepmania/src/OptionsCursor.h @@ -16,8 +16,10 @@ public: enum Element { cursor, underline }; void Load( CString sType, Element elem ); void Set( PlayerNumber pn ); + + void StopTweening(); + void BeginTweening( float fSecs ); void SetBarWidth( int iWidth ); - void TweenBarWidth( int iNewWidth ); protected: diff --git a/stepmania/src/ScreenOptions.cpp b/stepmania/src/ScreenOptions.cpp index e39a867ddd..2c89578c6f 100644 --- a/stepmania/src/ScreenOptions.cpp +++ b/stepmania/src/ScreenOptions.cpp @@ -417,7 +417,7 @@ void ScreenOptions::TweenCursor( PlayerNumber pn ) cursor.SetXY( (float)iX, (float)iY ); } - cursor.TweenBarWidth( iWidth ); + cursor.SetBarWidth( iWidth ); if( GAMESTATE->IsHumanPlayer(pn) ) {