add OptionsCursorPlus, an OptionsCursor with "CanGoLeft/Right" arrows
This commit is contained in:
@@ -12,35 +12,64 @@ OptionsCursor::OptionsCursor()
|
|||||||
this->AddChild( &m_sprRight );
|
this->AddChild( &m_sprRight );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OptionsCursorPlus::OptionsCursorPlus()
|
||||||
|
{
|
||||||
|
this->AddChild( &m_sprCanGoLeft );
|
||||||
|
this->AddChild( &m_sprCanGoRight );
|
||||||
|
|
||||||
|
SetCanGo( false, false );
|
||||||
|
}
|
||||||
|
|
||||||
OptionsCursor::OptionsCursor( const OptionsCursor &cpy ):
|
OptionsCursor::OptionsCursor( const OptionsCursor &cpy ):
|
||||||
ActorFrame( cpy ),
|
ActorFrame( cpy ),
|
||||||
m_sprLeft( cpy.m_sprLeft ),
|
m_sprLeft( cpy.m_sprLeft ),
|
||||||
m_sprMiddle( cpy.m_sprMiddle ),
|
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. */
|
/* Re-add children, or m_SubActors will point to cpy's children and not our own. */
|
||||||
m_SubActors.clear();
|
m_SubActors.clear();
|
||||||
this->AddChild( &m_sprMiddle );
|
this->AddChild( &m_sprMiddle );
|
||||||
this->AddChild( &m_sprLeft );
|
this->AddChild( &m_sprLeft );
|
||||||
this->AddChild( &m_sprRight );
|
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") );
|
CString sPath = THEME->GetPathG( sType, ssprintf("%s 3x2",elem==cursor?"cursor":"underline") );
|
||||||
|
|
||||||
m_sprLeft.Load( sPath );
|
|
||||||
m_sprMiddle.Load( sPath );
|
m_sprMiddle.Load( sPath );
|
||||||
|
m_sprLeft.Load( sPath );
|
||||||
m_sprRight.Load( sPath );
|
m_sprRight.Load( sPath );
|
||||||
|
|
||||||
m_sprLeft.StopAnimating();
|
|
||||||
m_sprMiddle.StopAnimating();
|
m_sprMiddle.StopAnimating();
|
||||||
|
m_sprLeft.StopAnimating();
|
||||||
m_sprRight.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 )
|
void OptionsCursor::Set( PlayerNumber pn )
|
||||||
{
|
{
|
||||||
|
|
||||||
int iBaseFrameNo;
|
int iBaseFrameNo;
|
||||||
switch( pn )
|
switch( pn )
|
||||||
{
|
{
|
||||||
@@ -53,24 +82,49 @@ void OptionsCursor::Set( PlayerNumber pn )
|
|||||||
m_sprRight.SetState( iBaseFrameNo+2 );
|
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()
|
void OptionsCursor::StopTweening()
|
||||||
{
|
{
|
||||||
ActorFrame::StopTweening();
|
ActorFrame::StopTweening();
|
||||||
|
|
||||||
m_sprLeft.StopTweening();
|
|
||||||
m_sprMiddle.StopTweening();
|
m_sprMiddle.StopTweening();
|
||||||
|
m_sprLeft.StopTweening();
|
||||||
m_sprRight.StopTweening();
|
m_sprRight.StopTweening();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OptionsCursorPlus::StopTweening()
|
||||||
|
{
|
||||||
|
OptionsCursor::StopTweening();
|
||||||
|
|
||||||
|
m_sprCanGoLeft.StopTweening();
|
||||||
|
m_sprCanGoRight.StopTweening();
|
||||||
|
}
|
||||||
|
|
||||||
void OptionsCursor::BeginTweening( float fSecs )
|
void OptionsCursor::BeginTweening( float fSecs )
|
||||||
{
|
{
|
||||||
ActorFrame::BeginTweening( fSecs );
|
ActorFrame::BeginTweening( fSecs );
|
||||||
|
|
||||||
m_sprLeft.BeginTweening( fSecs );
|
|
||||||
m_sprMiddle.BeginTweening( fSecs );
|
m_sprMiddle.BeginTweening( fSecs );
|
||||||
|
m_sprLeft.BeginTweening( fSecs );
|
||||||
m_sprRight.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 )
|
void OptionsCursor::SetBarWidth( int iWidth )
|
||||||
{
|
{
|
||||||
if( iWidth%2 == 1 )
|
if( iWidth%2 == 1 )
|
||||||
@@ -83,6 +137,21 @@ void OptionsCursor::SetBarWidth( int iWidth )
|
|||||||
m_sprRight.SetX( +iWidth/2 + fFrameWidth/2 );
|
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
|
* (c) 2001-2003 Chris Danford
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
|||||||
@@ -15,18 +15,41 @@ public:
|
|||||||
OptionsCursor( const OptionsCursor &cpy );
|
OptionsCursor( const OptionsCursor &cpy );
|
||||||
|
|
||||||
enum Element { cursor, underline };
|
enum Element { cursor, underline };
|
||||||
void Load( CString sType, Element elem );
|
void Load( const CString &sType, Element elem );
|
||||||
void Set( PlayerNumber pn );
|
void Set( PlayerNumber pn );
|
||||||
|
|
||||||
void StopTweening();
|
void StopTweening();
|
||||||
void BeginTweening( float fSecs );
|
void BeginTweening( float fSecs );
|
||||||
void SetBarWidth( int iWidth );
|
void SetBarWidth( int iWidth );
|
||||||
|
int GetBarWidth();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
Sprite m_sprLeft;
|
|
||||||
Sprite m_sprMiddle;
|
Sprite m_sprMiddle;
|
||||||
|
Sprite m_sprLeft;
|
||||||
Sprite m_sprRight;
|
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
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user