MeterDisplay::LoadFromNode

This commit is contained in:
Glenn Maynard
2005-02-26 10:08:12 +00:00
parent b3a8e8fd4f
commit 0ae355094f
2 changed files with 40 additions and 2 deletions
+39 -2
View File
@@ -3,7 +3,12 @@
#include "RageUtil.h"
#include "GameState.h"
#include "song.h"
#include "ActorUtil.h"
#include "XmlFile.h"
#include "RageLog.h"
REGISTER_ACTOR_CLASS(MeterDisplay)
REGISTER_ACTOR_CLASS(SongMeterDisplay)
MeterDisplay::MeterDisplay()
{
@@ -16,14 +21,46 @@ void MeterDisplay::Load( CString sStreamPath, float fStreamWidth, CString sTipPa
m_sprStream.Load( sStreamPath );
m_sprStream.SetZoomX( fStreamWidth / m_sprStream.GetUnzoomedWidth() );
m_sprTip.Load( sTipPath );
this->AddChild( &m_sprStream );
this->AddChild( m_sprTip );
m_sprTip.Load( sTipPath );
SetPercent( 0.5f );
}
void MeterDisplay::LoadFromNode( const CString& sDir, const XNode* pNode )
{
LOG->Trace( "MeterDisplay::LoadFromNode(%s,node)", sDir.c_str() );
if( !pNode->GetAttrValue( "StreamWidth", m_fStreamWidth ) )
RageException::Throw( "MeterDisplay in " + sDir + " missing StreamWidth attribute" );
{
CString sStreamPath;
if( !pNode->GetAttrValue( "StreamPath", sStreamPath ) )
RageException::Throw( "MeterDisplay in " + sDir + " missing StreamPath attribute" );
sStreamPath = sDir + sStreamPath;
ActorUtil::ResolvePath( sStreamPath, sDir );
m_sprStream.Load( sStreamPath );
m_sprStream.SetZoomX( m_fStreamWidth / m_sprStream.GetUnzoomedWidth() );
this->AddChild( &m_sprStream );
}
const XNode* pChild = pNode->GetChild( "Tip" );
if( pChild != NULL )
{
m_sprTip.LoadFromNode( sDir, pChild );
this->AddChild( m_sprTip );
}
SetPercent( 0.5f );
ActorFrame::LoadFromNode( sDir, pNode );
}
void MeterDisplay::SetPercent( float fPercent )
{
ASSERT( fPercent >= 0 && fPercent <= 1 );