/* definition of Main world class*/
 
#ifndef __CPA_MWORLD_HPP__
#define __CPA_MWORLD_HPP__
 
#ifdef ACTIVE_EDITOR
 
#include <afxtempl.h>
#include "ToolDLLb.hpp"
#include "ObjDLLb.hpp"
#include "CPAWorld.hpp"
#include "CPASList.hpp"
#include "geo.h"
#include "gli.h"
 
/****************************************/
#ifndef CPA_EXPORT
#if defined(CPA_WANTS_IMPORT)
#define CPA_EXPORT __declspec(dllimport)
#elif defined(CPA_WANTS_EXPORT)
#define CPA_EXPORT __declspec(dllexport)
#else
#define CPA_EXPORT
#endif
#endif
/****************************************/
 
class CPA_Interface;
class DEV_MultiDevice;
class FRMBaseMenu;
 
class CPA_EXPORT CPA_MainWorld
{
private:
	long		m_lKey;
	CPA_Interface *m_p_oInterface;
 
 
protected:
    CPA_World	*m_p_oGlobalWorld;
    CPA_List<CPA_ObjectDLLBase> m_oListOfObjectDLL;
    CPA_List<CPA_ToolDLLBase>	m_oListOfToolDLL;
	CPA_List<CPA_EditorBase>	m_oListOfEditorBase;
    CPA_List<CPA_ToolDLLBase>	m_oListOfToolDLLReceivingWindowMsg;
    CPA_List<CPA_ToolDLLBase>	m_oListOfToolDLLReceivingEvtEditorMsg;
 
    FRMBaseMenu		*m_p_oCurrentFrameBaseMenu;
	CPA_EditorBase	*m_p_oCurrentEditor;
 
public:
	GLI_tdxHandleToLight  m_a_tdxhArrayOfLocalLights[C_lMaxLightInViewport];
	long				  m_lNbLocalLights;
	GLI_tdxHandleToLight  m_a_tdxhArrayOfDynamicLights[C_lMaxLightInViewport];
	long				  m_lNbDynamicLights;
 
    /* constructor/destructor*/
    CPA_MainWorld	(long lKey,DEV_MultiDevice *p_oDevice, CPA_Interface *p_oInterface);
    ~CPA_MainWorld	(void);
 
    /* acces to parameters*/
    CPA_World		*GetWorld			 (void)		{ return m_p_oGlobalWorld; }
	CPA_Interface	*GetInterface		 (void)		{ return m_p_oInterface; }
 
    FRMBaseMenu		*GetFRMBase			 (void)		{ return m_p_oCurrentFrameBaseMenu; }
	CPA_EditorBase	*GetCurrentEditor	 (void)		{ return m_p_oCurrentEditor; }
 
    void fn_vSetCurrentFRMBaseMenu(FRMBaseMenu *_p_oCurrentFrameBaseMenu);
 
	/* load a world*/
	void LoadANewWorld(char *szLoadPath, char *szFileName);
 
 
	/* objects and lists*/
	CPA_BaseObjectList	* fn_p_oGetOriginalObjectList	(CString csTypeName);
	CPA_BaseObjectList	* fn_p_oGetInvalidObjectList	(CString csTypeName);
    
	long				  fn_lFindObjects			 (CPA_List<CPA_BaseObject> *p_oList, CString csObjectName, CString csObjectType = "",CPA_BaseObject *p_oOwner = NO_CRITERIA, tdeResearchCriteria eCriteria = E_rc_ValidObjects);
	CPA_BaseObject		* fn_p_oFindObject			 (CString csObjectName, CString csObjectType = "", CPA_BaseObject *p_oOwner = NO_CRITERIA, tdeResearchCriteria eCriteria = E_rc_ValidObjects);
	CPA_BaseObject		* fn_p_oFindObjectWithEngine (void *p_vEngineStruct, CString csObjectType = "", CPA_BaseObject *p_oOwner = NO_CRITERIA, tdeResearchCriteria eCriteria = E_rc_ValidObjects);
    
	BOOL fn_bExist	(CString csName, CString csTypeName = "",CPA_BaseObject *p_oOwner = NO_CRITERIA, tdeResearchCriteria eCriteria = E_rc_ValidObjects);
	BOOL fn_bExist	(CPA_BaseObject *p_oObject, tdeResearchCriteria eCriteria = E_rc_ValidObjects);
 
	/* Editors*/
	void fn_vRegisterEditor (CPA_EditorBase *p_oEditor);
	CPA_List<CPA_EditorBase> * GetListOfEditorBase (void) { return &m_oListOfEditorBase; }
    CPA_EditorBase * GetEditorByName(CString csName);
 
	/* DLLs*/
	CPA_DLLBase *GetDLLWithTypeName (CString csTypeName);
 
	/* object DLLs*/
	CPA_ObjectDLLBase *GetObjectDLLWithName (CString csName);
	CPA_ObjectDLLBase *GetObjectDLLWithType (long lEngineType);
    CPA_List<CPA_ObjectDLLBase> *GetListOfObjectDLLBase(void) { return &m_oListOfObjectDLL; }
 
    /* tool DLLs*/
    CPA_ToolDLLBase *GetToolDLLWithName(char *szName);
    CPA_List<CPA_ToolDLLBase>  *GetListOfToolDLLBase			(void) { return &m_oListOfToolDLL; }
	CPA_List<CPA_ToolDLLBase>  *GetToolDLLReceivingWindowMsg	(void) { return &m_oListOfToolDLLReceivingWindowMsg; }
    CPA_List<CPA_ToolDLLBase>  *GetToolDLLReceivingEvtEditorMsg	(void) { return &m_oListOfToolDLLReceivingEvtEditorMsg; }
    void fn_vSetReceivingWindowMsgState(CPA_ToolDLLBase *,BOOL _bWantToReceive = TRUE);
    void fn_vSetReceivingEvtEditorMsgState(CPA_ToolDLLBase *,BOOL _bWantToReceive = TRUE);
 
	/* current editor*/
	BOOL fn_bSetCurrentEditor	(CPA_EditorBase *pNewEditor);
	BOOL fn_bRestoreEditor		(CPA_EditorBase *pNewEditor);
	BOOL fn_bActivateEditor		(CPA_EditorBase *pNewEditor, CPA_List<CPA_BaseObject> *pParams);
	BOOL fn_bCloseEditor		(CPA_EditorBase *pOldDLL);
 
/* Begin Silviu Simen 01 september 1998 List of Objects in Sectors*/
	CPA_ListBySector	m_stListObjectsInSectors;
/* End Silviu Simen 01 september 1998 List of Objects in Sectors*/
 
};
 
#endif /*ACTIVE_EDITOR*/
#endif /*__CPA_MWORLD_HPP__*/
