/*=========================================================================
* 
* SECTint.hpp :  Sector DLL Interface - definition
* 
*
* Version			1.0
* Creation date			
* Revision date		
*
* Shaitan
*=======================================================================*/

#ifndef __SECT_INT_HPP__
#define __SECT_INT_HPP__

#include "incSND.h"
#include "incITF.h"

#include "SECTobj.hpp"

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

// mode
typedef enum
{
	E_em_EditSector,
	E_em_EditList
//Shaitan Clean Env
//	E_em_EditEnv
}
tdeEditMode;

// colors
#define C_ColorEdited		E_lc_Red
#define C_ColorSelected		E_lc_Blue
#define C_ColorShow			E_lc_Green
#define C_ColorSurf			E_lc_LightBlue
#define C_NoColor			E_lc_NoColor

// dialogs
class SECT_DialogList;
class SECT_DialogMode;
class SECT_DialogEdit;
class SECT_DialogSel;
class SECT_DialogBase;
class SECT_DialogActiv;
class SECT_DialogColls;
class SECT_DialogGraph;
class SECT_DialogSound;
class SECT_DialogSoundEvent;
class SECT_DialogDistance;
//Shaitan Clean Env
/*
class SECT_DialogEnvList;
class SECT_DialogEnvs;
class SECT_DialogSrf;
class SECT_DialogEnv;
class SECT_DialogMec;
class SECT_DialogVis;
*/

extern BOOL g_bCanSave;


/*===========================================================================
*		Description:	class Sector_Interface
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                      Author:         
*=========================================================================*/

class Sector_Interface : public CPA_ObjectDLLBase
{
private:
// edited sector
	CPA_SuperObject				*m_pEditedSector;
	CPA_SuperObject				*m_pSelectedSector;

// KeyBoard
	CPA_KeyActionConfiguration	* m_pKeyboard;

// ImageList
	CImageList					m_oStateIconList;
	
// Frames
	CSplitFrame					* m_pSectorLeftFrame;
	CSplitFrame					* m_pSectorBottomFrame;
//Shaitan Clean Env
/*
	CSplitFrame					* m_pEnvLeftFrame;
	CSplitFrame					* m_pEnvBottomFrame;
*/
	CSplitFrame					* m_pCurrentLeftFrame;
	CSplitFrame					* m_pCurrentBottomFrame;

// Dialogs (Sector)
	CPA_DialogList				* m_pSectorDialogList;
	SECT_DialogEdit				* m_pSectorDialogEdit;
	SECT_DialogMode				* m_pSectorDialogMode;
	SECT_DialogSel				* m_pDialogSel;
	SECT_DialogActiv			* m_pDialogActiv;
	SECT_DialogColls			* m_pDialogColls;
	SECT_DialogGraph			* m_pDialogGraph;
	SECT_DialogSound			* m_pDialogSound;
	SECT_DialogSoundEvent		* m_pDialogSoundEvent;
	SECT_DialogDistance			* m_pDialogDistance;

//Shaitan Clean Env
/*
// Dialogs (Env)
	CPA_DialogList				* m_pEnvDialogList;
	SECT_DialogEdit				* m_pEnvDialogEdit;
	SECT_DialogMode				* m_pEnvDialogMode;
	SECT_DialogEnvList			* m_pDialogEnvList;
	SECT_DialogEnvs				* m_pDialogEnvs;
	SECT_DialogSrf				* m_pDialogSrf;
	SECT_DialogEnv				* m_pDialogEnv;
	SECT_DialogMec				* m_pDialogMec;
	SECT_DialogVis				* m_pDialogVis;
*/

// Dialogs (Current)
	CPA_DialogList				* m_pCurrentDialogList;
	SECT_DialogEdit				* m_pCurrentDialogEdit;
	SECT_DialogMode				* m_pCurrentDialogMode;

// Modes
	tdeEditMode					m_eEditMode;
	int							m_aListActivity[C_NumberOfLists];

//Shaitan Clean Env
/*
// Environment
	CString						m_csEnvFileName;
	CString						m_csMecEnvFileName;
	CString						m_csVisEnvFileName;
*/

// Reference Path
	CString						m_csSECTRefPath;

//Shaitan Clean Env
/*
	CString						m_csSURFRefPath;
	CString						m_csENVRefPath;
	CString						m_csMECRefPath;
	CString						m_csVISRefPath;
*/

// Select Mode
	CString						m_csSaveSelectMode;
	BOOL						m_bPreviousState;
	BOOL						m_bPreviousLinkMode;

// Sound
	CPA_BaseObjectList			* m_pSoundEventList;

//Shaitan Clean Env
/*
	CPA_BaseObjectList			* m_pSoundEnvList;
// Surface
	CPA_SuperObject				* m_pCurrentVisual;
	SECT_Surface				* m_pSurfaceToDraw;
*/

// Init
	BOOL						  m_bAllInitialised;

//Shaitan Clean Env
// Environments
//	CPA_List<CPA_SuperObject>	  m_oSelectList;

// Symetric Mode
	BOOL						  m_bSymetricMode;

// Borders
	BOOL						  m_bDisplayBorders;

// Copy / Paste
	CPA_List<CPA_SuperObject>	  m_oCopyOfSectorList;

public:
    Sector_Interface(void);
    ~Sector_Interface(void);

/*===========================================================================
	Get functions
=========================================================================*/

	// current dialog
	CPA_DialogList		* GetDialogList		(void)	{ return m_pCurrentDialogList; }
	SECT_DialogEdit		* GetDialogEdit		(void)	{ return m_pCurrentDialogEdit; }
	SECT_DialogMode		* GetDialogMode		(void)	{ return m_pCurrentDialogMode; }
	
	// sector dialogs
	SECT_DialogSel		* GetDialogSel		(void)	{ return m_pDialogSel; }
	SECT_DialogBase		* GetSingleList		(tdeTypeList eType);

//Shaitan Clean Env
/*
	// env dialogs
	SECT_DialogEnvList	* GetDialogEnvList	(void)	{ return m_pDialogEnvList; }
	SECT_DialogEnvs		* GetDialogEnvs		(void)	{ return m_pDialogEnvs; }
	SECT_DialogSrf		* GetDialogSrf		(void)	{ return m_pDialogSrf; }
	SECT_DialogEnv		* GetDialogEnv		(void)	{ return m_pDialogEnv; }
	SECT_DialogMec		* GetDialogMec		(void)	{ return m_pDialogMec; }
	SECT_DialogVis		* GetDialogVis		(void)	{ return m_pDialogVis; }
*/
	
	CPA_SuperObject		* GetEditedSector	(void)	{ return m_pEditedSector; }
	
	CPA_SuperObject		* GetSectorToEdit	(CPA_List<CPA_BaseObject> *pParam);

	tdeEditMode			  GetEditMode		(void)	{ return m_eEditMode; }
	int					  GetListActivity	(tdeTypeList eList)	{ return m_aListActivity[eList]; }

	CString				  GetSECTRefPath	(void)	{ return m_csSECTRefPath; }
//Shaitan Clean Env
/*
	CString				  GetSURFRefPath	(void)	{ return m_csSURFRefPath; }
	CString				  GetENVRefPath		(void)	{ return m_csENVRefPath; }
	CString				  GetMECRefPath		(void)	{ return m_csMECRefPath; }
	CString				  GetVISRefPath		(void)	{ return m_csVISRefPath; }

    SECT_Surface		* GetSurfaceToDraw	(void)	{ return m_pSurfaceToDraw; }
*/
	
	CPA_SuperObject		* GetSectorWithName	(CString csName);

//Shaitan Clean Env
//	CPA_BaseObjectList	* GetSoundEnvList	(void) { return m_pSoundEnvList; }
	CPA_BaseObjectList	* GetSoundEventList	(void) { return m_pSoundEventList; }

//Shaitan Clean Env
//	CPA_List<CPA_SuperObject> * GetSelectList	(void) { return	&m_oSelectList; }
	CPA_List<CPA_SuperObject> * GetCopyOfSectorList	(void) { return	&m_oCopyOfSectorList; }

	BOOL fn_bSymetricMode (void) { return m_bSymetricMode; }

	BOOL fn_bDisplayBorders (void)	{ return m_bDisplayBorders; }

/*===========================================================================
	Set functions
=========================================================================*/

	void SetEditMode			(tdeEditMode eNewMode, BOOL bRedraw = TRUE);
	void SetListActivity		(tdeTypeList eType, BOOL bActive, BOOL bRedraw = TRUE);	
	void SetCurrentFrame		(tdeEditMode eNewMode);
	void SetSymetricMode		(BOOL bSymetricMode) { m_bSymetricMode = bSymetricMode; }
	void fn_vUpdateEditMode		(BOOL bReinit = FALSE);

/*===========================================================================
	Dialogs
=========================================================================*/

	void fn_vCreateSectorDialogs		(CString csFileName);
//Shaitan Clean Env
//	void fn_vCreateEnvironmentDialogs	(CString csFileName);

	void fn_vOnKeyDownInSectorList	(SECT_DialogBase *pDialog, UINT nChar);
//Shaitan Clean Env
//	void fn_vOnKeyDownInEnvList		(CPA_SuperObject *pSector, long lNumEnvElem, UINT nKey);

/*===========================================================================
	Others
=========================================================================*/

// inits
	void fn_vReinitEditor (CPA_SuperObject *pSectorToEdit);
	
// permissions & modifs
	BOOL fn_bAcceptModifHierarchy	(tdeStatus eStatus);
	void fn_vOnModifHierarchy		(tdeStatus eStatus);

// colors
	void fn_vShowEditedSector	(BOOL bUpdateDrawing, BOOL bAlone = TRUE);
	void fn_vShowAllSectors		(BOOL bUpdateDrawing = TRUE);
	void fn_vShowSelection		(BOOL bUpdateDrawing = TRUE);
	void fn_vSetRecursiveColor  (CPA_SuperObject *pEdObj, tdeLocalColor eColor);

// selection
	void fn_vSelectNewSector (CPA_SuperObject *pSector, BOOL bCenterOnSector = FALSE, BOOL bUpdateDrawing = TRUE);
// lists
	void fn_vUpdateActiveLists	(CPA_SuperObject *pSector);
// select for environment
	void fn_vUpdateSelectList	(CPA_SuperObject *pSector);

// preferences
	void fn_vSaveDialogsPreferences (void);

// copy / paste
	void fn_vCopySectorList  (CPA_SuperObject *pSector, tdeTypeList eList);
	void fn_vPasteSectorList (CPA_SuperObject *pSector, tdeTypeList eList);

/*===========================================================================
	Environments
=========================================================================*/

//Shaitan Clean Env
/*
	void fn_vInitEnvironmentFiles	(void);
	
	void fn_vLoadEnvironments		(void);
	void fn_vLoadMecEnvironments	(void);
	void fn_vLoadVisEnvironments	(void);

  CString	GetEnvFileName		(void) { return m_csEnvFileName; }
	CString GetMecEnvFileName	(void) { return m_csMecEnvFileName; }
	CString GetVisEnvFileName	(void) { return m_csVisEnvFileName; }
	
	SECT_Environment * GetOrBuildEnvironment	(ENV_tdxHandleToEnvironment hEnvironment);
	SECT_Environment * GetEnvironmentWithName	(CString csName);
	SECT_Environment * GetDefaultEnvironment (void);


	SECT_MecEnvironment * GetOrBuildMecEnvironment (DNM_tdxHandleToMecEnvironment hMecEnv);
	SECT_MecEnvironment * GetDefaultMecEnvironment (void);

	SECT_VisEnvironment * GetOrBuildVisEnvironment (ACP_tdxHandleToVisualEnvironment hVisEnv);
	SECT_VisEnvironment * GetDefaultVisEnvironment (void);

	SECT_SndEnvironment * GetOrNullSndEnvironment  (SND_tdxHandleToSoundInfo hSndEnv);
	SECT_SndEnvironment * GetDefaultSndEnvironment (void);
*/

/*===========================================================================
	Sounds
=========================================================================*/

	void fn_vReinitSoundParameters (void);

	SECT_SoundEvent * GetOrNullSoundEvent	(SND_tdxHandleToSoundEvent hSoundEvent);
	SECT_SoundEvent * GetDefaultSoundEvent	(void);

/*===========================================================================
	Surface
=========================================================================*/
//Shaitan Clean Env
/*
	void fn_vLoadSurfaces	(void);
	void SetSurfaceToDraw	(SECT_Surface *pSurface);

	SECT_Surface *	GetOrBuildSurface	(SRF_tdxHandleToSurface hSurface);
	SECT_Surface *	GetDefaultSurface	(Sector_Object *pSector);

	long GetSurfaceHeightIndex		(SECT_Surface *pSurface, long lPrevIndex);
	void fn_vUpdateHeightIndex		(SECT_Surface *pSurface);
	void fn_vUpdateAllSurfaceList	(SECT_Surface *pSurface);
*/

/*===========================================================================
	Water Effect
=========================================================================*/
	
//Shaitan Clean Env
//	void fn_vUpdateSurfaceList (BOOL bOnlyCurrentSurfaces = TRUE);

/*===========================================================================
	Borders
=========================================================================*/

	void fn_vDisplayBorder	(Sector_Object *pSector, BOOL bDisplay, BOOL bUpdate);
	void fn_vDisplayBorders (BOOL bDisplay);


/*===========================================================================
	Virtual
=========================================================================*/

	BOOL fn_bCanChangeVirtual	(CPA_SuperObject *pSector, BOOL bVirtual);
	void fn_vUpdateAllVirtuals	(void);
	
//#################################################################################
// DLL FUNCTIONS OVERLOAD
//#################################################################################

/*===========================================================================
	Inits
=========================================================================*/
 
    void fn_vJustAfterRegistered	(void);
	void fn_vConstruct				(void);
	void fn_vInitListByType			(CPA_World *pWorld);

    void fn_vBeforeEngine		(void);
    void fn_vBeforeEditor		(void);

	void fn_vLevelChanges		(void);
	void fn_vLevelHasChanged	(void);

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

	BOOL fn_bLoadBaseObject(CPA_BaseObject *p_oObject);

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

/*===========================================================================
	Editor
=========================================================================*/
 
    BOOL fn_bDefineSubMenu		(EDT_SubMenu *_p_oEDTSubMenu);
    void _OnSubMenuCommand		(EDT_SubMenu *_p_oEDTSubMenu, UINT uiMsgID);

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

	BOOL fn_bCanActivateEditor	(CPA_List<CPA_BaseObject> *pParams);

	void fn_vOnActivateEditor	(CPA_List<CPA_BaseObject> *pParam, BOOL bBackActivated=FALSE);
	void fn_vOnCloseEditor		(void);

    BOOL fn_bHasGainedFocus		(void);
    void fn_vHasLostFocus		(void);

/*===========================================================================
	Permissions
=========================================================================*/

	tdeTypeAnswer fn_bAcceptSelect	(CPA_SuperObject *pEdObj, ACP_tdxIndex xIndex, HIE_tdstPickInfo *pPicking, tdeStatus eStatus);

	BOOL fn_bAcceptModifDelete		(CPA_List<CPA_SuperObject> *pListObjects, tdeStatus eStatus);
	BOOL fn_bAcceptModifParent		(CPA_List<CPA_SuperObject> *pListObjects, tdeStatus eStatus);
	BOOL fn_bAcceptModifCopy		(CPA_List<CPA_SuperObject> *pListObjects, tdeStatus eStatus);
	BOOL fn_bAcceptModifTranslate	(CPA_List<CPA_SuperObject> *pListObjects, tdeStatus eStatus);
	BOOL fn_bAcceptModifRotate		(CPA_List<CPA_SuperObject> *pListObjects, tdeStatus eStatus);
	BOOL fn_bAcceptModifScale		(CPA_SuperObject *pEdObj, tdeStatus eStatus);
	BOOL fn_bAcceptModifInsert		(CPA_SuperObject *pEdObj, CPA_SuperObject *pParent, tdeStatus eStatus);
	BOOL fn_bAcceptAsParent			(CPA_BaseObject *pChild, CPA_BaseObject *pParent);
	BOOL fn_bAcceptAsChild			(CPA_BaseObject *pParent, CPA_BaseObject *pChild);

/*===========================================================================
	Modifs
=========================================================================*/

	void fn_vOnSelect		(CPA_SuperObject *pEdObj, tdeTypeModif eType, tdeStatus eStatus);
	void fn_vOnModifName	(CPA_SuperObject *pEdObj, CString csInitalName, CString csFinalName, tdeTypeModif eType, tdeStatus eStatus);

	void fn_vOnModifDelete		(CPA_List<EDT_SaveParents> *pListObjects, tdeTypeModif eType, tdeStatus eStatus);
	void fn_vOnModifParent		(CPA_List<EDT_SaveParents> *pListObjects, tdeTypeModif eType, tdeStatus eStatus);
	void fn_vOnModifCopy		(CPA_List<EDT_SaveParents> *pListObjects, tdeTypeModif eType, tdeStatus eStatus);
	void fn_vOnModifInsert		(CPA_SuperObject *pEdObj, CPA_SuperObject *pParent, tdstPosition *p_stPosition,
								 tdeTypeModif eType, tdeStatus eStatus);

	void fn_vOnChangeRoot	(void);
	void fn_vOnChangeWorld	(void);
	void fn_vOnChangeDevice (void);

/*===========================================================================
	Messages
=========================================================================*/

    BOOL    _OnKeyDown			(UINT nChar, UINT nRepCnt, UINT nFlags);
    BOOL    _OnLButtonDown		(UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *pPicking);
    BOOL    _OnRButtonDown		(UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *pPicking);
    BOOL    _OnLButtonDblClk	(UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *pPicking);

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

	void	GetListsForDialog			(CPA_DialogList *pDialog);
	void	fn_vInitDefaultParameters	(CPA_DialogList *pDialog);

	BOOL	fn_bOnSelChangeListObjects	(CPA_DialogList *pDialog, CString csListName, CPA_BaseObject *pSelectedObject, BOOL bUnselect);
	BOOL	fn_bOnDblClkListObjects		(CPA_DialogList *pDialog, CString csListName, CPA_BaseObject *pSelectedObject);

	int		GetStateForListItem			(CPA_DialogList *pDialog, CString csListName, CPA_BaseObject *pObject);
	BOOL	GetColorsForListItem		(CPA_DialogList *pDialog, CString csListName, CPA_BaseObject *pObject,
										  COLORREF *pRectColor, COLORREF *pTextColor);

	BOOL fn_bIsInActiveLists			(CPA_SuperObject *pSector);
	BOOL fn_bIsAvailableForList			(CPA_SuperObject *pSector);


	tdeTypeList	GetFirstActiveList		(void);
	void		fn_vGetSectorsToDraw	(CPA_List<CPA_SuperObject> *pSectorList);

	void fn_vLinkNearestSectors (void);
};


extern tdstDLLIdentity g_stSectorIdentity;


#endif // __SECT_INT_HPP__
