[MeterDisplay] Add Lua binding. "Allow setting and changing the width dynamically. Phase out the "StreamWidth" node property; set it with SetStreamWidth instead." [Glenn Maynard]
This commit is contained in:
@@ -18,6 +18,9 @@ sm-ssc v1.2.3 | 201103??
|
|||||||
* [WheelBase] Add GetCurrentIndex and GetNumItems Lua bindings. [AJ]
|
* [WheelBase] Add GetCurrentIndex and GetNumItems Lua bindings. [AJ]
|
||||||
* [ScreenSelectMusic] Add GetMusicWheel Lua binding. [AJ]
|
* [ScreenSelectMusic] Add GetMusicWheel Lua binding. [AJ]
|
||||||
* Added custom MusicWheel items. [AJ]
|
* Added custom MusicWheel items. [AJ]
|
||||||
|
* [MeterDisplay] Add Lua binding. "Allow setting and changing the width
|
||||||
|
dynamically. Phase out the "StreamWidth" node property; set it with
|
||||||
|
SetStreamWidth instead." [Glenn Maynard]
|
||||||
|
|
||||||
20110305
|
20110305
|
||||||
--------
|
--------
|
||||||
|
|||||||
+28
-7
@@ -17,15 +17,13 @@ MeterDisplay::MeterDisplay()
|
|||||||
|
|
||||||
void MeterDisplay::Load( RString sStreamPath, float fStreamWidth, RString sTipPath )
|
void MeterDisplay::Load( RString sStreamPath, float fStreamWidth, RString sTipPath )
|
||||||
{
|
{
|
||||||
m_fStreamWidth = fStreamWidth;
|
|
||||||
|
|
||||||
m_sprStream.Load( sStreamPath );
|
m_sprStream.Load( sStreamPath );
|
||||||
m_sprStream->SetZoomX( fStreamWidth / m_sprStream->GetUnzoomedWidth() );
|
|
||||||
this->AddChild( m_sprStream );
|
this->AddChild( m_sprStream );
|
||||||
|
|
||||||
m_sprTip.Load( sTipPath );
|
m_sprTip.Load( sTipPath );
|
||||||
this->AddChild( m_sprTip );
|
this->AddChild( m_sprTip );
|
||||||
|
|
||||||
|
SetStreamWidth( fStreamWidth );
|
||||||
SetPercent( 0.5f );
|
SetPercent( 0.5f );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,14 +31,10 @@ void MeterDisplay::LoadFromNode( const XNode* pNode )
|
|||||||
{
|
{
|
||||||
LOG->Trace( "MeterDisplay::LoadFromNode(%s)", ActorUtil::GetWhere(pNode).c_str() );
|
LOG->Trace( "MeterDisplay::LoadFromNode(%s)", ActorUtil::GetWhere(pNode).c_str() );
|
||||||
|
|
||||||
if( !pNode->GetAttrValue("StreamWidth", m_fStreamWidth) )
|
|
||||||
RageException::Throw( "%s: MeterDisplay: missing the \"StreamWidth\" attribute", ActorUtil::GetWhere(pNode).c_str() );
|
|
||||||
|
|
||||||
const XNode *pStream = pNode->GetChild( "Stream" );
|
const XNode *pStream = pNode->GetChild( "Stream" );
|
||||||
if( pStream == NULL )
|
if( pStream == NULL )
|
||||||
RageException::Throw( "%s: MeterDisplay: missing the \"Stream\" attribute", ActorUtil::GetWhere(pNode).c_str() );
|
RageException::Throw( "%s: MeterDisplay: missing the \"Stream\" attribute", ActorUtil::GetWhere(pNode).c_str() );
|
||||||
m_sprStream.LoadActorFromNode( pStream, this );
|
m_sprStream.LoadActorFromNode( pStream, this );
|
||||||
m_sprStream->SetZoomX( m_fStreamWidth / m_sprStream->GetUnzoomedWidth() );
|
|
||||||
this->AddChild( m_sprStream );
|
this->AddChild( m_sprStream );
|
||||||
|
|
||||||
const XNode* pChild = pNode->GetChild( "Tip" );
|
const XNode* pChild = pNode->GetChild( "Tip" );
|
||||||
@@ -50,6 +44,10 @@ void MeterDisplay::LoadFromNode( const XNode* pNode )
|
|||||||
this->AddChild( m_sprTip );
|
this->AddChild( m_sprTip );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float fStreamWidth = 0;
|
||||||
|
pNode->GetAttrValue( "StreamWidth", fStreamWidth );
|
||||||
|
SetStreamWidth( fStreamWidth );
|
||||||
|
|
||||||
SetPercent( 0.5f );
|
SetPercent( 0.5f );
|
||||||
|
|
||||||
ActorFrame::LoadFromNode( pNode );
|
ActorFrame::LoadFromNode( pNode );
|
||||||
@@ -65,6 +63,12 @@ void MeterDisplay::SetPercent( float fPercent )
|
|||||||
m_sprTip->SetX( SCALE(fPercent, 0.f, 1.f, -m_fStreamWidth/2, m_fStreamWidth/2) );
|
m_sprTip->SetX( SCALE(fPercent, 0.f, 1.f, -m_fStreamWidth/2, m_fStreamWidth/2) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MeterDisplay::SetStreamWidth( float fStreamWidth )
|
||||||
|
{
|
||||||
|
m_fStreamWidth = fStreamWidth;
|
||||||
|
m_sprStream->SetZoomX( m_fStreamWidth / m_sprStream->GetUnzoomedWidth() );
|
||||||
|
}
|
||||||
|
|
||||||
void SongMeterDisplay::Update( float fDeltaTime )
|
void SongMeterDisplay::Update( float fDeltaTime )
|
||||||
{
|
{
|
||||||
if( GAMESTATE->m_pCurSong )
|
if( GAMESTATE->m_pCurSong )
|
||||||
@@ -80,6 +84,23 @@ void SongMeterDisplay::Update( float fDeltaTime )
|
|||||||
MeterDisplay::Update( fDeltaTime );
|
MeterDisplay::Update( fDeltaTime );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// lua start
|
||||||
|
#include "LuaBinding.h"
|
||||||
|
|
||||||
|
class LunaMeterDisplay: public Luna<MeterDisplay>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static int SetStreamWidth( T* p, lua_State *L ) { p->SetStreamWidth(FArg(1)); return 0; }
|
||||||
|
|
||||||
|
LunaMeterDisplay()
|
||||||
|
{
|
||||||
|
ADD_METHOD( SetStreamWidth );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
LUA_REGISTER_DERIVED_CLASS( MeterDisplay, ActorFrame )
|
||||||
|
// lua end
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) 2003-2004 Chris Danford
|
* (c) 2003-2004 Chris Danford
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
|||||||
+1
-2
@@ -19,8 +19,7 @@ public:
|
|||||||
void SetStreamWidth( float fStreamWidth );
|
void SetStreamWidth( float fStreamWidth );
|
||||||
|
|
||||||
// Lua
|
// Lua
|
||||||
// HACK: not linking right now.
|
void PushSelf( lua_State *L );
|
||||||
// void PushSelf( lua_State *L );
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float m_fStreamWidth;
|
float m_fStreamWidth;
|
||||||
|
|||||||
Reference in New Issue
Block a user