From 27a4d9df27b2c36e6c2f05c29b5d1500ed10062e Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sat, 30 Jul 2005 04:48:37 +0000 Subject: [PATCH] add OptionsCursorPlus, an OptionsCursor with "CanGoLeft/Right" arrows --- stepmania/src/OptionsCursor.cpp | 85 +++++++++++++++++++++++++++++---- stepmania/src/OptionsCursor.h | 27 ++++++++++- 2 files changed, 102 insertions(+), 10 deletions(-) diff --git a/stepmania/src/OptionsCursor.cpp b/stepmania/src/OptionsCursor.cpp index bd53a49f5f..3d98a4fec1 100644 --- a/stepmania/src/OptionsCursor.cpp +++ b/stepmania/src/OptionsCursor.cpp @@ -12,35 +12,64 @@ OptionsCursor::OptionsCursor() this->AddChild( &m_sprRight ); } +OptionsCursorPlus::OptionsCursorPlus() +{ + this->AddChild( &m_sprCanGoLeft ); + this->AddChild( &m_sprCanGoRight ); + + SetCanGo( false, false ); +} + OptionsCursor::OptionsCursor( const OptionsCursor &cpy ): ActorFrame( cpy ), m_sprLeft( cpy.m_sprLeft ), m_sprMiddle( cpy.m_sprMiddle ), - m_sprRight( cpy.m_sprRight ) + m_sprRight( cpy.m_sprRight ), + m_sprCanGoLeft( cpy.m_sprCanGoLeft ), + m_sprCanGoRight( cpy.m_sprCanGoRight ) { /* Re-add children, or m_SubActors will point to cpy's children and not our own. */ m_SubActors.clear(); this->AddChild( &m_sprMiddle ); this->AddChild( &m_sprLeft ); this->AddChild( &m_sprRight ); + + this->AddChild( &m_sprCanGoLeft ); + this->AddChild( &m_sprCanGoRight ); } -void OptionsCursor::Load( CString sType, Element elem ) +OptionsCursorPlus::OptionsCursorPlus( const OptionsCursorPlus &cpy ): + OptionsCursor( cpy ), + m_sprCanGoLeft( cpy.m_sprCanGoLeft ), + m_sprCanGoRight( cpy.m_sprCanGoRight ) +{ + this->AddChild( &m_sprCanGoLeft ); + this->AddChild( &m_sprCanGoRight ); +} + +void OptionsCursor::Load( const CString &sType, Element elem ) { CString sPath = THEME->GetPathG( sType, ssprintf("%s 3x2",elem==cursor?"cursor":"underline") ); - - m_sprLeft.Load( sPath ); + m_sprMiddle.Load( sPath ); + m_sprLeft.Load( sPath ); m_sprRight.Load( sPath ); - m_sprLeft.StopAnimating(); m_sprMiddle.StopAnimating(); + m_sprLeft.StopAnimating(); m_sprRight.StopAnimating(); } +void OptionsCursorPlus::Load( const CString &sType, Element elem ) +{ + OptionsCursor::Load( sType, elem ); + + m_sprCanGoLeft.Load( THEME->GetPathG(sType,"CanGoLeft") ); + m_sprCanGoRight.Load( THEME->GetPathG(sType,"CanGoRight") ); +} + void OptionsCursor::Set( PlayerNumber pn ) { - int iBaseFrameNo; switch( pn ) { @@ -53,24 +82,49 @@ void OptionsCursor::Set( PlayerNumber pn ) m_sprRight.SetState( iBaseFrameNo+2 ); } +void OptionsCursorPlus::SetCanGo( bool bCanGoLeft, bool bCanGoRight ) +{ + m_sprCanGoLeft.EnableAnimation( bCanGoLeft ); + m_sprCanGoRight.EnableAnimation( bCanGoRight ); + + m_sprCanGoLeft.SetDiffuse( bCanGoLeft ? RageColor(1,1,1,1) : RageColor(0.5,0.5,0.5,1) ); + m_sprCanGoRight.SetDiffuse( bCanGoRight ? RageColor(1,1,1,1) : RageColor(0.5,0.5,0.5,1) ); +} + void OptionsCursor::StopTweening() { ActorFrame::StopTweening(); - m_sprLeft.StopTweening(); m_sprMiddle.StopTweening(); + m_sprLeft.StopTweening(); m_sprRight.StopTweening(); } +void OptionsCursorPlus::StopTweening() +{ + OptionsCursor::StopTweening(); + + m_sprCanGoLeft.StopTweening(); + m_sprCanGoRight.StopTweening(); +} + void OptionsCursor::BeginTweening( float fSecs ) { ActorFrame::BeginTweening( fSecs ); - m_sprLeft.BeginTweening( fSecs ); m_sprMiddle.BeginTweening( fSecs ); + m_sprLeft.BeginTweening( fSecs ); m_sprRight.BeginTweening( fSecs ); } +void OptionsCursorPlus::BeginTweening( float fSecs ) +{ + OptionsCursor::BeginTweening( fSecs ); + + m_sprCanGoLeft.BeginTweening( fSecs ); + m_sprCanGoRight.BeginTweening( fSecs ); +} + void OptionsCursor::SetBarWidth( int iWidth ) { if( iWidth%2 == 1 ) @@ -83,6 +137,21 @@ void OptionsCursor::SetBarWidth( int iWidth ) m_sprRight.SetX( +iWidth/2 + fFrameWidth/2 ); } +void OptionsCursorPlus::SetBarWidth( int iWidth ) +{ + OptionsCursor::SetBarWidth( iWidth ); + + float fFrameWidth = m_sprLeft.GetUnzoomedWidth(); + + m_sprCanGoLeft.SetX( m_sprLeft.GetDestX() ); + m_sprCanGoRight.SetX( m_sprRight.GetDestX() ); +} + +int OptionsCursor::GetBarWidth() +{ + return m_sprLeft.GetZoomX() * m_sprLeft.GetUnzoomedWidth(); +} + /* * (c) 2001-2003 Chris Danford * All rights reserved. diff --git a/stepmania/src/OptionsCursor.h b/stepmania/src/OptionsCursor.h index 3e31ebcc71..4b28978168 100644 --- a/stepmania/src/OptionsCursor.h +++ b/stepmania/src/OptionsCursor.h @@ -15,18 +15,41 @@ public: OptionsCursor( const OptionsCursor &cpy ); enum Element { cursor, underline }; - void Load( CString sType, Element elem ); + void Load( const CString &sType, Element elem ); void Set( PlayerNumber pn ); void StopTweening(); void BeginTweening( float fSecs ); void SetBarWidth( int iWidth ); + int GetBarWidth(); protected: - Sprite m_sprLeft; Sprite m_sprMiddle; + Sprite m_sprLeft; Sprite m_sprRight; + + Sprite m_sprCanGoLeft; + Sprite m_sprCanGoRight; +}; + +class OptionsCursorPlus : public OptionsCursor +{ +public: + OptionsCursorPlus(); + OptionsCursorPlus( const OptionsCursorPlus &cpy ); + + void Load( const CString &sType, Element elem ); + + void StopTweening(); + void BeginTweening( float fSecs ); + void SetBarWidth( int iWidth ); + void SetCanGo( bool bCanGoLeft, bool bCanGoRight ); + +protected: + + Sprite m_sprCanGoLeft; + Sprite m_sprCanGoRight; }; #endif