// EdIRIRD.hpp : header file
//

#ifndef _EDIRIRD_HPP_
#define _EDIRIRD_HPP_

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

#include <afxtempl.h>

//For saving function
#include "SCR.h"

#include "EdIRBELs.hpp"
#include "EdIRDbLs.hpp"
#include "EdIRBkLs.hpp"
//BEGIN ROMTEAM Cristi Petrescu 98-04-
#include "EdIRMacL.hpp"
//END ROMTEAM Cristi Petrescu 98-04-

class CPA_EdIR_DiagView;
class CTL_Editor_Data;
class CPA_Actor;

/////////////////////////////////////////////////////////////////////////////
// class CPA_EdIR_Brain
/////////////////////////////////////////////////////////////////////////////

class CPA_EdIR_Brain
{
	//Attributes
	private:
		CPA_Actor								*m_pclModel;
		BOOL										m_bOldApplicationIsOK;
		BOOL										m_bDsgVarControlsAreCreated;
		BOOL										m_bMustReInitBehaviour;
		CPA_EdIR_DebugInfoList	m_clDebugInfoList;
		CPA_EdIR_BreakPointList	m_clBreakPointList;
		BOOL										m_bAlreadyProcessed;

	public:
		BOOL						m_bHasBeenModified;
		BOOL						m_bCanQuickSave;
		CPA_EdIR_MainBehaviourList	m_clListOfIntelligenceBehaviours;
		CPA_EdIR_MainBehaviourList	m_clListOfReflexBehaviours;
		CPA_EdIR_MainBehaviourList	m_clListOfDeclarations;
		// BEGIN CPA2 Cristi Petrescu 98-03-
		CPA_EdIR_MainBehaviourList	m_clListOfMacros;
		// END CPA2 Cristi Petrescu 98-03-
		// BEGIN ROMTEAM CPA2 Cristi Petrescu 98-04-
		CPA_EdIR_MainBehaviourList	m_clListOfSubrs;
		// END ROMTEAM CPA2 Cristi Petrescu 98-04-

		//BEGIN ROMTEAM Cristi Petrescu 98-05-
		BOOL						m_bMustBuildDebugInfo;
		//END ROMTEAM Cristi Petrescu 98-05-

		//BEGIN ROMTEAM Cristi Petrescu 98-06-
		BOOL						m_bShowPrivateVariable;
		//END ROMTEAM Cristi Petrescu 98-06-

//ANNECY CB
		BOOL m_bFirstShow;
//END ANNECY
	//Operations
	private:
		//for saving script
		void		m_fn_vCreateInitControlsForBehaviour(struct AI_tdstAIModel_ *);
		void		m_fn_vUpdateInitControlsForBehaviour(struct AI_tdstAIModel_ *);
		void		m_fn_vCreateControlsForBehaviour();
		void		m_fn_vUpdateControlsForBehaviour();
		void		m_fn_vDeleteOldDsgVarControl();
		void		m_fn_vRememberOldDsgVarValues();
		void		m_fn_vUpdateDatasWithOldValues();
		void		m_fn_vReplaceBehaviourNames(CString);

	public:
		CPA_EdIR_Brain(CPA_Actor *);
		CPA_EdIR_Brain(CPA_Actor *,CPA_EdIR_Brain *);
		~CPA_EdIR_Brain();

		void	m_fn_vUpdateBehavioursList(CPA_EdIR_DiagView *,enum tdeEditState_);
		void	m_fn_vCreateOrUpdateDsgVarControlsWithEngineValues();
		CString	m_fn_csGetModelName();

		//for saving script
		static void	m_fn_vSaveEngineAI(SCR_tdst_File_Description *,char *,void *,SCR_tde_Ntfy_Action);
		static void	m_fn_vSaveEngineAIDeclaration(SCR_tdst_File_Description *,char *,void *,SCR_tde_Ntfy_Action);
		static void	m_fn_vSaveEngineAIRules(SCR_tdst_File_Description *,char *,void *,SCR_tde_Ntfy_Action);
		static void	m_fn_vSaveEngineAIReflexes(SCR_tdst_File_Description *,char *,void *,SCR_tde_Ntfy_Action);
		//BEGIN ROMTEAM Cristi Petrescu 98-04-
		static void	m_fn_vSaveEngineAISubrs(SCR_tdst_File_Description *,char *,void *,SCR_tde_Ntfy_Action);
		//END ROMTEAM Cristi Petrescu 98-04-
		static void	m_fn_vSaveEngineAIDefines(SCR_tdst_File_Description *,char *,void *,SCR_tde_Ntfy_Action);
		static void	m_fn_vSaveEditorAIDeclaration(SCR_tdst_File_Description *,char *,void *,SCR_tde_Ntfy_Action);
		// BEGIN CPA2 Cristi Petrescu 98-03-
		static void	m_fn_vSaveEditorAIMacros(SCR_tdst_File_Description *,char *,void *,SCR_tde_Ntfy_Action);
		// END CPA2 Cristi Petrescu 98-03-
		// BEGIN ROMTEAM CPA2 Cristi Petrescu 98-04-		
		static void	m_fn_vSaveEditorAISubrs(SCR_tdst_File_Description *,char *,void *,SCR_tde_Ntfy_Action);
		// END ROMTEAM CPA2 Cristi Petrescu 98-04-
		static void	m_fn_vSaveEditorAIRules(SCR_tdst_File_Description *,char *,void *,SCR_tde_Ntfy_Action);
		static void	m_fn_vSaveEditorAIReflexes(SCR_tdst_File_Description *,char *,void *,SCR_tde_Ntfy_Action);
//ROMTEAM Check Save 12.06.98 Ionut Grozea
		BOOL m_fn_MacrosHasBeenModified(){ return (m_clListOfMacros.m_fn_bHasBeenModified() || m_clListOfDeclarations.m_fn_bHasBeenModified());};
//ENDROMTEAM Check Save 12.06.98 Ionut Grozea
		/* CHRISTOPHE QUICK SAVE MODIFICATIONS */
		void				m_fn_vQuickSave();
		/* END CHRISTOPHE QUICK SAVE MODIFICATIONS */
		
		//Check IA
		BOOL	m_fn_bCheckIA();

		//Interprets IA
		BOOL	m_fn_bProcessIA(BOOL,CPA_Actor *pclActor=NULL);

		//for updating dsg var controls
		CPA_Actor	*m_fn_pclGetModel();

		BOOL	m_fn_bHasBeenModified();
		void	m_fn_vSetModified(BOOL);

		BOOL	m_fn_bIAIsAlreadyProcessed();

		BOOL	m_fn_bReInitBehaviourIsNeeded();
		void	m_fn_vSetReInitBehaviourFlag(BOOL);

		void	m_fn_vNotify();

// Shaitan FastC {
		void	m_fn_vNotifyIA();
//End Shaitan FastC }

		BOOL	m_fn_bOldApplicationIsOK();

		//interface with action editor
		void	*m_fn_pvGetStateHandle(CString);
		void	m_fn_vGetActionList(CStringList *);

		//interface with debugger
		CString	m_fn_csGetDsgVarName(long	lIndex);
		//long		m_fn_lGetLineNumber(struct tdstNodeInterpret_ *);
		//long		m_fn_lGetColumnNumber(struct tdstNodeInterpret_ *);
		//long		m_fn_lGetIndex(struct tdstNodeInterpret_ *);
		void		m_fn_vShowBehaviour(struct tdstNodeInterpret_ *);
		//BEGIN ROMTEAM Cristi Petrescu 98-05-
		void		m_fn_vShowBehaviour(CString);
		void		m_fn_vMustBuildDebugInfo (BOOL);
		CString		m_fn_csGetBehaviourName (struct tdstNodeInterpret_ *);

		//void		m_fn_vStartExecutedCodeDisplay (CString);
		//void		m_fn_vStopExecutedCodeDisplay (CString);
		void		m_fn_vClearExecutedNodes (CString);
		void		m_fn_vSetOneExecutedNode (struct tdstNodeInterpret_ *);

		void		m_fn_vUpdateDebugInfo (void);

		// BEGIN ROMTEAM Cristi Petrescu 98-06-
		long		m_fn_lGetVariableIndex (CString VariableName);
		// END ROMTEAM Cristi Petrescu 98-06-
		//END ROMTEAM Cristi Petrescu 98-05-

		CPA_EdIR_BreakPointList	*m_fn_pclGetBreakPointList();
		void										m_fn_vSetOrRemoveOneBreakPoint(long,CString);
		void										m_fn_vSetEngineBreakPoints(BOOL);
		
		CPA_EdIR_DebugInfoList *m_fn_pclGetDebugInfoList(void) ;

// Shaitan => Macros to subroutines
		void m_fn_vChangeAllEditorMacrosToSubroutines	(void);
		void m_fn_vRemoveAllMacrosFromEditorAI			(void);
		void m_fn_vUpdateEditorSubroutines				(void);
		void m_fn_vChangeOneEditorMacroToSubroutines	(CPA_EdIR_MainBehaviour	*pMacroMainBehaviour);
		void m_fn_vRemoveOneMacroFromEditorAI			(CPA_EdIR_MainBehaviour	*pMacroMainBehaviour);
		long m_fn_lCreateEditorSubroutinesFromMacro		(CPA_EdIR_MainBehaviour *pMacroMainBehaviour, CRect crTitleRect, CStringList *pListOfMacros, CStringList *pListOfSubrs);
		void m_fn_vUpdateEditorMacroCallsInEditorAI		(CStringList *pListOfMacros, CStringList *pListOfSubrs);
		void m_fn_vReplaceInEditorBehaviour				(CPA_EdIR_MainBehaviour	*pMainBehaviour, CString csMacroName, CString csSubrName);

		CString m_fn_csBuildDefineListForMacro			(CStringList *pListOfDefines, CString csMacroText);
		void m_fn_vRegisterEditorDefinesForMacro		(CPA_EdIR_MainBehaviour	*pMacroMainBehaviour, CStringList *pListOfDefines);

		CString m_fn_csExtractCommentLinesForNextMacro	(CString csMacroText);

		int	 m_fn_iGetFirstValidOccurence				(CString csLowRules, CString csLowSearched);

		BOOL m_fn_bIsIsolatedName						(int iStartIndex, int iEndIndex, CString csRule);
		BOOL m_fn_bIsInCommentedLine					(int iStartIndex, CString csRule);
// Shaitan => Macros to subroutines
};

#endif //_EDIRIRD_HPP_
