add Lua ActorScroller
This commit is contained in:
@@ -22,12 +22,14 @@ public:
|
||||
lua_pushnil( L );
|
||||
return 1;
|
||||
}
|
||||
static int GetNumChildren( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumChildren() ); return 1; }
|
||||
|
||||
static void Register(lua_State *L)
|
||||
{
|
||||
ADD_METHOD( propagate )
|
||||
ADD_METHOD( SetUpdateRate )
|
||||
ADD_METHOD( GetChild )
|
||||
ADD_METHOD( GetNumChildren )
|
||||
LunaActor<T>::Register( L );
|
||||
}
|
||||
};
|
||||
@@ -44,6 +46,7 @@ public:
|
||||
virtual void AddChild( Actor* pActor );
|
||||
virtual void RemoveChild( Actor* pActor );
|
||||
Actor* GetChild( const CString &sName );
|
||||
int GetNumChildren() const { return m_SubActors.size(); }
|
||||
|
||||
void RemoveAllChildren();
|
||||
void MoveToTail( Actor* pActor );
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
#include "RageLog.h"
|
||||
#include "ActorUtil.h"
|
||||
|
||||
// lua start
|
||||
LUA_REGISTER_CLASS( ActorScroller )
|
||||
// lua end
|
||||
|
||||
/* Tricky: We need ActorFrames created in XML to auto delete their children.
|
||||
* We don't want classes that derive from ActorFrame to auto delete their
|
||||
* children. The name "ActorFrame" is widely used in XML, so we'll have
|
||||
@@ -100,8 +104,8 @@ void ActorScroller::LoadFromNode( const CString &sDir, const XNode *pNode )
|
||||
vTranslateTerm0,
|
||||
vTranslateTerm1,
|
||||
vTranslateTerm2 );
|
||||
SetCurrentAndDestinationItem( int(-fItemPaddingStart) );
|
||||
SetDestinationItem( int(m_SubActors.size()-1+fItemPaddingEnd) );
|
||||
SetCurrentAndDestinationItem( -fItemPaddingStart );
|
||||
SetDestinationItem( m_SubActors.size()-1+fItemPaddingEnd );
|
||||
}
|
||||
|
||||
void ActorScroller::Update( float fDeltaTime )
|
||||
|
||||
@@ -4,8 +4,23 @@
|
||||
#define ActorScroller_H
|
||||
|
||||
#include "ActorFrame.h"
|
||||
|
||||
struct XNode;
|
||||
|
||||
template<class T>
|
||||
class LunaActorScroller : public LunaActorFrame<T>
|
||||
{
|
||||
public:
|
||||
LunaActorScroller() { LUA->Register( Register ); }
|
||||
|
||||
static int SetCurrentAndDestinationItem( T* p, lua_State *L ) { p->SetCurrentAndDestinationItem( FArg(1) ); return 0; }
|
||||
|
||||
static void Register(lua_State *L)
|
||||
{
|
||||
ADD_METHOD( SetCurrentAndDestinationItem )
|
||||
LunaActor<T>::Register( L );
|
||||
}
|
||||
};
|
||||
|
||||
class ActorScroller : public ActorFrame
|
||||
{
|
||||
public:
|
||||
@@ -23,8 +38,13 @@ public:
|
||||
virtual void DrawPrimitives(); // DOES draw
|
||||
|
||||
void LoadFromNode( const CString &sDir, const XNode *pNode );
|
||||
void SetDestinationItem( int iItem ) { m_fDestinationItem = float(iItem); }
|
||||
void SetCurrentAndDestinationItem( int iItem ) { m_fCurrentItem = m_fDestinationItem = float(iItem); }
|
||||
void SetDestinationItem( float fItemIndex ) { m_fDestinationItem = fItemIndex; }
|
||||
void SetCurrentAndDestinationItem( float fItemIndex ) { m_fCurrentItem = m_fDestinationItem = fItemIndex; }
|
||||
|
||||
//
|
||||
// Commands
|
||||
//
|
||||
void PushSelf( lua_State *L );
|
||||
|
||||
protected:
|
||||
bool m_bLoaded;
|
||||
|
||||
@@ -207,14 +207,15 @@ ScreenCredits::ScreenCredits( CString sName ) : ScreenAttract( sName )
|
||||
pFrame->Load( THEME->GetPathG("ScreenCredits","background frame") );
|
||||
m_ScrollerFrames.AddChild( pFrame );
|
||||
}
|
||||
const int iFirst = -2, iLast = NUM_BACKGROUNDS+2;
|
||||
m_ScrollerBackgrounds.SetCurrentAndDestinationItem( iFirst );
|
||||
m_ScrollerBackgrounds.SetDestinationItem( iLast );
|
||||
float fFirst = -2;
|
||||
float fLast = NUM_BACKGROUNDS+2;
|
||||
m_ScrollerBackgrounds.SetCurrentAndDestinationItem( fFirst );
|
||||
m_ScrollerBackgrounds.SetDestinationItem( fLast );
|
||||
|
||||
m_ScrollerFrames.SetCurrentAndDestinationItem( iFirst );
|
||||
m_ScrollerFrames.SetDestinationItem( iLast );
|
||||
m_ScrollerFrames.SetCurrentAndDestinationItem( fFirst );
|
||||
m_ScrollerFrames.SetDestinationItem( fLast );
|
||||
|
||||
fTime = max( fTime, BACKGROUNDS_SCROLL_SECONDS_PER_ITEM*(iLast-iFirst) );
|
||||
fTime = max( fTime, BACKGROUNDS_SCROLL_SECONDS_PER_ITEM*(fLast-fFirst) );
|
||||
}
|
||||
|
||||
m_ScrollerTexts.SetName( "Texts" );
|
||||
@@ -245,10 +246,11 @@ ScreenCredits::ScreenCredits( CString sName ) : ScreenAttract( sName )
|
||||
m_ScrollerTexts.AddChild( pText );
|
||||
}
|
||||
|
||||
const int iFirst = -10, iLast = ARRAYSIZE(CREDIT_LINES)+10;
|
||||
m_ScrollerTexts.SetCurrentAndDestinationItem( iFirst );
|
||||
m_ScrollerTexts.SetDestinationItem( iLast );
|
||||
fTime = max( fTime, TEXTS_SCROLL_SECONDS_PER_ITEM*(iLast-iFirst) );
|
||||
float fFirst = -10;
|
||||
float fLast = ARRAYSIZE(CREDIT_LINES)+10;
|
||||
m_ScrollerTexts.SetCurrentAndDestinationItem( fFirst );
|
||||
m_ScrollerTexts.SetDestinationItem( fLast );
|
||||
fTime = max( fTime, TEXTS_SCROLL_SECONDS_PER_ITEM*(fLast-fFirst) );
|
||||
}
|
||||
|
||||
m_Overlay.LoadFromAniDir( THEME->GetPathB("ScreenCredits","overlay") );
|
||||
|
||||
@@ -114,9 +114,9 @@ void HighScoreWheel::Load( const HighScoreList& hsl, int iIndexToFocus )
|
||||
|
||||
float HighScoreWheel::Scroll()
|
||||
{
|
||||
SetCurrentAndDestinationItem( m_SubActors.size()+5 );
|
||||
SetCurrentAndDestinationItem( m_SubActors.size()+5.0f );
|
||||
int iIndexToFocus = max( m_iIndexToFocus, 3 );
|
||||
SetDestinationItem( iIndexToFocus );
|
||||
SetDestinationItem( (float)iIndexToFocus );
|
||||
return GetTweenTimeLeft();
|
||||
}
|
||||
|
||||
|
||||
@@ -560,9 +560,9 @@ bool ScreenSelectMaster::ChangeSelection( PlayerNumber pn, int iNewChoice )
|
||||
if( SHOW_SCROLLER )
|
||||
{
|
||||
if( SHARED_PREVIEW_AND_CURSOR )
|
||||
m_Scroller[0].SetDestinationItem( iNewChoice );
|
||||
m_Scroller[0].SetDestinationItem( (float)iNewChoice );
|
||||
else
|
||||
m_Scroller[p].SetDestinationItem( iNewChoice );
|
||||
m_Scroller[p].SetDestinationItem( (float)iNewChoice );
|
||||
|
||||
if( SHARED_PREVIEW_AND_CURSOR )
|
||||
for( unsigned c=0; c<m_aGameCommands.size(); c++ )
|
||||
@@ -748,7 +748,7 @@ void ScreenSelectMaster::TweenOnScreen()
|
||||
{
|
||||
if( SHARED_PREVIEW_AND_CURSOR )
|
||||
{
|
||||
m_Scroller[0].SetCurrentAndDestinationItem( m_iChoice[0] );
|
||||
m_Scroller[0].SetCurrentAndDestinationItem( (float)m_iChoice[0] );
|
||||
SET_XY_AND_ON_COMMAND( m_Scroller[0] );
|
||||
for( unsigned c=0; c<m_aGameCommands.size(); c++ )
|
||||
COMMAND( *m_sprScroll[c][0], int(c) == m_iChoice[0]? "GainFocus":"LoseFocus" );
|
||||
@@ -756,7 +756,7 @@ void ScreenSelectMaster::TweenOnScreen()
|
||||
else
|
||||
FOREACH_HumanPlayer( p )
|
||||
{
|
||||
m_Scroller[p].SetCurrentAndDestinationItem( m_iChoice[p] );
|
||||
m_Scroller[p].SetCurrentAndDestinationItem( (float)m_iChoice[p] );
|
||||
SET_XY_AND_ON_COMMAND( m_Scroller[p] );
|
||||
for( unsigned c=0; c<m_aGameCommands.size(); c++ )
|
||||
COMMAND( *m_sprScroll[c][p], int(c) == m_iChoice[p]? "GainFocus":"LoseFocus" );
|
||||
|
||||
Reference in New Issue
Block a user