cursor parts: Sprite -> AutoActor to get rid of baked player text, move Cursor and Underline into their own metrics groups to (rather than lumping to ScreenOptions or OptionRow) so that the name meanings are clearer
This commit is contained in:
@@ -2,13 +2,10 @@
|
|||||||
#include "OptionsCursor.h"
|
#include "OptionsCursor.h"
|
||||||
#include "RageUtil.h"
|
#include "RageUtil.h"
|
||||||
#include "ThemeManager.h"
|
#include "ThemeManager.h"
|
||||||
|
#include "ActorUtil.h"
|
||||||
|
|
||||||
OptionsCursor::OptionsCursor()
|
OptionsCursor::OptionsCursor()
|
||||||
{
|
{
|
||||||
this->AddChild( &m_sprMiddle );
|
|
||||||
this->AddChild( &m_sprLeft );
|
|
||||||
this->AddChild( &m_sprRight );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OptionsCursorPlus::OptionsCursorPlus()
|
OptionsCursorPlus::OptionsCursorPlus()
|
||||||
@@ -23,9 +20,9 @@ OptionsCursor::OptionsCursor( const OptionsCursor &cpy ):
|
|||||||
{
|
{
|
||||||
/* 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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
OptionsCursorPlus::OptionsCursorPlus( const OptionsCursorPlus &cpy ):
|
OptionsCursorPlus::OptionsCursorPlus( const OptionsCursorPlus &cpy ):
|
||||||
@@ -37,30 +34,26 @@ OptionsCursorPlus::OptionsCursorPlus( const OptionsCursorPlus &cpy ):
|
|||||||
this->AddChild( m_sprCanGoRight );
|
this->AddChild( m_sprCanGoRight );
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsCursor::Load( const RString &sType, Element elem, PlayerNumber pn )
|
void OptionsCursor::Load( const RString &sMetricsGroup )
|
||||||
{
|
{
|
||||||
RString sElem = ssprintf( "%s %s", elem==cursor?"cursor":"underline", PlayerNumberToString(pn).c_str() );
|
#define LOAD_SPR( spr, name ) \
|
||||||
RString sPath = THEME->GetPathG( sType, sElem );
|
spr.Load( THEME->GetPathG(sMetricsGroup,name) ); \
|
||||||
|
spr->SetName( name ); \
|
||||||
|
ActorUtil::LoadAllCommandsAndSetXYAndOnCommand( spr, sMetricsGroup ); \
|
||||||
|
this->AddChild( spr );
|
||||||
|
|
||||||
m_sprMiddle.Load( sPath );
|
LOAD_SPR( m_sprMiddle, "Middle" );
|
||||||
m_sprLeft.Load( sPath );
|
LOAD_SPR( m_sprLeft, "Left" );
|
||||||
m_sprRight.Load( sPath );
|
LOAD_SPR( m_sprRight, "Right" );
|
||||||
|
#undef LOAD_SPR
|
||||||
m_sprMiddle.StopAnimating();
|
|
||||||
m_sprLeft.StopAnimating();
|
|
||||||
m_sprRight.StopAnimating();
|
|
||||||
|
|
||||||
m_sprLeft.SetState( 0 );
|
|
||||||
m_sprMiddle.SetState( 1 );
|
|
||||||
m_sprRight.SetState( 2 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsCursorPlus::Load( const RString &sType, Element elem, PlayerNumber pn )
|
void OptionsCursorPlus::Load( const RString &sMetricsGroup )
|
||||||
{
|
{
|
||||||
OptionsCursor::Load( sType, elem, pn );
|
OptionsCursor::Load( sMetricsGroup );
|
||||||
|
|
||||||
m_sprCanGoLeft.Load( THEME->GetPathG(sType,"CanGoLeft") );
|
m_sprCanGoLeft.Load( THEME->GetPathG(sMetricsGroup,"CanGoLeft") );
|
||||||
m_sprCanGoRight.Load( THEME->GetPathG(sType,"CanGoRight") );
|
m_sprCanGoRight.Load( THEME->GetPathG(sMetricsGroup,"CanGoRight") );
|
||||||
|
|
||||||
this->AddChild( m_sprCanGoLeft );
|
this->AddChild( m_sprCanGoLeft );
|
||||||
this->AddChild( m_sprCanGoRight );
|
this->AddChild( m_sprCanGoRight );
|
||||||
@@ -81,9 +74,9 @@ void OptionsCursor::StopTweening()
|
|||||||
{
|
{
|
||||||
ActorFrame::StopTweening();
|
ActorFrame::StopTweening();
|
||||||
|
|
||||||
m_sprMiddle.StopTweening();
|
m_sprMiddle->StopTweening();
|
||||||
m_sprLeft.StopTweening();
|
m_sprLeft->StopTweening();
|
||||||
m_sprRight.StopTweening();
|
m_sprRight->StopTweening();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsCursorPlus::StopTweening()
|
void OptionsCursorPlus::StopTweening()
|
||||||
@@ -98,9 +91,9 @@ void OptionsCursor::BeginTweening( float fSecs )
|
|||||||
{
|
{
|
||||||
ActorFrame::BeginTweening( fSecs );
|
ActorFrame::BeginTweening( fSecs );
|
||||||
|
|
||||||
m_sprMiddle.BeginTweening( fSecs );
|
m_sprMiddle->BeginTweening( fSecs );
|
||||||
m_sprLeft.BeginTweening( fSecs );
|
m_sprLeft->BeginTweening( fSecs );
|
||||||
m_sprRight.BeginTweening( fSecs );
|
m_sprRight->BeginTweening( fSecs );
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsCursorPlus::BeginTweening( float fSecs )
|
void OptionsCursorPlus::BeginTweening( float fSecs )
|
||||||
@@ -113,27 +106,25 @@ void OptionsCursorPlus::BeginTweening( float fSecs )
|
|||||||
|
|
||||||
void OptionsCursor::SetBarWidth( int iWidth )
|
void OptionsCursor::SetBarWidth( int iWidth )
|
||||||
{
|
{
|
||||||
if( iWidth%2 == 1 )
|
float fWidth = ceilf(iWidth/2.0f)*2.0f; // round up to nearest even number
|
||||||
iWidth++; // round up to nearest even number
|
|
||||||
float fFrameWidth = m_sprLeft.GetUnzoomedWidth();
|
|
||||||
|
|
||||||
m_sprMiddle.SetZoomX( iWidth/(float)fFrameWidth );
|
m_sprMiddle->ZoomToWidth( fWidth );
|
||||||
|
|
||||||
m_sprLeft.SetX( -iWidth/2 - fFrameWidth/2 );
|
m_sprLeft->SetX( -fWidth/2 );
|
||||||
m_sprRight.SetX( +iWidth/2 + fFrameWidth/2 );
|
m_sprRight->SetX( +fWidth/2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsCursorPlus::SetBarWidth( int iWidth )
|
void OptionsCursorPlus::SetBarWidth( int iWidth )
|
||||||
{
|
{
|
||||||
OptionsCursor::SetBarWidth( iWidth );
|
OptionsCursor::SetBarWidth( iWidth );
|
||||||
|
|
||||||
m_sprCanGoLeft->SetX( m_sprLeft.GetDestX() );
|
m_sprCanGoLeft->SetX( m_sprLeft->GetDestX() );
|
||||||
m_sprCanGoRight->SetX( m_sprRight.GetDestX() );
|
m_sprCanGoRight->SetX( m_sprRight->GetDestX() );
|
||||||
}
|
}
|
||||||
|
|
||||||
int OptionsCursor::GetBarWidth() const
|
int OptionsCursor::GetBarWidth() const
|
||||||
{
|
{
|
||||||
float fWidth = m_sprLeft.GetZoomX() * m_sprLeft.GetUnzoomedWidth();
|
float fWidth = m_sprMiddle->GetZoomX() * m_sprMiddle->GetUnzoomedWidth();
|
||||||
return (int)fWidth;
|
return (int)fWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,15 +8,13 @@
|
|||||||
#include "PlayerNumber.h"
|
#include "PlayerNumber.h"
|
||||||
#include "AutoActor.h"
|
#include "AutoActor.h"
|
||||||
|
|
||||||
|
|
||||||
class OptionsCursor : public ActorFrame
|
class OptionsCursor : public ActorFrame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OptionsCursor();
|
OptionsCursor();
|
||||||
OptionsCursor( const OptionsCursor &cpy );
|
OptionsCursor( const OptionsCursor &cpy );
|
||||||
|
|
||||||
enum Element { cursor, underline };
|
void Load( const RString &sMetricsGroup );
|
||||||
void Load( const RString &sType, Element elem, PlayerNumber pn );
|
|
||||||
|
|
||||||
void StopTweening();
|
void StopTweening();
|
||||||
void BeginTweening( float fSecs );
|
void BeginTweening( float fSecs );
|
||||||
@@ -24,10 +22,9 @@ public:
|
|||||||
int GetBarWidth() const;
|
int GetBarWidth() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
AutoActor m_sprMiddle;
|
||||||
Sprite m_sprMiddle;
|
AutoActor m_sprLeft;
|
||||||
Sprite m_sprLeft;
|
AutoActor m_sprRight;
|
||||||
Sprite m_sprRight;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class OptionsCursorPlus : public OptionsCursor
|
class OptionsCursorPlus : public OptionsCursor
|
||||||
@@ -36,7 +33,7 @@ public:
|
|||||||
OptionsCursorPlus();
|
OptionsCursorPlus();
|
||||||
OptionsCursorPlus( const OptionsCursorPlus &cpy );
|
OptionsCursorPlus( const OptionsCursorPlus &cpy );
|
||||||
|
|
||||||
void Load( const RString &sType, Element elem, PlayerNumber pn );
|
void Load( const RString &sMetricsGroup );
|
||||||
|
|
||||||
void StopTweening();
|
void StopTweening();
|
||||||
void BeginTweening( float fSecs );
|
void BeginTweening( float fSecs );
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ void ScreenOptions::Init()
|
|||||||
// init cursors
|
// init cursors
|
||||||
FOREACH_PlayerNumber( p )
|
FOREACH_PlayerNumber( p )
|
||||||
{
|
{
|
||||||
m_Cursor[p].Load( m_sName, OptionsCursorPlus::cursor, p );
|
m_Cursor[p].Load( "OptionsCursor" + PlayerNumberToString(p) );
|
||||||
m_Cursor[p].SetName( "Cursor" );
|
m_Cursor[p].SetName( "Cursor" );
|
||||||
LOAD_ALL_COMMANDS( m_Cursor[p] );
|
LOAD_ALL_COMMANDS( m_Cursor[p] );
|
||||||
m_framePage.AddChild( &m_Cursor[p] );
|
m_framePage.AddChild( &m_Cursor[p] );
|
||||||
|
|||||||
Reference in New Issue
Block a user