//
// Tools_Entity_ProxyTrigger_Object.h
//
// Created by Richard Rice - 21/09/2006
// 
// Copyright (C) 2006 Rebellion, All Rights Reserved.
//

#ifdef ASURA_USE_PRAGMA_ONCE
    #pragma once
#endif

#ifndef __TOOLS_ENTITY_PROXYTRIGGER_OBJECT_H__
#define __TOOLS_ENTITY_PROXYTRIGGER_OBJECT_H__

#include "Entity/Tools_Entity_Object.h"

class Tools_Entity_ProxyTrigger_Object : public Tools_Entity_Object
{
		friend class Tools_ChooseObject_ProxyTriggerAddTarget;

	public :
		Tools_Entity_ProxyTrigger_Object(Asura_Entity* pxEntity);
		~Tools_Entity_ProxyTrigger_Object();

		virtual const char* GetMyNamePrefix() const { return Tools_Entity_ProxyTrigger_Object::GetNamePrefix(); }

		static void Create();

		static void AddMessageOverlayControls(struct Asura_StaticMessage* pxMessage,class Asura_Overlay* pxOverlay,class Asura_Vector_2& xOffset);

		static const char* GetNamePrefix() { return "PxT_"; }

	protected :
		//virtual function overides
		const char* GetTypeDescriptionForObjectType(){return "Proxy Trigger";}
		const char* GetTypeDescription(){return m_xTypeDescription.GetString();	}
		
		void AddOverlayControls(class Asura_Overlay* pxOverlay,class Asura_Vector_2& xOffset);
		bool HandlesThisMessage(int iMessageID);
		void ReferencedObjectIsBeingDeleted(Tools_Object* pxObject);


		virtual void Copy(const Tools_Object*);
		virtual bool CanBeCopied() const {return Type == TOT_Entity_ProxyTrigger;}
		virtual Tools_Object* CreateObjectOfThisType() const;

		virtual void AddContextMenuItems(class Tools_ContextMenu& xMenu, const class Tools_ContextMenu_Context& xContext);

	private :
		static Tools_Entity_ProxyTrigger_Object* Create(bool bGenerateName,int iTargetClass);
		static void EditProxyMessageTarget(int iMessage);

		void FindTargetObject(bool bIgnoreFrameStamp = false);

		void BuildListStrings();
		void DeleteListStrings();
		void UpdateList();

		void GetTargetList(List<Tools_Object*>& xOutputList) const;

		void SelectTargets(bool bAddToSelection) const;
		void DeselectTargets() const;

		//overlay callback functions
		//defines for routeing static callback functions to non-static versions
		#define OVERLAY_VOID_CALLBACK(__FnName)\
		static void __FnName(int iThis){((Tools_Entity_ProxyTrigger_Object*)iThis)->__FnName();}\
		void __FnName();

		#define OVERLAY_BOOL_CALLBACK(__FnName)\
		static bool __FnName(int iThis){return ((Tools_Entity_ProxyTrigger_Object*)iThis)->__FnName();}\
		bool __FnName();

		OVERLAY_VOID_CALLBACK(AddTarget)
		OVERLAY_VOID_CALLBACK(AddTargetHideExisting)
		OVERLAY_VOID_CALLBACK(EditTargets)
		OVERLAY_VOID_CALLBACK(RemoveTarget)
		OVERLAY_BOOL_CALLBACK(CanRemoveTarget)

		OVERLAY_VOID_CALLBACK(SelectTargets)

		#undef OVERLAY_VOID_CALLBACK
		#undef OVERLAY_BOOL_CALLBACK

		void AddTarget_TargetChosen(const List<Tools_Object*>* pxObjectList, bool bAlterExistingTargets);
		bool IsInTargetList(Asura_Guid uGuid) const;

		static void ContextMenu_DeselectProxyTargets(void* pObject);
		static void ContextMenu_SelectProxyTargets_Add(void* pObject);
		static void ContextMenu_SelectProxyTargets_Replace(void* pObject);


		
		//A target tools object of the class that this entity is a proxy for
		Tools_Entity_Object* m_pxTargetObject;
		u_int m_uFindTargetFrameStamp;

		int m_iListSelection;
		int m_iListSize;
		char** m_pszListStrings;
		class Asura_List_Dialog* m_pxListDialog;

		Asura_String m_xTypeDescription;
};




#endif //__TOOLS_ENTITY_PROXYTRIGGER_OBJECT_H__