add Lua method

This commit is contained in:
Chris Danford
2005-06-04 01:56:03 +00:00
parent 4bce1df7fe
commit b4eda6dddf
2 changed files with 46 additions and 1 deletions
+40
View File
@@ -52,6 +52,46 @@ void RageInput::AddHandler( InputHandler *pHandler )
m_pDevices.push_back( pHandler );
}
// lua start
#include "LuaBinding.h"
template<class T>
class LunaRageInput : public Luna<T>
{
public:
LunaRageInput() { LUA->Register( Register ); }
static int GetDescriptions( T* p, lua_State *L )
{
vector<InputDevice> vDevices;
vector<CString> vsDescriptions;
p->GetDevicesAndDescriptions( vDevices, vsDescriptions );
LuaHelpers::CreateTableFromArray( vsDescriptions, L );
return 1;
}
static void Register(lua_State *L)
{
ADD_METHOD( GetDescriptions )
Luna<T>::Register( L );
// Add global singleton if constructed already. If it's not constructed yet,
// then we'll register it later when we reinit Lua just before
// initializing the display.
if( INPUTMAN )
{
lua_pushstring(L, "INPUTMAN");
INPUTMAN->PushSelf( LUA->L );
lua_settable(L, LUA_GLOBALSINDEX);
}
}
};
LUA_REGISTER_CLASS( RageInput )
// lua end
/*
* Copyright (c) 2001-2004 Chris Danford, Glenn Maynard
* All rights reserved.