/*****************************************************************************
 * $LastChangedDate: 2011-03-15 14:18:37 -0400 (Tue, 15 Mar 2011) $
 * @file
 * @author  Jim E. Brooks  http://www.palomino3d.org
 * @brief   Interface of C functions for Lua scripts.
 * @remarks @remarks module.txt documents how to export new C++ classes to Lua.
 *
 * ----------------------------
 * -- THIS IS AUTO-GENERATED --
 * ----------------------------
 *
 *//*
 * LEGAL:   COPYRIGHT (C) 2008 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
 *****************************************************************************/

#include "base/module.hh"
using namespace base;
#include "object/module.hh"
using namespace object;
#include "game/module.hh"
#include "game/hud.hh"
using namespace game;
#include "lua_bind/module.hh"
#include "lua_bind/bind.hh"

namespace lua {


namespace bind {

#define BIND_CLASS_NAME      "GameHud"
#define BIND_METATABLE_NAME  LUABIND_METATABLE_STRING(BIND_CLASS_NAME)

//==============================================================================
// C functions called by Lua that access C++ objects.
//==============================================================================

/*****************************************************************************
 * GameHud:AttachTarget(object,text)
 *****************************************************************************/
INTERN int 
GameHud_AttachTarget( lua_State* L ) 
{ 
   try { 

        const string text = POP_STRING( L );
        shptr<Object> object = POP_USERDATA_AS_SHPTR<Object>( L );
        CHECK_TYPESIG(object,TYPESIG_OBJECT);
        GET_GAME_HUD().AttachTarget( object, text );
    
   } CATCH_LUA_EXCEPTION 
   return 0; 
} 

/*****************************************************************************
 * GameHud:DeselectTarget()
 *****************************************************************************/
INTERN int 
GameHud_DeselectTarget( lua_State* L ) 
{ 
   try { 

        GET_GAME_HUD().RemoveRadarLock();
    
   } CATCH_LUA_EXCEPTION 
   return 0; 
} 

/*****************************************************************************
 * GameHud:DetachTarget(object)
 *****************************************************************************/
INTERN int 
GameHud_DetachTarget( lua_State* L ) 
{ 
   try { 

        shptr<Object> object = POP_USERDATA_AS_SHPTR<Object>( L );
        CHECK_TYPESIG(object,TYPESIG_OBJECT);
        GET_GAME_HUD().DetachTarget( object );
    
   } CATCH_LUA_EXCEPTION 
   return 0; 
} 

/*****************************************************************************
 * GameHud:RemoveRadarLock()
 *****************************************************************************/
INTERN int 
GameHud_RemoveRadarLock( lua_State* L ) 
{ 
   try { 

        GET_GAME_HUD().RemoveRadarLock();
    
   } CATCH_LUA_EXCEPTION 
   return 0; 
} 

/*****************************************************************************
 * GameHud:SelectTarget(object,radarLock)
 *****************************************************************************/
INTERN int 
GameHud_SelectTarget( lua_State* L ) 
{ 
   try { 

        const bool radarLock = POP_BOOL( L );
        shptr<Object> object = POP_USERDATA_AS_SHPTR<Object>( L );
        CHECK_TYPESIG(object,TYPESIG_OBJECT);
        GET_GAME_HUD().SelectTarget( object, radarLock );
    
   } CATCH_LUA_EXCEPTION 
   return 0; 
} 

//==============================================================================
// Register binding with Lua. 
//==============================================================================

#if ! DOXYGEN 

INTERN const struct luaL_reg sMethodTable[] =
{
  // New(),__gc() omitted as Lua cannot instantiate this C++ class.
  { "AttachTarget", GameHud_AttachTarget },
  { "DeselectTarget", GameHud_DeselectTarget },
  { "DetachTarget", GameHud_DetachTarget },
  { "RemoveRadarLock", GameHud_RemoveRadarLock },
  { "SelectTarget", GameHud_SelectTarget },
  { NULL, NULL }
};

void
RegisterGameHud( lua_State* L )
{
    REGISTER_BINDING( L,
                      BIND_METATABLE_NAME,
                      BIND_CLASS_NAME,
                      sMethodTable );
}

#endif // ! DOXYGEN 

} // namespace bind 

} // namespace lua 
