/*=============================================================================
 *
 *  Filename:			ACInterf.hpp
 *  Version:            1.0
 *  Date:				30/12/96
 *  Author:             Marc Trabucato
 *
 *  Description:		description of TAction_Interface class, which is the
 *						base class of action DLL (inherit CPA_ToolDLLBase
 *
 *===========================================================================*/

#ifndef __TActionINTERF_HPP__
#define __TActionINTERF_HPP__

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

#ifdef ACTIVE_EDITOR

//3dos

//ACP
#include "TAC.h"

class CPA_DialogList;

class CPA_Family;
class CPA_Action;
class CPA_State;

class CDlgActionContents;
class CDlgActionList;
class CDlgState;
class CDlgAction;
class CDlgAnimList;
class CDlgNameList;

class CDlgZonesActivation;
class CDlgZAList;
class CDlgZAL;

class CPA_ZonesActivating;
class CPA_ZonesActivatingList;
class CPA_tdoNameList;

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

//----------------------------------------------------------
// Tool DLL interface class
//----------------------------------------------------------
class TAction_Interface : public CPA_ToolDLLBase
{
  protected:
    BOOL                m_bStateMode;
    //
    CSplitFrame         *m_p_oSplitterLeftSTM;
    CPA_DialogList      *m_p_oDialogListSTM;
    CDlgActionList      *m_p_oDlgActionList;
    CDlgActionContents  *m_p_oDlgActionContents;
    //
    CSplitFrame         *m_p_oSplitterBottomSTM;
    CDlgState           *m_p_oDlgState;
    CDlgAnimList        *m_p_oDlgAnimList;
    //
    CSplitFrame         *m_p_oSplitterLeftZAM;
    CPA_DialogList      *m_p_oDialogListZAM;
    CDlgNameList        *m_p_oDlgNameList;
    CDlgZAL             *m_p_oDlgZAList;
    CDlgAction          *m_p_oDlgActions;
    //
    CSplitFrame         *m_p_oSplitterBottomZAM;
    CDlgZAList          *m_p_oDlgZAListContent;
    CDlgZonesActivation *m_p_oDlgZA;
    //
    long                m_lEditorState;
    // current values
	CPA_Family              *m_p_oCurrentFamily;
	CPA_Action			    *m_p_oCurrentAction;
	CPA_State			    *m_p_oCurrentState;
    CPA_tdoNameList         *m_p_oCurrentNameList;
    CPA_ZonesActivatingList *m_p_oCurrentZAList;
    CPA_ZonesActivating     *m_p_oCurrentZA;
    //
    BOOL                     m_bAllFamilies;
    CPA_Family              *m_p_oCurrentAnimFamily;
// CPA_Ed_1 Mihaela Tancu begin
	int						 m_iIndexListBox;			//the index in the list box used for drag&drop of animations in the list box with states 
	HWND					 m_hDlgActionContentsHwnd;  //the HWND of the action contents
// CPA_Ed_1 Mihaela Tancu end
  private:


  public:
    TAction_Interface(void);
    //~TAction_Interface(void);
// CPA_Ed_1 Mihaela Tancu begin
	int						mfn_iGetIndexListBox		( void)		{ return m_iIndexListBox; }
	void					mfn_iSetIndexListBox		( int iIndex)		{ m_iIndexListBox = iIndex; } 
	HWND					mfn_hGetDlgActionContentsHwnd	( void)	{ return m_hDlgActionContentsHwnd; }
	void					mfn_hSetDlgActionContentsHwnd	( HWND hDlgActionContentsHwnd){ m_hDlgActionContentsHwnd = hDlgActionContentsHwnd; } 
// CPA_Ed_1 Mihaela Tancu end

	// get functions
    CPA_Family              *mfn_p_oGetCurrentFamily    ( void )    { return m_p_oCurrentFamily; }
    CPA_Action              *mfn_p_oGetCurrentAction    ( void )    { return m_p_oCurrentAction; }
    CPA_State               *mfn_p_oGetCurrentState     ( void )    { return m_p_oCurrentState;  }
    CPA_tdoNameList         *mfn_p_oGetCurrentNamesList ( void )    { return m_p_oCurrentNameList; }
    CPA_ZonesActivatingList *mfn_p_oGetCurrentZAList    ( void )    { return m_p_oCurrentZAList; }
    CPA_ZonesActivating     *mfn_p_oGetCurrentZA        ( void )    { return m_p_oCurrentZA; }

    void             mfn_vSetEditMode         ( BOOL _bStateMode = TRUE, BOOL _bActive = TRUE );

	// select functions
    void mfn_vChangeFamily  ( CPA_Family *_p_oNewFamily );
	void mfn_vChangeAction  ( CPA_Action *_p_oAction );
	void mfn_vChangeState   ( CPA_State *_p_oState );
    void mfn_vChangeNameList( CPA_tdoNameList *_p_oNameList );

    // new functions for modif
    // update display
    void mfn_vSetCurrentFamily      ( CPA_Family *_p_oNewFamily );
	void mfn_vSetCurrentAction      ( CPA_Action *_p_oAction );
	void mfn_vSetCurrentState       ( CPA_State *_p_oState );
	void mfn_vSetCurrentNameList    ( CPA_tdoNameList *_p_oList );
    void mfn_vSetCurrentActionList  ( int *_a_ItemList, long _lNumberOfItems );
    void mfn_vSetCurrentZAList      ( CPA_ZonesActivatingList *_p_oZAList );
    void mfn_vSetCurrentZA          ( CPA_ZonesActivating *_p_oZA );

    void mfn_vAllActionsDeleted ( CPA_Family *_p_oFamily ) ;
    void mfn_vActionCreated     ( CPA_Family *_p_oFamily , CPA_Action *_p_oAction );
    void mfn_vActionDeleted     ( CPA_Family *_p_oFamily );

    void mfn_vStateCreated      ( CPA_Action *_p_oAction , CPA_State *_p_oState );
    void mfn_vStateDeleted      ( CPA_Action *_p_oAction );
    void mfn_vStateChanged      ( CPA_State  *_p_oState , tdeChangingState _eChange) ;

    void mfn_vZAListCreated     ( CPA_ZonesActivatingList *_p_oZAList );
    void mfn_vZAListDeleted     ( CPA_tdoNameList *_p_oNameList );
    void mfn_vZAToStateChanged  ( CPA_List<CPA_State> *_p_oListOfStates );
    void mfn_vZACreated         ( CPA_ZonesActivating *_p_oZA );
    void mfn_vZAChanged         ( CPA_ZonesActivating *_p_oZA, int _iIndex );
    void mfn_vZADeleted         ( CPA_ZonesActivating *_p_oZA );

    void mfn_vNotifyAllZAList   ( CPA_Family *_p_oFamily, BOOL _bUpdateList = TRUE );

  //====================================================================================
  //========================= COMMON DLL FUNCTIONS OVERLOAD ============================
  //====================================================================================
    //void fn_vOnModifDrawFlag(class CPA_SuperObject *) {};

  // ACP MEssages Functions overload
    void    fn_vJustAfterRegistered   (void);
    void    fn_vConstruct             (void);
	void    fn_vBeforeEngine          (void);
	void    fn_vBeforeEditor          (void);
    BOOL    fn_bAcceptToRunEngine     (void);
    BOOL    fn_bAcceptToSave          (void);
  // Windows MEssages Functions overload

  // to update lists of reachable objects

  // for changes

  // editor Modifs
    void fn_vOnSelect       (CPA_SuperObject *pEdObj, tdeTypeModif eType, tdeStatus eStatus);

  // insert

  // moves

  // Dialog List
    CPA_BaseObject  *GetDialogSelection			(CPA_DialogList *pDialog, CString csTypeName, tdeListDrawMode eDrawMode);
    void            GetListsForDialog			(CPA_DialogList *pDialog);
    BOOL			fn_bOnSelChangeListObjects  (CPA_DialogList *pDialog, CString csTypeName, CPA_BaseObject *pSelectedObject, BOOL _bUnselect);
	BOOL			fn_bOnDblClkListObjects		(CPA_DialogList *pDialog, CString csListName, CPA_BaseObject *pSelectedObject);
	void			fn_vInitDefaultParameters	(CPA_DialogList *pDialog);
	BOOL			fn_bAddEntriesToListPopup	(CPA_DialogList *pDialog, CString csListName, CMenu *pMenu, UINT uiCustomEntriesStart);
	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);


  //Menus
    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);

  // Current Editor
	tdePermission fn_eAcceptNewEditor	(CPA_EditorBase *pNewEditor)	 { return 	C_CloseBefore; }
    BOOL          fn_bCanActivateEditor (CPA_List<CPA_BaseObject> *pParams);
	BOOL          fn_bCanCloseEditor	(void);

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

  // To communicate with that editor
    long OnQueryAction  (CPA_EditorBase *p_oSender, WPARAM, LPARAM);
    long OnQueryOpen    (CPA_EditorBase *p_oSender, WPARAM, LPARAM);
    long OnQueryClose   (CPA_EditorBase *p_oSender, WPARAM, LPARAM)     { return 0; }


  protected:
    //Check functions
    BOOL mfn_bCheckStatesTransitions( CPA_Family *_p_oFamily );
    BOOL mfn_bCheckFamiliesZA       ( void );
    BOOL mfn_bCheckFamiliesZAList   ( void );
    //load functions
    BOOL mfn_bLoadStatesMechanics   ( CPA_Family *_p_oFamily );
    BOOL mfn_bLoadStatesAnimations  ( CPA_Family *_p_oFamily );
    // test functions
    BOOL mfn_bUpdateStateBeforeRunningEngine    ( CPA_Family *_p_oFamily );
    BOOL mfn_bUpdateStateBeforeSaving           ( CPA_Family *_p_oFamily );
    BOOL mfn_bUpdateCsaListBeforeRunningEngine  ( void );
    BOOL mfn_bUpdateCsaListBeforeSaving         ( void );
    void mfn_vWriteErrorOnFile                  (long _lErrorType,void *_p_void);
	//load function
    void mfn_vLoadActions                       ( CPA_Family *_p_oFamily );
    void mfn_vInitStateAfterLoading             ( CPA_Family *_p_oFamily );
    // new load functions
    void mfn_vCreateEditorObjects               ( CPA_Family *_p_oFamily );
    void mfn_vLoadAllActions                    ( CPA_Family *_p_oFamily );
    void mfn_vUpdateMechanics                   ( void );
	void mfn_vUpdateAllStates					( CPA_Family *_p_oFamily );
// Shaitan => state list in the level
	// update list of used actions
	void mfn_vUpdateListOfUsedActions			( CPA_Family *_p_oFamily);
	static SCR_tde_Anl_ReturnValue	m_fn_tdeCallBackLoadUsedActions(SCR_tdst_File_Description *pfFile,  char *szAction, char *szPars[], SCR_tde_Anl_Action eType);
// End Shaitan => state list in the level

    // ZA changes NOTIFICATION
    void mfn_vRemoveZoneFromNamesList           ( CPA_tdoNameList *_p_oNameList, unsigned short _usIndex );
    void mfn_vInsertZoneToNamesList             ( CPA_tdoNameList *_p_oNameList, unsigned short _usIndex );
	//
    CPA_BaseObject *mfn_p_oCreateNewZA          ( CPA_tdoNameList *_p_oName, char *_szName );
    CPA_BaseObject *mfn_p_oCreateNewZAList      ( CPA_tdoNameList *_p_oName, char *_szName );

    void mfn_vSavePreferences                   ( void );
    void mfn_vRestorePreferences                ( void );
};

#undef extern
extern tdstDLLIdentity g_stTActionIdentity;

#endif // ACTIVE_EDITOR
#endif // __TActionINTERF_HPP__
