Lua Marker functions (CLuaFunctionDefinitions)

This commit is contained in:
Dmitry Korolev 2014-10-14 19:46:45 +04:00
parent 5fded36cee
commit aeb86ab312
2 changed files with 226 additions and 12 deletions

View File

@ -4103,3 +4103,217 @@ bool CLuaFunctionDefinitions::SetVehiclePlateText( lua_State* pLuaVM, void* pUse
return false;
}
// Marker create/destroy functions
void* CLuaFunctionDefinitions::CreateMarker( lua_State* pLuaVM, float fX, float fY, float fZ, const char* szType, float fSize, unsigned char iRed, unsigned char iGreen, unsigned char iBlue, void* pVisibleTo )
{
CLuaArguments pLuaArguments;
pLuaArguments.PushNumber( fX );
pLuaArguments.PushNumber( fY );
pLuaArguments.PushNumber( fZ );
pLuaArguments.PushString( szType );
pLuaArguments.PushNumber( fSize );
pLuaArguments.PushNumber( iRed );
pLuaArguments.PushNumber( iGreen );
pLuaArguments.PushNumber( iBlue );
pLuaArguments.PushUserData( pVisibleTo );
if( pLuaArguments.Call( pLuaVM, "createMarker", 1 ) )
{
CLuaArgument pLuaArgument( pLuaVM, -1 );
return pLuaArgument.GetLightUserData();
}
return NULL;
}
// Marker get functions
unsigned int CLuaFunctionDefinitions::GetMarkerCount( lua_State* pLuaVM, void* pUserData )
{
CLuaArguments pLuaArguments;
pLuaArguments.PushUserData( pUserData );
if( pLuaArguments.Call( pLuaVM, "getMarkerCount", 1 ) )
{
CLuaArgument pLuaArgument( pLuaVM, -1 );
return static_cast< unsigned int >( pLuaArgument.GetNumber() );
}
return 0;
}
const char* CLuaFunctionDefinitions::GetMarkerType( lua_State* pLuaVM, void* pUserData )
{
CLuaArguments pLuaArguments;
pLuaArguments.PushUserData( pUserData );
if( pLuaArguments.Call( pLuaVM, "getMarkerType", 1 ) )
{
CLuaArgument pLuaArgument( pLuaVM, -1 );
return pLuaArgument.GetString();
}
return NULL;
}
float CLuaFunctionDefinitions::GetMarkerSize( lua_State* pLuaVM, void* pUserData )
{
CLuaArguments pLuaArguments;
pLuaArguments.PushUserData( pUserData );
if( pLuaArguments.Call( pLuaVM, "getMarkerSize", 1 ) )
{
CLuaArgument pLuaArgument( pLuaVM, -1 );
return static_cast< float >( pLuaArgument.GetNumber() );
}
return 0.0f;
}
bool CLuaFunctionDefinitions::GetMarkerColor( lua_State* pLuaVM, void* pUserData, unsigned char& ucRed, unsigned char& ucGreen, unsigned char& ucBlue )
{
CLuaArguments pLuaArguments;
pLuaArguments.PushUserData( pUserData );
if( pLuaArguments.Call( pLuaVM, "getMarkerColor", 1 ) )
{
ucRed = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -3 ) )->GetNumber() );
ucGreen = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -2 ) )->GetNumber() );
ucBlue = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -1 ) )->GetNumber() );
return true;
}
return false;
}
int CLuaFunctionDefinitions::GetMarkerTarget( lua_State* pLuaVM, void* pUserData, float& fX, float& fY, float& fZ )
{
CLuaArguments pLuaArguments;
pLuaArguments.PushUserData( pUserData );
if( pLuaArguments.Call( pLuaVM, "getMarkerTarget", 1 ) )
{
fX = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -3 ) )->GetNumber() );
fY = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -2 ) )->GetNumber() );
fZ = static_cast< unsigned char >( ( new CLuaArgument( pLuaVM, -1 ) )->GetNumber() );
return true;
}
return false;
}
const char* CLuaFunctionDefinitions::GetMarkerIcon( lua_State* pLuaVM, void* pUserData )
{
CLuaArguments pLuaArguments;
pLuaArguments.PushUserData( pUserData );
if( pLuaArguments.Call( pLuaVM, "getMarkerIcon", 1 ) )
{
CLuaArgument pLuaArgument( pLuaVM, -1 );
return pLuaArgument.GetString();
}
return 0;
}
// Marker set functions
bool CLuaFunctionDefinitions::SetMarkerType( lua_State* pLuaVM, void* pUserData, const char* szType )
{
CLuaArguments pLuaArguments;
pLuaArguments.PushUserData( pUserData );
pLuaArguments.PushString( szType );
if( pLuaArguments.Call( pLuaVM, "setMarkerType", 1 ) )
{
CLuaArgument pLuaArgument( pLuaVM, -1 );
return pLuaArgument.GetBoolean();
}
return false;
}
bool CLuaFunctionDefinitions::SetMarkerSize( lua_State* pLuaVM, void* pUserData, float fSize )
{
CLuaArguments pLuaArguments;
pLuaArguments.PushUserData( pUserData );
pLuaArguments.PushNumber( fSize );
if( pLuaArguments.Call( pLuaVM, "setMarkerSize", 1 ) )
{
CLuaArgument pLuaArgument( pLuaVM, -1 );
return pLuaArgument.GetBoolean();
}
return false;
}
bool CLuaFunctionDefinitions::SetMarkerColor( lua_State* pLuaVM, void* pUserData, unsigned char ucRed, unsigned char ucGreen, unsigned char ucBlue )
{
CLuaArguments pLuaArguments;
pLuaArguments.PushUserData( pUserData );
pLuaArguments.PushNumber( ucRed );
pLuaArguments.PushNumber( ucGreen );
pLuaArguments.PushNumber( ucBlue );
if( pLuaArguments.Call( pLuaVM, "setMarkerColor", 1 ) )
{
CLuaArgument pLuaArgument( pLuaVM, -1 );
return pLuaArgument.GetBoolean();
}
return false;
}
bool CLuaFunctionDefinitions::SetMarkerTarget( lua_State* pLuaVM, void* pUserData, void* pTarget )
{
CLuaArguments pLuaArguments;
pLuaArguments.PushUserData( pUserData );
pLuaArguments.PushUserData( pTarget );
if( pLuaArguments.Call( pLuaVM, "setMarkerTarget", 1 ) )
{
CLuaArgument pLuaArgument( pLuaVM, -1 );
return pLuaArgument.GetBoolean();
}
return false;
}
bool CLuaFunctionDefinitions::SetMarkerIcon( lua_State* pLuaVM, void* pUserData, const char* szIcon )
{
CLuaArguments pLuaArguments;
pLuaArguments.PushUserData( pUserData );
pLuaArguments.PushString( szIcon );
if( pLuaArguments.Call( pLuaVM, "setMarkerIcon", 1 ) )
{
CLuaArgument pLuaArgument( pLuaVM, -1 );
return pLuaArgument.GetBoolean();
}
return false;
}

View File

@ -310,22 +310,22 @@ public:
static bool SetVehiclePlateText ( lua_State* pLuaVM, void* pUserData, const char* szName );
// Marker create/destroy functions
// static int CreateMarker ( lua_State* luaVM );
static void* CreateMarker ( lua_State* pLuaVM, float fX, float fY, float fZ, const char* szType, float fSize, unsigned char iRed, unsigned char iGreen, unsigned char iBlue, void* pVisibleTo );
// Marker get functions
// static int GetMarkerCount ( lua_State* luaVM );
// static int GetMarkerType ( lua_State* luaVM );
// static int GetMarkerSize ( lua_State* luaVM );
// static int GetMarkerColor ( lua_State* luaVM );
// static int GetMarkerTarget ( lua_State* luaVM );
// static int GetMarkerIcon ( lua_State* luaVM );
static unsigned int GetMarkerCount ( lua_State* pLuaVM, void* pUserData );
static const char* GetMarkerType ( lua_State* pLuaVM, void* pUserData );
static float GetMarkerSize ( lua_State* pLuaVM, void* pUserData );
static bool GetMarkerColor ( lua_State* pLuaVM, void* pUserData, unsigned char& ucRed, unsigned char& ucGreen, unsigned char& ucBlue );
static int GetMarkerTarget ( lua_State* pLuaVM, void* pUserData, float& fX, float& fY, float& fZ );
static const char* GetMarkerIcon ( lua_State* pLuaVM, void* pUserData );
// Marker set functions
// static int SetMarkerType ( lua_State* luaVM );
// static int SetMarkerSize ( lua_State* luaVM );
// static int SetMarkerColor ( lua_State* luaVM );
// static int SetMarkerTarget ( lua_State* luaVM );
// static int SetMarkerIcon ( lua_State* luaVM );
static bool SetMarkerType ( lua_State* pLuaVM, void* pUserData, const char* szType );
static bool SetMarkerSize ( lua_State* pLuaVM, void* pUserData, float fSize );
static bool SetMarkerColor ( lua_State* pLuaVM, void* pUserData, unsigned char ucRed, unsigned char ucGreen, unsigned char ucBlue );
static bool SetMarkerTarget ( lua_State* pLuaVM, void* pUserData, void* pTarget );
static bool SetMarkerIcon ( lua_State* pLuaVM, void* pUserData, const char* szIcon );
// Blip create/destroy functions
// static int CreateBlip ( lua_State* luaVM );