//#################################################################################
//
// BASE DEFINITION CLASS OF DLL interface Modification
//
//#################################################################################
//
//

#ifndef __STMODIF_HPP__
#define __STMODIF_HPP__

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

class CPA_Family;
class CPA_Animation;
class CPA_Action;
class CPA_State;
class TAction_Interface;
tdstTransitionStateInfo;
#include "TAC.h"

///////////////////////////////////////////////////////////////////////////////
// typedef

typedef struct tdstIAInfo_
{
    CPA_State *p_oOwnerState;
    CPA_Action *p_oActionThatInterrupt;
    CPA_State *p_oTransitionalState;
    BOOL bActive;
} tdstIAInfo;

///////////////////////////////////////////////////////////////////////////////
// class State_New

class State_New : public CPA_Modif
{
protected:
    TAction_Interface  *m_p_oParentDLL;
    CPA_Action         *m_p_oAction;
    CPA_State          *m_p_oState;
    CPA_Animation      *m_p_oAnim;
    char               *m_szName;
    BOOL                m_bNormalState;
    CPA_SaveObject      *m_p_oMeca;
public:
    State_New(TAction_Interface *_p_oParentDLL, CPA_Action *_p_oAction,
              CPA_Animation *_p_oAnim, char *_szNewName, BOOL _bNormalState, CPA_SaveObject *_p_oMeca);
    ~State_New();
// actions
    BOOL Do();
    BOOL Undo();
};

///////////////////////////////////////////////////////////////////////////////
// class State_CreateFromAnims

class State_CreateFromAnims : public CPA_Modif
{
protected:
    TAction_Interface       *m_p_oParentDLL;
    CPA_Action              *m_p_oAction;
    CPA_List<CPA_State>     m_oListOfCreatedStates;
    CPA_List<CPA_Animation> m_oListOfAnimations;
    BOOL                    m_bNormalState;
    CPA_SaveObject           *m_p_oMeca;
public:
    State_CreateFromAnims(TAction_Interface *_p_oParentDLL, CPA_Action *_p_oAction);
    ~State_CreateFromAnims();
// init
    void mfn_vAddAnim           (CPA_Animation *_p_oAnim);
    void mfn_vSetNormalState    (BOOL _bNormalState);
    void mfn_vSetMecaCard       (CPA_SaveObject *_p_oMeca);
// actions
    BOOL Do();
    BOOL Undo();
};

///////////////////////////////////////////////////////////////////////////////
// class State_Copy

class State_Copy : public CPA_Modif
{
protected:
    TAction_Interface  *m_p_oParentDLL;
    CPA_Action         *m_p_oAction;
    CPA_State          *m_p_oStateSource;
    CPA_State          *m_p_oStateTarget;
public:
    State_Copy(TAction_Interface *_p_oParentDLL, CPA_Action *_p_oAction,
               CPA_State *_p_oState);
    ~State_Copy();
// actions
    BOOL Do();
    BOOL Undo();
};

///////////////////////////////////////////////////////////////////////////////
// class State_Rename

class State_Rename : public CPA_Modif
{
protected:
    TAction_Interface  *m_p_oParentDLL;
    CPA_Action         *m_p_oAction;
    CPA_State          *m_p_oState;
    char               *m_szNewName;
public:
    State_Rename(TAction_Interface *_p_oParentDLL, CPA_Action *_p_oAction,
                 CPA_State *_p_oState, char *_szNewName);
    ~State_Rename();
// actions
    BOOL Do();
    BOOL Undo();
};

///////////////////////////////////////////////////////////////////////////////
// class State_Delete

class State_Delete : public CPA_Modif
{
protected:
    TAction_Interface  *m_p_oParentDLL;
    CPA_Action         *m_p_oAction;
    CPA_State          *m_p_oState;
    BOOL                m_bIsDefault;
// CPA_Ed_1 Mihaela Tancu begin
    CPA_State          *m_p_oStateNext;	// the next state of the state be delete
    CPA_State          *m_p_Previous;	//the previous state of the state to delete (in the list)
    CPA_State          *m_p_PreviousNext;	//the next state of its previous state
    BOOL                m_bDefault;			//true if the state to delete is default
// CPA_Ed_1 Mihaela Tancu end
public:
    State_Delete(TAction_Interface *_p_oParentDLL, CPA_Action *_p_oAction,
                 CPA_State *_p_oState);
    ~State_Delete();
// actions
    BOOL Do();
    BOOL Undo();
};

///////////////////////////////////////////////////////////////////////////////
// class State_Default

class State_Default : public CPA_Modif
{
protected:
    TAction_Interface  *m_p_oParentDLL;
    CPA_Action         *m_p_oAction;
    CPA_State          *m_p_oNewDefaultState;
public:
    State_Default(TAction_Interface *_p_oParentDLL, CPA_Action *_p_oAction,
                  CPA_State *_p_oNewState);
    ~State_Default();
// actions
    BOOL Do();
    BOOL Undo();
protected:
    BOOL mfn_vSwapDefaultState();
};

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// class State_ModifAnim

class State_ModifAnim : public CPA_Modif
{
protected:
    TAction_Interface  *m_p_oParentDLL;
    CPA_State          *m_p_oState;
    CPA_Animation      *m_p_oNewAnim;
public:
    State_ModifAnim(TAction_Interface *_p_oParentDLL, CPA_State *_p_oState,
                    CPA_Animation *_p_oNewAnim);
    ~State_ModifAnim();
// actions
    BOOL Do();
    BOOL Undo();
protected:
    BOOL mfn_vSwapAnimation();
};

///////////////////////////////////////////////////////////////////////////////
// class State_ModifNextState

class State_ModifNextState : public CPA_Modif
{
protected:
    TAction_Interface  *m_p_oParentDLL;
    CPA_State          *m_p_oState;
    CPA_State          *m_p_oNewNextState;
public:
    State_ModifNextState(TAction_Interface *_p_oParentDLL, CPA_State *_p_oState,
                         CPA_State *_p_oNewNextState);
    ~State_ModifNextState();
// actions
    BOOL Do();
    BOOL Undo();
protected:
    BOOL mfn_vSwapNextState();
};

///////////////////////////////////////////////////////////////////////////////
// class State_ModifSpeed

class State_ModifSpeed : public CPA_Modif
{
protected:
    TAction_Interface  *m_p_oParentDLL;
    CPA_State          *m_p_oState;
    signed char         m_cNewSpeed;
    BOOL                m_bFirstDo;
public:
    State_ModifSpeed(TAction_Interface *_p_oParentDLL, CPA_State *_p_oState, signed char m_cNewSpeed);
    ~State_ModifSpeed();
// actions
    BOOL Do();
    BOOL Undo();
protected:
    BOOL mfn_vSwapSpeed();
};

///////////////////////////////////////////////////////////////////////////////
// class State_ModifReplay

class State_ModifReplay : public CPA_Modif
{
protected:
    TAction_Interface  *m_p_oParentDLL;
    CPA_State          *m_p_oState;
    unsigned char       m_ucNewReplay;
    BOOL                m_bFirstDo;
public:
    State_ModifReplay(TAction_Interface *_p_oParentDLL, CPA_State *_p_oState, unsigned char _ucNewSpeed);
    ~State_ModifReplay();
// actions
    BOOL Do();
    BOOL Undo();
protected:
    BOOL mfn_vSwapReplay();
};

///////////////////////////////////////////////////////////////////////////////
// class State_ModifMechanic

class State_ModifMechanic : public CPA_Modif
{
protected:
    TAction_Interface  *m_p_oParentDLL;
    CPA_State          *m_p_oState;
    CPA_SaveObject      *m_p_oNewMeca;
public:
    State_ModifMechanic(TAction_Interface *_p_oParentDLL, CPA_State *_p_oState,CPA_SaveObject *_p_oNewMeca);
    ~State_ModifMechanic();
// actions
    BOOL Do();
    BOOL Undo();
protected:
    BOOL mfn_vSwapMecaCard();
};

///////////////////////////////////////////////////////////////////////////////
// class State_ModifTransition

class State_ModifTransition : public CPA_Modif
{
public:
    TAction_Interface       *m_p_oParentDLL;
    CPA_State               *m_p_oState;
    tdstTransitionStateInfo  m_stNextTransition;
protected:
private:
public:
    State_ModifTransition( TAction_Interface *_p_oParentDLL, CPA_State *_p_oState, CPA_Action *_p_oAction,
                           tdeTransitionState _eState, CPA_State *_p_oStatoToGo = NULL );
    ~State_ModifTransition();
// actions
    BOOL Do();
    BOOL Undo();
protected:
    BOOL mfn_bMakeDo();
};

///////////////////////////////////////////////////////////////////////////////
// class State_ModifTransitionExtended

class State_ModifTransitionExtended : public CPA_Modif
{
public:
    TAction_Interface					*m_p_oParentDLL;
	CPA_State							*m_p_oCurrentState;
    CPA_List<CPA_State>					 m_oListOfStates;
	CPA_List<tdstTransitionStateInfo>	 m_oListOfTSI;
    CPA_List<tdstTSIState>				 m_oListOfTSIState;
    BOOL                                 m_bEndCreation;
protected:
private:
public:
    State_ModifTransitionExtended( TAction_Interface *_p_oParentDLL, CPA_State *_p_oCurrentState );
    ~State_ModifTransitionExtended();

	void mfn_vAddState		( CPA_State *_p_oState );
    void mfn_vAddTransition	( CPA_Action *_p_oAction, tdeTransitionState _eState, CPA_State *_p_oStatoToGo = NULL );
	void mfn_vEndCreation	( void );
// actions
    BOOL Do();
    BOOL Undo();
protected:
    BOOL mfn_bMakeDo();
};

///////////////////////////////////////////////////////////////////////////////
// class State_SwapDefaultTransitionStatus

class State_SwapDefaultTransitionStatus : public CPA_Modif
{
public:
    TAction_Interface       *m_p_oParentDLL;
    CPA_State               *m_p_oState;
    tdeTransitionState       m_eNextState;
protected:
private:
public:
    State_SwapDefaultTransitionStatus( TAction_Interface *_p_oParentDLL, CPA_State *_p_oState );
    ~State_SwapDefaultTransitionStatus();
// actions
    BOOL Do();
    BOOL Undo();
protected:
    BOOL mfn_bMakeDo();
};


// CPA_Ed_1 Mihaela Tancu begin
///////////////////////////////////////////////////////////////////////////////
// class State_Move
class State_Move : public CPA_Modif
{
protected:
    TAction_Interface  *m_p_oParentDLL;
    CPA_Action         *m_p_oAction;
    CPA_State          *m_p_oPrevStateToMove;	//the previous state in list of the state to move
    CPA_State          *m_p_oStateToMove;		//the state to move
    CPA_State          *m_p_oPrevStateTarget;	//the previous state in the list of the target state before which is inserted the state to move
    CPA_State          *m_p_oStateTarget;		//the target state
    CPA_State          *m_p_oPrevStateToMoveNext;	//next states used for saving and restoring the next states of the states which are changing its next states
    CPA_State          *m_p_oStateToMoveNext;
    CPA_State          *m_p_oPrevStateTargetNext;
    BOOL                m_bDefault;				//true if the state to move is default
    BOOL                m_bDefaultTarget;		//true if the state before which is inserted the state to move is default

public:
    State_Move(TAction_Interface *_p_oParentDLL, CPA_Action *_p_oAction,
               CPA_State *_p_oPrevStateToMove, CPA_State *_p_oStateToMove, 
			   CPA_State *_p_oPrevStateTarget, CPA_State *_p_oStateTarget,
			   CPA_State *_p_oPrevStateToMoveNext, CPA_State *_p_oStateToMoveNext,
			   CPA_State *_p_oPrevStateTargetNext,
			   BOOL _bDefault, BOOL _bDefaultTarget );
    ~State_Move();
	void mfn_vMoveNormalState();  //move the normal state in the list box
	void mfn_vMoveTransitionalState();	//move the transitional state in the list box
	void mfn_vUndoMoveNormalState();	//undo the moving for the normal state
	void mfn_vUndoMoveTransitionalState();	//undo the moving for the transitional state

// actions
    BOOL Do();
    BOOL Undo();
};



class State_CreateFromAnimsMove : public CPA_Modif
{
protected:
    TAction_Interface       *m_p_oParentDLL;
    CPA_Action              *m_p_oAction;
    CPA_List<CPA_State>     m_oListOfCreatedStates;
    CPA_List<CPA_Animation> m_oListOfAnimations;
    BOOL                    m_bNormalState;
    CPA_SaveObject          *m_p_oMeca;
    CPA_State				*m_p_oPrevStateTarget;  // the state before which is inserted the new state
    CPA_State				*m_p_oStateTarget;		// the previous state 
    CPA_State				*m_p_oPrevStateTargetNext;  // the old Next state of the previous state 
	BOOL					m_bDefaultTarget;			// if the target state is default
public:
    State_CreateFromAnimsMove(TAction_Interface *_p_oParentDLL, CPA_Action *_p_oAction,
							  CPA_State *_p_oPrevStateTarget, CPA_State *_p_oStateTarget,
							  CPA_State	*_p_oPrevStateTargetNext);
    ~State_CreateFromAnimsMove();
// init
    void mfn_vAddAnim           (CPA_Animation *_p_oAnim);
    void mfn_vSetNormalState    (BOOL _bNormalState);
    void mfn_vSetMecaCard       (CPA_SaveObject *_p_oMeca);
	void mfn_vDo				(void);  
	void mfn_vDoMany			(int iNumber);
	void mfn_vUndoMany			(int iNumber);
// actions
    BOOL Do();
    BOOL Undo();
};


// CPA_Ed_1 Mihaela Tancu end

class State_ModifCustomBits: public CPA_Modif
{
protected:
    TAction_Interface  *m_p_oParentDLL;
    CPA_State          *m_p_oState;
	unsigned char		m_ucCBNumber;
    BOOL                m_bFirstDo;
public:
    State_ModifCustomBits(TAction_Interface *_p_oParentDLL, CPA_State *_p_oState, unsigned char	_ucCBNumber);
    ~State_ModifCustomBits();
// actions
    BOOL Do();
    BOOL Undo();
protected:
    BOOL mfn_vSwapCB();
};



///////////////////////////////////////////////////////////////////////////////

#endif // __STMODIF_HPP__

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
