//**************************************
// This is the base class of your DLL interface
// All methods of CPA_ObjectDLLBase are
// present in that class.
//**************************************
#ifndef __ACTOR_INTERF_HPP__
#define __ACTOR_INTERF_HPP__

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

#include "ACP_Base.h"
#include "ITF.h"
#include "IncMEC.h"
#define D_ZdxStuff_StructureDefine
#define D_State_Define
#include "IncGAM.h"
#undef D_State_Define
#include "GLI.h"

// if you want only one instance of your DLL
// activate the next line
//#define DLL_ONLY_ONE_INSTANCE

////////////////////////////////////////////////
// EdCarac specific	 //YB

// Specific Includes
#include "Defines.hpp"

#include "EDACFmMn.hpp"
#include "EDACDoc.hpp"

//End EdCarac specific
////////////////////////////////////////////////

struct stIndexOfNameInfo
{
	CString		csNameOfObject;
	CPA_Actor	*pclModel;
	CString		csObjectType;
};

//----------------------------------------------------------
// Object DLL interface class
//----------------------------------------------------------
class CPA_Actor_Editor_Interface : public CPA_ObjectDLLBase
{
private:
	CPA_List<CPA_SuperObject> m_stListModels;
	CPA_KeyActionConfiguration	* m_p_oKeyboard;

public:

	CPA_Actor_Editor_Interface(void);
	~CPA_Actor_Editor_Interface(void);

/*===========================================================================
	Virtual Functions
=========================================================================*/
public:

	// To pre translate all messages
//	virtual BOOL fn_bPreTranslateMessage(MSG * /*p_stMsg*/) { return FALSE; };
	// Called just after editor has been inserted in list of all editors
	virtual void fn_vJustAfterRegistered(void);
	// Called just before windows main loop processing
	virtual void fn_vConstruct(void);
	// Called to refresh datas of DLL if "fn_vCanBeRefresh" returns TRUE
	virtual void fn_vRefreshDatas(void);
	//
	virtual void fn_vLevelChanges(void);
	// Called when level has changed
	virtual void fn_vLevelHasChanged(void);

	virtual BOOL fn_bLoadBaseObject(CPA_BaseObject *p_oObject);

/*===========================================================================
	Current Editor
=========================================================================*/

	virtual tdePermission fn_eAcceptNewEditor(CPA_EditorBase *pNewEditor);

	virtual BOOL fn_bCanActivateEditor(CPA_List<CPA_SaveObject> *pParams);
	virtual void fn_vOnActivateEditor	(CPA_List<CPA_BaseObject> *pParams, BOOL bBackActivated=FALSE);

	virtual BOOL fn_bCanCloseEditor(void);
	virtual void fn_vOnCloseEditor(void);

public:
/*===========================================================================
	Messages from Evt_Editor
=========================================================================*/

// for changes
//	virtual void fn_vOnChangeDevice (void) { }

// Editor Modifs
	virtual void fn_vOnModifDelete(CPA_List<EDT_SaveParents> *pListObjects, tdeTypeModif eType, tdeStatus eStatus);
//	virtual void fn_vOnModifParent(CPA_List<EDT_SaveParents> *pListObjects, tdeTypeModif eType, tdeStatus eStatus) { }
//	virtual void fn_vOnModifCopy(CPA_List<EDT_SaveParents> *pListObjects, tdeTypeModif eType, tdeStatus eStatus) { }
	virtual void fn_vOnModifName(CPA_SuperObject *pEdObj, CString csInitialName, CString csFinalName, tdeTypeModif eType, tdeStatus eStatus);
	virtual void fn_vOnSelect(CPA_SuperObject *pEdObj, tdeTypeModif eType, tdeStatus eStatus);

//ANNECY Shaitan SPOFlags 19/02/98
	virtual void fn_vOnModifFlag (CPA_SuperObject *pEdObj, unsigned long ulOldFlag, unsigned long ulNewFlag);
//ENDANNECY Shaitan SPOFlags
//ANNECY Shaitan Transparency (26/03/98) {
	virtual void fn_vOnModifTransparency (CPA_SuperObject *pEdObj, float fNewLevel);
//ENDANNECY Shaitan Transparency }

	virtual void fn_vOnModifInsert(	CPA_SuperObject *pEdObj, CPA_SuperObject *pParent,
																	tdstPosition *p_stPosition, tdeTypeModif eType, tdeStatus eStatus);

// Moves
	virtual void fn_vOnModifMove(CPA_List<EDT_SavePos> *pListObjects, CPA_List<EDT_SaveGlobalPos> *pListConcerned, tdeTypeModif eType, tdeStatus eStatus);
//	virtual void fn_vOnBeginMove(CPA_List<CPA_SuperObject> *pListObjects, CPA_List<CPA_SuperObject> *pListConcerned, tdeStatus eStatus) { }
//	virtual void fn_vOnMoving(CPA_List<CPA_SuperObject> *pListObjects, CPA_List<CPA_SuperObject> *pListConcerned, tdeStatus eStatus) { }

// Models
	virtual void fn_vOnAddModelToList(CPA_ObjectDLLBase *pOwnerDLL, CString csListName, CString csModelName, tdeTypeModif eType);
	virtual BOOL fn_bCanDeleteThisModel	(CString csListName, CString csModelType, CString csModelName);

// permission
	virtual BOOL fn_bAcceptModifDelete(CPA_List<CPA_SuperObject> *pListObjects, tdeStatus eStatus);
//	virtual BOOL fn_bAcceptModifParent(CPA_List<CPA_SuperObject> *pListObjects, tdeStatus eStatus)  { return TRUE; }
	virtual BOOL fn_bAcceptModifCopy(CPA_List<CPA_SuperObject> *pListObjects, tdeStatus eStatus);
	virtual BOOL fn_bAcceptModifTranslate(CPA_List<CPA_SuperObject> *pListObjects, tdeStatus eStatus);
	virtual BOOL fn_bAcceptModifRotate(CPA_List<CPA_SuperObject> *pListObjects, tdeStatus eStatus);
	virtual BOOL fn_bAcceptModifScale(CPA_SuperObject *pEdObj, tdeStatus eStatus);
//	virtual BOOL fn_bAcceptModifInsert(CPA_SuperObject *pEdObj, CPA_SuperObject *pParent, tdeStatus eStatus) { return TRUE; }
	virtual BOOL fn_bAcceptModifName(CPA_SuperObject *pEdObj, tdeStatus eStatus);
//	virtual BOOL fn_bAcceptMultiSelect(void)	{ return TRUE; }

//ANNECY Shaitan SPOFlags 19/02/98
	virtual BOOL fn_bAcceptModifFlag (CPA_SuperObject *pEdObj, unsigned long ulFlag);
//ENDANNECY Shaitan SPOFlags

// Begin Silviu Simen 18 August 1998 Cut/Paste Mechanism
	virtual BOOL fn_bAcceptModifCut		(CPA_List<CPA_SuperObject> *pListObjects, tdeStatus eStatus);
// End Silviu Simen 18 August 1998 Cut/Paste Mechanism
// Begin Silviu Simen List by Sector and type
	void fn_AddDialogBySector (void);
// Begin Silviu Simen List by Sector and type

// to precise selection
	virtual tdeTypeAnswer fn_bAcceptSelect(CPA_SuperObject *pEdObj, ACP_tdxIndex xIndex, HIE_tdstPickInfo *pPicking, tdeStatus eStatus);

/*===========================================================================
	Dialog List
=========================================================================*/

//	virtual BOOL fn_bSetCustomTest		(CPA_DialogList *pDialog) { return FALSE; }
//	virtual BOOL fn_bCustomTestFunction (CString csCurrentType, CString csTestName, CPA_SaveObject *pEdObj) { return TRUE; }

/*===========================================================================
	General Purpose
=========================================================================*/

	virtual long OnQueryAction	(CPA_EditorBase * /*p_oSender*/, WPARAM, LPARAM);
//	virtual long OnQueryInfos	(CPA_DLLBase * /*p_oSender*/, WPARAM, LPARAM) { return 0; };
//	virtual long OnQueryOpen	(CPA_DLLBase * /*p_oSender*/, WPARAM, LPARAM) { return 0; };
//	virtual long OnQueryClose	(CPA_DLLBase * /*p_oSender*/, WPARAM, LPARAM) { return 0; };

/*===========================================================================
	Coherence
=========================================================================*/
	virtual BOOL fn_bOnInvalidateLink	(CPA_BaseObject *pOwner, CPA_BaseObject *pReferencedObject, BOOL bDestroyed);
	virtual void fn_vOnRestoreLink		(CPA_BaseObject *pOwner, CPA_BaseObject *pReferencedObject);
  virtual void fn_vOnModifyChild    (CPA_BaseObject *pOwner, CPA_BaseObject *pReferencedObject, unsigned long _ulData);

/*===========================================================================
	Messages
=========================================================================*/
// focus
	virtual void fn_vHasLostFocus	(void);
	virtual BOOL fn_bHasGainedFocus	(void);
// engine - editor
	virtual void fn_vBeforeEngine (void);
	virtual void fn_vBeforeEditor (void);
// engine
	virtual BOOL fn_bAcceptToRunEngine(void);
//	virtual BOOL fn_bAcceptToRunTimerEngine	(void) { return TRUE; };
// end appli
//	virtual void fn_vJustBeforeClosing	(void) { };
//	virtual BOOL fn_bAcceptToExit		(void) { return TRUE; };
// save
	virtual void fn_vBeforeSaveAll(void);
	virtual void fn_vAfterSaveAll(void);
  virtual BOOL fn_bAcceptToSave(void);

// keys
	virtual BOOL _OnKeyDown (UINT nChar, UINT nRepCnt, UINT nFlags);
//	virtual BOOL _OnKeyUp	(UINT nChar, UINT nRepCnt, UINT nFlags)	{ return FALSE; };
// mouse
//	virtual BOOL _OnMouseMove	  (UINT nFlags, tdstMousePos *p_stPos, MTH3D_tdstVector *p_stVect)	{ return FALSE; };
//	virtual BOOL _OnLButtonDblClk (UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *p_stPickInfo)	{ return FALSE; };
//	virtual BOOL _OnRButtonDblClk (UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *p_stPickInfo)	{ return FALSE; };
//	virtual BOOL _OnLButtonDown	  (UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *p_stPickInfo)	{ return FALSE; };
//	virtual BOOL _OnRButtonDown	  (UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *p_stPickInfo)	{ return FALSE; };
//	virtual BOOL _OnLButtonUp	  (UINT nFlags, tdstMousePos *p_stPos)	{ return FALSE; };
//	virtual BOOL _OnRButtonUp	  (UINT nFlags, tdstMousePos *p_stPos)	{ return FALSE; };
// command
//	virtual BOOL _OnCommand			(UINT IDCmdMsg)				{ return FALSE; };
//	virtual BOOL _OnUpdateCommandUI	(UINT uiID, CCmdUI *pCmdUI)	{ return FALSE; };
// dragdrop
//	virtual BOOL _OnDragDropEnd			(WPARAM wParam, LPARAM lParam)	{ return FALSE; };
//	virtual BOOL _OnDragDropMove		(WPARAM wParam, LPARAM lParam)	{ return FALSE; };
//	virtual BOOL _OnDragDropLooseFocus	(WPARAM wParam, LPARAM lParam)	{ return FALSE; };
//	virtual BOOL _OnDragDropGainFocus	(WPARAM wParam, LPARAM lParam)	{ return FALSE; };
// add objects to draw
//	virtual void fn_vAddObjectsToDraw	(GLD_tdstViewportAttributes *p1, GLI_tdxHandleToLight p2)	{ };
//	virtual void fn_vAddObjectsToDraw2	(GLD_tdstViewportAttributes *p1, GLI_tdxHandleToLight p2)	{ };

/*===========================================================================
	Reinit
=========================================================================*/

//	virtual void fn_vOnChangeRoot	(void)	{ };
//	virtual void fn_vOnChangeWorld	(void)	{ };

/*===========================================================================
	for Dialog List
=========================================================================*/

	//List control
	virtual CPA_BaseObject  * GetDialogSelection (CPA_DialogList *pDialog, CString csTypeName, tdeListDrawMode eDrawMode);
	virtual void GetListsForDialog (CPA_DialogList *pDialog);

	virtual BOOL fn_bOnSelChangeListObjects(CPA_DialogList *pDialog, CString csTypeName, CPA_BaseObject *pSelectedObject, BOOL bUnselect);
	virtual BOOL fn_bOnDblClkListObjects(CPA_DialogList *pDialog, CString csTypeName, CPA_BaseObject *pSelectedObject);
	virtual BOOL fn_bOnSelChangeComboList(CPA_DialogList *pDialog, CString csTypeName);
	virtual BOOL fn_bOnButtonTest(CPA_DialogList *pDialog, CString csTypeName, tdeListDrawMode eDraw);

	virtual BOOL fn_bOnKeyDownInDialog	(CPA_DialogList *pDialog, CString csListName, tdeListDrawMode eDraw,
										 CPA_BaseObject *pSelectedObject, UINT nChar, UINT nRepCnt, UINT nFlags);

	virtual void fn_vInitDefaultParameters(CPA_DialogList *pDialog);

	virtual void fn_vSetANewTest(CPA_DialogList *pDialog, CString csCurrentList);
	virtual BOOL fn_bTestFunction(CString csCurrentType, CString csTestName, CPA_BaseObject *pEdObj);

	//Tree control
	virtual BOOL fn_bOnSelChangeHierarchyTree(CPA_DialogList *pDialog, CString csListName, CPA_BaseObject *pSelectedObject, CPA_BaseObject *pSelectedParent);
	virtual BOOL fn_bOnDblClkHierarchyTree(CPA_DialogList *pDialog, CString csListName, CPA_BaseObject *pSelectedObject, CPA_BaseObject *pSelectedParent);

	virtual BOOL fn_bCanDragItemInHierarchyTree(CPA_DialogList *pDialog, CString csListName, CPA_BaseObject *pObjectToDrag);
	virtual BOOL fn_bCanDropItemInHierarchyTree(CPA_DialogList *pDialog, CString csListName, CPA_BaseObject *pObjectToDrop, CPA_BaseObject *pTarget);
	virtual BOOL fn_bOnDragDropInHierarchyTree(CPA_DialogList *pDialog, CString csListName, CPA_BaseObject *pObject, CPA_BaseObject *pTarget);

	virtual CPA_BaseObject *GetTreeNodeNextChild(CPA_DialogList *pDialog, CString csListName, CPA_BaseObject *pParent, CPA_BaseObject *pCurrentChild);
	virtual void *GetInfoForTreeItem(CPA_DialogList *pDialog, CString csListName, CPA_BaseObject *pObject, CPA_BaseObject *pParent);
	virtual int GetIconForTreeItem(CPA_DialogList *pDialog, CString csListName, CPA_BaseObject *pObject);
	virtual int GetStateForTreeItem(CPA_DialogList *pDialog, CString csListName, CPA_BaseObject *pObject);
	
	virtual BOOL fn_bAddEntriesToTreePopup(CPA_DialogList *pDialog, CString csListName, CMenu *pMenu, UINT uiCustomEntriesStart);
	virtual void fn_vOnCommandInTreePopup(CPA_DialogList *pDialog, CString csListName, UINT uiCustomEntry);
	virtual BOOL fn_bAddEntriesToListPopup(CPA_DialogList *pDialog, CString csListName, CMenu *pMenu, UINT uiCustomEntriesStart);
	virtual void fn_vOnCommandInListPopup(CPA_DialogList *pDialog, CString csListName, UINT uiCustomEntry);

/*===========================================================================
	Dialog Bar - Mircea Dunka 31 Aug. 1998
=========================================================================*/
	void fn_vDefineDlgBarBtnIcon (tde_DlgBarCategory wCategory, tds_DlgBarBtn *_pDlgBarBtn);

/*===========================================================================
	SubMenus and PopupMenu
=========================================================================*/

	virtual BOOL fn_bDefineSubMenu(EDT_SubMenu *_p_oEDTSubMenu);
	virtual void _OnSubMenuCommand(EDT_SubMenu *_p_oEDTSubMenu,UINT uiMsgID);

	virtual BOOL fn_bDefinePopupMenu(EDT_PopUpMenu *pPopup, CPA_List<CPA_SuperObject> *pSelection, BOOL bAsCurrentEditor);
	virtual void _OnPopUpMenuCommand(UINT m_IDCmdMsg);

// Hierarchy
	virtual CPA_SuperObject *GetNewEditorInstance(HIE_tdxHandleToSuperObject pEngineInstance);
	virtual void fn_vUpdateEditorInstance(CPA_SuperObject *pEditorInstance, HIE_tdxHandleToSuperObject pEngineInstance);
	virtual BOOL fn_bCanHandleThisType(long lEngineType);

// Models & Instances
	virtual void fn_vInitListByType(CPA_World *pWorld);
	virtual void fn_vInitListsOfModels(void);
	virtual void fn_vSaveListModels(CString csListName, CPA_List<EDT_Model> *pListModels);
	virtual CString	fn_csLoadListModels(void);
	virtual EDT_Model *GetNewModel(CString csListName);
	virtual BOOL fn_bCanLoadNewModel(CString csListName);
	virtual BOOL fn_bCanDeleteModel(CString csListName);
	virtual BOOL fn_bCanChangeModelIcon(CString csListName);
	virtual BOOL fn_bCanSaveListModels(CString csListName);
	virtual BOOL fn_bCanLoadListModels(void);
//	virtual void fn_vOnLoadNewModel(CString csListName, EDT_Model *pNewModel);
	virtual CString	fn_csChangeModelIcon (CString csListName, CString csModelName);

	virtual CPA_SuperObject *GetNewInstance(CString csTypeName, CString csModelName, CPA_SuperObject *pParent);
	virtual tdeTypeSO		 GetTypeInstance(CString csTypeName, CString csModelName);
//ANNECY Shaitan EmptySectors 25/02/98
	virtual tdeSaveStatus	 GetStatusInstance(CString csTypeName, CString csModelName);
//ENDANNECY Shaitan EmptySectors

//	virtual CPA_SuperObject * GetParentForInsertion	 (CString csTypeName, CString csModelName, tdstPosition *p_stPosition) { return NULL; }
	virtual BOOL fn_bChooseInsertPosition(CPA_SuperObject *pNewInstance, CPA_SuperObject *pParent, tdstPosition *p_stPosition);

// objects
//	virtual CPA_Object * GetNewObject (CString csObjectFile, CString csObjectName, FILE *p_fFile, CPA_MainWorld *p_oMainWorld) { return NULL; }
	virtual CPA_Object *Duplicate(CPA_Object *pObject, CPA_SuperObject *pNewSuperObject);

	virtual CPA_SuperObject *GetCopyOfProtectedChild (CPA_SuperObject *pInitialChild, CPA_SuperObject *pNewOwner);

// permissions for EvtEditor
//	virtual BOOL fn_bAcceptAsParent(CPA_Object *pChild, CPA_Object *pParent);
//	virtual BOOL fn_bAcceptAsChild(CPA_Object *pParent, CPA_Object *pChild);

// when insertion is canceled
	virtual void fn_vOnCancelInsertion(CPA_SuperObject *pInstance);

	// Bounding Volume
	virtual void fn_vComputeBoundingVolume(CPA_BaseObject *pObject);
	virtual ACP_tdxHandleOfObject fn_hGetBoundingVolume(CPA_BaseObject *_pObj);

	////////

//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//(YB) Editor's specific members

//Attributes
public:
	//The (one and only) document
	EdActors_MyDocument m_clDocument;

	//The main frame
	class CMainFrame *m_pclCaracMainFrame;

// Shaitan => module list in the level
	BOOL m_bCanGenerateOptimizedLevel;
// End Shaitan => module list in the level


protected:

private:
	//For List Dialog
	CPA_Family *m_pclFamilyFilter;
	CPA_Actor *m_pclModelFilter;
	CPA_Actor *m_pclSelectedInstance;
	CPA_Actor *m_pclSelectedActorForTreeView;	//Model or Instance
	//CPA2 Stegaru Cristian 98-05
	CPA_UnloadedAlways *m_pSelectedUnloadedAlways;
	//End CPA2 Stegaru Cristian 98-05

	EdActors_EditorActor *m_pcl3DSelectedActor;

	//For tree
	CImageList m_clImageListForTree;

	//Empty SuperObject
	CPA_SuperObject *m_pclTreeRoot;
	
	BOOL m_pri_bTreeMustShowUnloadedObjects;
	BOOL m_pri_bTreeMustOnlyShowFamiliesWithModels;

	//For Undo / Redo handling
	CString m_csEditorVersion;

	// For Anim Player
	CPA_Actor		*m_pTempActorModel;
	CPA_Actor		*m_pTempActorModelInstance;
	CPA_SuperObject *m_pTempInstanceSO;
	CPA_SuperObject	*m_pTempModelSO;

	// For display
	BOOL			 m_bShowActors;
	void			*m_pEngineModule;


	//Functions
public:
	//For list Handling
	void m_fn_vSetListWithAFamily(CPA_Family *);
	void m_fn_vSetListWithAModel(EdActors_EditorActorModel *);

	CString m_fn_csGetEditorVersion();

	//For List Dialog
	void m_pub_fn_vSetSelectionInDialogList(CPA_Actor *_pclNewSelection);
	//CPA2 Stegaru Cristian 98/07/01
	BOOL mfn_bUnloadAlwaysFromLevel (CPA_Actor *pActor);
	//End CPA2 Stegaru Cristian 98/07/01
	//CPA2 Gabi Dumitrascu 98/07/15
	void mfn_vLoadAlways (CPA_UnloadedAlways *pUAlways);
	//End CPA2 Gabi Dumitrascu 98/07/15
protected:

private:
	void m_fn_vLookForModifiedDatas();
	void m_fn_vShowEditor();
	void m_fn_vHideEditor();

	void m_fn_vPrepareMotorActor(CPA_Actor *pclEdActor);

	//CPA2 Stegaru Cristian 98-04
	void m_fn_vCheckFamilyBoundingVolume (CPA_Actor *pclEdActor);
	BOOL mfn_bDisplayInfo (UINT uID);
	//End CPA2 Stegaru Cristian 98-04

	// For Anim player
	CPA_SuperObject* m_fn_pGetAnActorInstance (CPA_BaseObject *p_oFamily);
	void m_fn_vDeleteTempActorInstance();

	// For Watch data
	void m_fn_LoadWatchData();

	// For display
	void mfn_vUpdateDisplayOfAllActors (BOOL bShowInactive);

friend class EdActors_ActorsView;
friend class EdActors_MyDocument;

//(YB) End of Editor's specific members
//--------------------------------------------------------------------------
};

// YB //
#undef extern

extern CPA_Actor_Editor_Interface *g_pclInterface;
// End YB //

extern tdstDLLIdentity g_stActorEditorIdentity;


#endif // __ACTOR_INTER
