pass a GameCommand to each wheel item bar (experimental)
This commit is contained in:
@@ -35,6 +35,7 @@ void GameCommand::Init()
|
||||
m_sText = "";
|
||||
m_bInvalid = true;
|
||||
m_iIndex = -1;
|
||||
m_bHasFocus = false;
|
||||
m_MultiPlayer = MultiPlayer_Invalid;
|
||||
m_pStyle = NULL;
|
||||
m_pm = PlayMode_Invalid;
|
||||
@@ -810,21 +811,25 @@ bool GameCommand::IsZero() const
|
||||
class LunaGameCommand: public Luna<GameCommand>
|
||||
{
|
||||
public:
|
||||
static int GetName( T* p, lua_State *L ) { lua_pushstring(L, p->m_sName ); return 1; }
|
||||
static int GetText( T* p, lua_State *L ) { lua_pushstring(L, p->m_sText ); return 1; }
|
||||
static int GetIndex( T* p, lua_State *L ) { lua_pushnumber(L, p->m_iIndex ); return 1; }
|
||||
static int GetName( T* p, lua_State *L ) { lua_pushstring(L, p->m_sName ); return 1; }
|
||||
static int GetText( T* p, lua_State *L ) { lua_pushstring(L, p->m_sText ); return 1; }
|
||||
static int GetIndex( T* p, lua_State *L ) { lua_pushnumber(L, p->m_iIndex ); return 1; }
|
||||
static int GetHasFocus( T* p, lua_State *L ) { lua_pushboolean(L, p->m_bHasFocus ); return 1; }
|
||||
static int GetMultiPlayer( T* p, lua_State *L ) { lua_pushnumber(L, p->m_MultiPlayer); return 1; }
|
||||
static int GetProfileID( T* p, lua_State *L ) { lua_pushstring(L, p->m_sProfileID ); return 1; }
|
||||
static int GetSong( T* p, lua_State *L ) { if(p->m_pSong==NULL) lua_pushnil(L); else p->m_pSong->PushSelf(L); return 1; }
|
||||
static int GetSong( T* p, lua_State *L ) { if(p->m_pSong==NULL) lua_pushnil(L); else p->m_pSong->PushSelf(L); return 1; }
|
||||
static int GetSongGroup( T* p, lua_State *L ) { lua_pushstring(L, p->m_sSongGroup ); return 1; }
|
||||
|
||||
LunaGameCommand()
|
||||
{
|
||||
ADD_METHOD( GetName );
|
||||
ADD_METHOD( GetText );
|
||||
ADD_METHOD( GetIndex );
|
||||
ADD_METHOD( GetHasFocus );
|
||||
ADD_METHOD( GetMultiPlayer );
|
||||
ADD_METHOD( GetProfileID );
|
||||
ADD_METHOD( GetSong );
|
||||
ADD_METHOD( GetSongGroup );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -52,7 +52,8 @@ public:
|
||||
RString m_sText; // display text
|
||||
bool m_bInvalid;
|
||||
RString m_sInvalidReason;
|
||||
int m_iIndex;
|
||||
int m_iIndex;
|
||||
bool m_bHasFocus;
|
||||
MultiPlayer m_MultiPlayer;
|
||||
const Style* m_pStyle;
|
||||
PlayMode m_pm;
|
||||
|
||||
@@ -147,7 +147,7 @@ MusicWheelItem::~MusicWheelItem()
|
||||
delete m_pGradeDisplay[p];
|
||||
}
|
||||
|
||||
void MusicWheelItem::LoadFromWheelItemData( const WheelItemBaseData *pWIBD )
|
||||
void MusicWheelItem::LoadFromWheelItemData( const WheelItemBaseData *pWIBD, int iIndex, bool bHasFocus )
|
||||
{
|
||||
const WheelItemData *pWID = dynamic_cast<const WheelItemData*>( pWIBD ); // XXX: ugly cast
|
||||
|
||||
@@ -272,6 +272,22 @@ void MusicWheelItem::LoadFromWheelItemData( const WheelItemBaseData *pWIBD )
|
||||
SetGrayBar( pBars[i] );
|
||||
break;
|
||||
}
|
||||
|
||||
GameCommand gc;
|
||||
gc.m_pSong = pWID->m_pSong;
|
||||
gc.m_sSongGroup = pWID->m_sText;
|
||||
gc.m_bHasFocus = true;
|
||||
gc.m_iIndex = iIndex;
|
||||
gc.m_bHasFocus = bHasFocus;
|
||||
|
||||
Lua *L = LUA->Get();
|
||||
gc.PushSelf( L );
|
||||
lua_setglobal( L, "ThisGameCommand" );
|
||||
LUA->Release( L );
|
||||
|
||||
this->PlayCommand( "Set" );
|
||||
|
||||
LUA->UnsetGlobal( "ThisGameCommand" );
|
||||
}
|
||||
|
||||
void MusicWheelItem::RefreshGrades()
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
virtual ~MusicWheelItem();
|
||||
virtual MusicWheelItem *Copy() const { return new MusicWheelItem(*this); }
|
||||
|
||||
virtual void LoadFromWheelItemData( const WheelItemBaseData* pWID );
|
||||
virtual void LoadFromWheelItemData( const WheelItemBaseData* pWID, int iIndex, bool bHasFocus );
|
||||
virtual void HandleMessage( const Message &msg );
|
||||
void RefreshGrades();
|
||||
|
||||
|
||||
@@ -151,10 +151,10 @@ bool RoomWheel::Select()
|
||||
return false;
|
||||
}
|
||||
|
||||
void RoomWheelItem::LoadFromWheelItemData( const WheelItemBaseData* pWID )
|
||||
void RoomWheelItem::LoadFromWheelItemData( const WheelItemBaseData* pWID, int iIndex, bool bHasFocus )
|
||||
{
|
||||
const RoomWheelData* tmpdata = (RoomWheelData*) pWID;
|
||||
WheelItemBase::LoadFromWheelItemData( pWID );
|
||||
WheelItemBase::LoadFromWheelItemData( pWID, iIndex, bHasFocus );
|
||||
m_Desc.SetText( tmpdata->m_sDesc );
|
||||
m_Desc.SetDiffuseColor( pWID->m_color );
|
||||
m_text.SetDiffuseColor( pWID->m_color );
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
RoomWheelItem( const RoomWheelItem &cpy );
|
||||
|
||||
void Load( RString sType );
|
||||
virtual void LoadFromWheelItemData( const WheelItemBaseData* pWID );
|
||||
virtual void LoadFromWheelItemData( const WheelItemBaseData* pWID, int iIndex, bool bHasFocus );
|
||||
virtual RoomWheelItem *Copy() const { return new RoomWheelItem(*this); }
|
||||
|
||||
private:
|
||||
|
||||
@@ -522,7 +522,15 @@ void WheelBase::RebuildWheelItems( int iDist )
|
||||
WheelItemBase *pDisplay = items[i];
|
||||
|
||||
pDisplay->SetExpanded( pData->m_Type == TYPE_SECTION && pData->m_sText == m_sExpandedSectionName );
|
||||
pDisplay->LoadFromWheelItemData( pData );
|
||||
}
|
||||
|
||||
for( int i=0; i<(int)items.size(); i++ )
|
||||
{
|
||||
int iIndex = iFirstVisibleIndex + i;
|
||||
wrap( iIndex, data.size() );
|
||||
const WheelItemBaseData *pData = data[iIndex];
|
||||
WheelItemBase *pDisplay = items[i];
|
||||
pDisplay->LoadFromWheelItemData( pData, iIndex, m_iSelection==iIndex );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ void WheelItemBase::Load( RString sType )
|
||||
this->AddChild( &m_text );
|
||||
}
|
||||
|
||||
void WheelItemBase::LoadFromWheelItemData( const WheelItemBaseData* pWID )
|
||||
void WheelItemBase::LoadFromWheelItemData( const WheelItemBaseData* pWID, int iIndex, bool bHasFocus )
|
||||
{
|
||||
ASSERT( pWID != NULL );
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
void DrawGrayBar( Actor& bar );
|
||||
void SetExpanded( bool bExpanded ) { m_bExpanded = bExpanded; }
|
||||
|
||||
virtual void LoadFromWheelItemData( const WheelItemBaseData* pWID );
|
||||
virtual void LoadFromWheelItemData( const WheelItemBaseData* pWID, int iIndex, bool bHasFocus );
|
||||
|
||||
RageColor m_colorLocked;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user