add Backing element, load using ThemeManager for easier discoverability and overriding
This commit is contained in:
@@ -16,30 +16,35 @@ ComboGraph::ComboGraph()
|
|||||||
|
|
||||||
m_pNormalCombo = NULL;
|
m_pNormalCombo = NULL;
|
||||||
m_pMaxCombo = NULL;
|
m_pMaxCombo = NULL;
|
||||||
m_pMaxComboText = NULL;
|
m_pComboNumber = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComboGraph::LoadFromNode( const XNode* pNode )
|
void ComboGraph::Load( RString sMetricsGroup )
|
||||||
{
|
{
|
||||||
ActorFrame::LoadFromNode( pNode );
|
BODY_WIDTH.Load( sMetricsGroup, "BodyWidth" );
|
||||||
|
|
||||||
Actor *pActor = this->GetChild( "MaxComboText" );
|
Actor *pActor = NULL;
|
||||||
if( pActor == NULL )
|
|
||||||
RageException::Throw( "%s: ComboGraph: must have a child named \"MaxComboText\"", ActorUtil::GetWhere(pNode).c_str() );
|
|
||||||
m_pMaxComboText = dynamic_cast<BitmapText *>( pActor );
|
|
||||||
if( m_pMaxComboText == NULL )
|
|
||||||
RageException::Throw( "%s: ComboGraph: \"MaxComboText\" child is not a BitmapText", ActorUtil::GetWhere(pNode).c_str() );
|
|
||||||
|
|
||||||
m_pNormalCombo = this->GetChild( "NormalCombo" );
|
m_pBacking = ActorUtil::MakeActor( THEME->GetPathG(sMetricsGroup,"Backing") );
|
||||||
if( m_pNormalCombo == NULL )
|
m_pBacking->ZoomToWidth( BODY_WIDTH );
|
||||||
RageException::Throw( "%s: ComboGraph: must have a child named \"NormalCombo\"", ActorUtil::GetWhere(pNode).c_str() );
|
this->AddChild( m_pBacking );
|
||||||
|
|
||||||
m_pMaxCombo = this->GetChild( "MaxCombo" );
|
m_pNormalCombo = ActorUtil::MakeActor( THEME->GetPathG(sMetricsGroup,"NormalCombo") );
|
||||||
if( m_pMaxCombo == NULL )
|
m_pNormalCombo->ZoomToWidth( BODY_WIDTH );
|
||||||
RageException::Throw( "%s: ComboGraph: must have a child named \"MaxCombo\"", ActorUtil::GetWhere(pNode).c_str() );
|
this->AddChild( m_pNormalCombo );
|
||||||
|
|
||||||
|
m_pMaxCombo = ActorUtil::MakeActor( THEME->GetPathG(sMetricsGroup,"MaxCombo") );
|
||||||
|
m_pMaxCombo->ZoomToWidth( BODY_WIDTH );
|
||||||
|
this->AddChild( m_pMaxCombo );
|
||||||
|
|
||||||
|
pActor = ActorUtil::MakeActor( THEME->GetPathG(sMetricsGroup,"ComboNumber") );
|
||||||
|
m_pComboNumber = dynamic_cast<BitmapText *>( pActor );
|
||||||
|
if( m_pComboNumber == NULL )
|
||||||
|
RageException::Throw( "ComboGraph: \"sMetricsGroup\" \"ComboNumber\" must be a BitmapText" );
|
||||||
|
this->AddChild( m_pComboNumber );
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComboGraph::Load( const StageStats &s, const PlayerStageStats &pss )
|
void ComboGraph::Set( const StageStats &s, const PlayerStageStats &pss )
|
||||||
{
|
{
|
||||||
const float fFirstSecond = 0;
|
const float fFirstSecond = 0;
|
||||||
const float fLastSecond = s.GetTotalPossibleStepsSeconds();
|
const float fLastSecond = s.GetTotalPossibleStepsSeconds();
|
||||||
@@ -84,14 +89,13 @@ void ComboGraph::Load( const StageStats &s, const PlayerStageStats &pss )
|
|||||||
if( !bIsMax )
|
if( !bIsMax )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BitmapText *pText = m_pMaxComboText->Copy();
|
BitmapText *pText = m_pComboNumber->Copy();
|
||||||
|
|
||||||
const float fStart = SCALE( combo.m_fStartSecond, fFirstSecond, fLastSecond, 0.0f, 1.0f );
|
const float fStart = SCALE( combo.m_fStartSecond, fFirstSecond, fLastSecond, 0.0f, 1.0f );
|
||||||
const float fSize = SCALE( combo.m_fSizeSeconds, 0, fLastSecond-fFirstSecond, 0.0f, 1.0f );
|
const float fSize = SCALE( combo.m_fSizeSeconds, 0, fLastSecond-fFirstSecond, 0.0f, 1.0f );
|
||||||
|
|
||||||
const float fWidth = m_pNormalCombo->GetUnzoomedWidth();
|
|
||||||
const float fCenterPercent = fStart + fSize/2;
|
const float fCenterPercent = fStart + fSize/2;
|
||||||
const float fCenterXPos = SCALE( fCenterPercent, 0.0f, 1.0f, -fWidth/2.0f, fWidth/2.0f );
|
const float fCenterXPos = SCALE( fCenterPercent, 0.0f, 1.0f, -BODY_WIDTH/2.0f, BODY_WIDTH/2.0f );
|
||||||
pText->SetX( fCenterXPos );
|
pText->SetX( fCenterXPos );
|
||||||
|
|
||||||
pText->SetText( ssprintf("%i",combo.GetStageCnt()) );
|
pText->SetText( ssprintf("%i",combo.GetStageCnt()) );
|
||||||
@@ -102,7 +106,7 @@ void ComboGraph::Load( const StageStats &s, const PlayerStageStats &pss )
|
|||||||
/* Hide the templates. */
|
/* Hide the templates. */
|
||||||
m_pNormalCombo->SetVisible( false );
|
m_pNormalCombo->SetVisible( false );
|
||||||
m_pMaxCombo->SetVisible( false );
|
m_pMaxCombo->SetVisible( false );
|
||||||
m_pMaxComboText->SetVisible( false );
|
m_pComboNumber->SetVisible( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
// lua start
|
// lua start
|
||||||
@@ -111,17 +115,23 @@ void ComboGraph::Load( const StageStats &s, const PlayerStageStats &pss )
|
|||||||
class LunaComboGraph: public Luna<ComboGraph>
|
class LunaComboGraph: public Luna<ComboGraph>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static int LoadFromStats( T* p, lua_State *L )
|
static int Load( T* p, lua_State *L )
|
||||||
|
{
|
||||||
|
p->Load( SArg(1) );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
static int Set( T* p, lua_State *L )
|
||||||
{
|
{
|
||||||
StageStats *pStageStats = Luna<StageStats>::check( L, 1 );
|
StageStats *pStageStats = Luna<StageStats>::check( L, 1 );
|
||||||
PlayerStageStats *pPlayerStageStats = Luna<PlayerStageStats>::check( L, 2 );
|
PlayerStageStats *pPlayerStageStats = Luna<PlayerStageStats>::check( L, 2 );
|
||||||
p->Load( *pStageStats, *pPlayerStageStats );
|
p->Set( *pStageStats, *pPlayerStageStats );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
LunaComboGraph()
|
LunaComboGraph()
|
||||||
{
|
{
|
||||||
ADD_METHOD( LoadFromStats );
|
ADD_METHOD( Load );
|
||||||
|
ADD_METHOD( Set );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -3,16 +3,18 @@
|
|||||||
|
|
||||||
#include "ActorFrame.h"
|
#include "ActorFrame.h"
|
||||||
#include "PlayerNumber.h"
|
#include "PlayerNumber.h"
|
||||||
#include "BitmapText.h"
|
#include "ThemeMetric.h"
|
||||||
|
|
||||||
class StageStats;
|
class StageStats;
|
||||||
class PlayerStageStats;
|
class PlayerStageStats;
|
||||||
|
class BitmapText;
|
||||||
|
|
||||||
class ComboGraph: public ActorFrame
|
class ComboGraph: public ActorFrame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ComboGraph();
|
ComboGraph();
|
||||||
void Load( const StageStats &s, const PlayerStageStats &pss );
|
void Load( RString sMetricsGroup );
|
||||||
virtual void LoadFromNode( const XNode* pNode );
|
void Set( const StageStats &s, const PlayerStageStats &pss );
|
||||||
virtual ComboGraph *Copy() const;
|
virtual ComboGraph *Copy() const;
|
||||||
virtual bool AutoLoadChildren() const { return true; }
|
virtual bool AutoLoadChildren() const { return true; }
|
||||||
|
|
||||||
@@ -22,9 +24,11 @@ public:
|
|||||||
virtual void PushSelf( lua_State *L );
|
virtual void PushSelf( lua_State *L );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
ThemeMetric<float> BODY_WIDTH;
|
||||||
|
Actor *m_pBacking;
|
||||||
Actor *m_pNormalCombo;
|
Actor *m_pNormalCombo;
|
||||||
Actor *m_pMaxCombo;
|
Actor *m_pMaxCombo;
|
||||||
BitmapText *m_pMaxComboText;
|
BitmapText *m_pComboNumber;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user