add Lua bindings for ControllerStateDisplay
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "InputMapper.h"
|
||||
#include "InputFilter.h"
|
||||
#include "RageLog.h"
|
||||
#include "LuaBinding.h"
|
||||
|
||||
static const char *ControllerStateButtonNames[] = {
|
||||
"Up",
|
||||
@@ -22,7 +23,15 @@ static const DeviceButton ControllerStateButtonToDeviceButton[] = {
|
||||
JOY_LEFT,
|
||||
JOY_RIGHT,
|
||||
};
|
||||
// TODO: Generalize for all game types
|
||||
static const GameButton ControllerStateButtonToGameButton[] = {
|
||||
DANCE_BUTTON_UP,
|
||||
DANCE_BUTTON_DOWN,
|
||||
DANCE_BUTTON_LEFT,
|
||||
DANCE_BUTTON_RIGHT,
|
||||
};
|
||||
|
||||
REGISTER_ACTOR_CLASS( ControllerStateDisplay )
|
||||
|
||||
ControllerStateDisplay::ControllerStateDisplay()
|
||||
{
|
||||
@@ -33,7 +42,7 @@ ControllerStateDisplay::ControllerStateDisplay()
|
||||
this->AddChild( &m_Buttons[b].spr );
|
||||
}
|
||||
|
||||
void ControllerStateDisplay::Load( MultiPlayer mp )
|
||||
void ControllerStateDisplay::LoadMultiPlayer( MultiPlayer mp )
|
||||
{
|
||||
m_bIsLoaded = true;
|
||||
|
||||
@@ -43,7 +52,7 @@ void ControllerStateDisplay::Load( MultiPlayer mp )
|
||||
{
|
||||
Button &button = m_Buttons[ b ];
|
||||
|
||||
LOG->Warn( "csd: %d %d", mp, b );
|
||||
//LOG->Warn( "csd: %d %d", mp, b );
|
||||
|
||||
RString sPath = THEME->GetPathG( "ControllerStateDisplay", ControllerStateButtonToString(b) );
|
||||
button.spr.Load( sPath );
|
||||
@@ -52,15 +61,58 @@ void ControllerStateDisplay::Load( MultiPlayer mp )
|
||||
}
|
||||
}
|
||||
|
||||
void ControllerStateDisplay::LoadGameController( GameController gc )
|
||||
{
|
||||
m_bIsLoaded = true;
|
||||
|
||||
m_sprFrame.Load( THEME->GetPathG("ControllerStateDisplay", "frame") );
|
||||
|
||||
FOREACH_ENUM2( ControllerStateButton, b )
|
||||
{
|
||||
Button &button = m_Buttons[ b ];
|
||||
|
||||
//LOG->Warn( "csd: %d %d", mp, b );
|
||||
|
||||
RString sPath = THEME->GetPathG( "ControllerStateDisplay", ControllerStateButtonToString(b) );
|
||||
button.spr.Load( sPath );
|
||||
|
||||
button.gi = GameInput( gc, ControllerStateButtonToGameButton[b] );
|
||||
}
|
||||
}
|
||||
|
||||
void ControllerStateDisplay::Update( float fDelta )
|
||||
{
|
||||
FOREACH_ENUM2( ControllerStateButton, b )
|
||||
{
|
||||
Button &button = m_Buttons[ b ];
|
||||
button.spr.SetVisible( INPUTFILTER->IsBeingPressed(button.di) );
|
||||
|
||||
bool bVisible = false;
|
||||
|
||||
if( button.gi.IsValid() )
|
||||
bVisible = INPUTMAPPER->IsButtonDown(button.gi);
|
||||
else if( button.di.IsValid() )
|
||||
bVisible = INPUTFILTER->IsBeingPressed(button.di);
|
||||
|
||||
button.spr.SetVisible( bVisible );
|
||||
}
|
||||
}
|
||||
|
||||
// lua start
|
||||
class LunaControllerStateDisplay: public Luna<ControllerStateDisplay>
|
||||
{
|
||||
public:
|
||||
LunaControllerStateDisplay() { LUA->Register( Register ); }
|
||||
|
||||
static int LoadGameController( T* p, lua_State *L ) { p->LoadGameController( (GameController)IArg(1) ); return 0; }
|
||||
|
||||
static void Register(lua_State *L)
|
||||
{
|
||||
ADD_METHOD( LoadGameController );
|
||||
Luna<T>::Register( L );
|
||||
}
|
||||
};
|
||||
|
||||
LUA_REGISTER_DERIVED_CLASS( ControllerStateDisplay, Actor )
|
||||
|
||||
/*
|
||||
* (c) 2001-2004 Chris Danford
|
||||
|
||||
Reference in New Issue
Block a user