//
// Tools_HierarchyNode_Object.h
//
// Created by KJFL - 15 October 2008
//
// Copyright (C) 2008 Rebellion, All Rights Reserved.
//

#ifdef ASURA_USE_PRAGMA_ONCE
    #pragma once
#endif

#ifndef _TOOLS_HIERARCHYNODE_OBJECT_H_
#define _TOOLS_HIERARCHYNODE_OBJECT_H_

#include "Objects/Tools_Object.h"
#include "Objects/Tools_Object_System.h"

class Asura_Hierarchy_Skin;
class Asura_Physics_Ragdoll_Desc_HierarchyNode;
class Asura_StringDisplay_Dialog;

class Tools_HierarchyNode_Object : public Tools_Object
{
	public :

		Tools_HierarchyNode_Object( Asura_Hierarchy_Skin* pxSkin, int iBoneIndex, Asura_Physics_Ragdoll_Desc_HierarchyNode* pxHierarchyNode );

		const char* GetName();
		const char* GetTypeDescription(){return "HierarchyNode";}
		int GetBoneIndex() { return m_iBoneIndex; }

		virtual bool IsSelectable();
		virtual void OnSelection();
		virtual void OnDeselection();
		virtual void OnGroupDeselection();

		virtual void Render();
		virtual void PrintInfo( float& x,float& y );
		virtual bool CanBeDestroyed(){return false;}
		virtual bool CanBeMoved(){return false;}

		void UpdatePosition(const Asura_Vector_3& xPos,const Asura_Matrix_3x3& xMat);
		virtual bool ObjectIsInLOS(const Asura_Vector_3& xAlpha, const Asura_Vector_3& xBeta, float& fLowest);

		virtual bool IsDraggable() const;

		void CreatePropertiesOverlay( void );
		void DeletePropertiesOverlay( void );

		void UpdateDialogLabels( void );

		static void ChooseCollisionObject( void );
		static void ClearCollisionObject( void );
		void SetCollisionObject( u_int uCollisionObjectIndex );

		int GetParentBoneIndex( void ) const { return m_iParentBoneIndex; }

		Asura_Physics_Ragdoll_Desc_HierarchyNode* GetRagdollHierarchyNode( void ) const { return m_pxHierarchyNode; }

	private :
	
		Asura_Hierarchy_Skin*						m_pxSkin;
		int											m_iBoneIndex;

		Asura_Physics_Ragdoll_Desc_HierarchyNode*	m_pxHierarchyNode;

		int											m_iParentBoneIndex;
		u_int										m_uDefaultCollisionObject;
		
		Asura_StringDisplay_Dialog* 				m_pxColDialog;
		Asura_StringDisplay_Dialog* 				m_pxColDialog2;

		static Asura_Vector_2						s_xPropertiesOverlayPosition;
		static Tools_HierarchyNode_Object*			s_pxCurrentlyEditedObject;
};


class Tools_NodeChooseCollisionObject : public Tools_ChooseObject
{
	public :
		Tools_NodeChooseCollisionObject ( Tools_HierarchyNode_Object* pxNode )
		: m_pxNode( pxNode )
		{}

		virtual bool CanBeSelected( Tools_Object* pxObject );
		virtual void ObjectSelected( Tools_Object* pxObject );
		virtual void OnFinish() { delete this; }

	private:
		Tools_HierarchyNode_Object*	m_pxNode;
};


#endif //_TOOLS_HIERARCHYNODE_OBJECT_H_
