/**
* Model Vgui
* @version: 8-24-05
* @author Joseph 'Pcjoe' Florencio
*/

#pragma warning (disable:4786)
#pragma warning (disable:4530)

#ifndef MODELVGUI_H
#define MODELVGUI_H
#include <tinyxml.h>

typedef enum
{	MV_LOOPING=0,
	MV_NON_LOOPING,
	MV_SWITCH_ON_FINISH
}MV_ANIMTYPE;

#pragma warning (disable:4786)
#pragma warning (disable:4530)
/*
* Model Vgui Animation
*/
class CMV_Anim
{
public:

	/*
	* Accessors
	*/
	std::string getAnimation( void ) { return m_strAnim; }
	void setAnimation( std::string strAnim ) { m_strAnim = strAnim; }

	int getAnimType( void ) { return m_iAnimType; }
	void setAnimType( int iType ) { m_iAnimType = iType; }

	float getDurration( void ) { return m_flDurration; }
	void setDurration( float flDurration ) { m_flDurration = flDurration; }
private:
	std::string m_strAnim;
	int		m_iAnimType;
	float	m_flDurration;	// Not used for MV_SWITCH_ON_FINISH

};

/*
* Model Vgui Animation Sequence
*/
class CMV_AnimSequence
{
public:
	CMV_AnimSequence();

	// Add Animation
	void addAnimation( std::string strAnim, int iAnimType, float flDurration );

	// Parse XML
	void parseXML( TiXmlElement *pSeq );

	/*
	* Accessors
	*/
	std::vector<CMV_Anim> *getAnimationList( void ) { return &m_AnimationList; }

private:
	std::vector<CMV_Anim> m_AnimationList;
};

/*
* Model Vgui
*/
class CModelVgui
{
public:
	// Constructors
	CModelVgui();
	CModelVgui(std::string strModel);
	CModelVgui(model_s *pModel);

	// Set Model
	void setModel( model_s *pModel );
	void setModel( std::string strModel );

	// Save Last Anim Data
	void saveLastAnimData( void );

	// Play Sequence
	void playSequence( std::string strSequence );

	// Next Anim
	void nextAnim( void );

	// Think
	void Think( void );

	// Add Anim Sequence
	CMV_AnimSequence *addAnimSequence( std::string strName );

	/*
	* Accessors
	*/
	CMDLControl *getModelControl() { return &m_ModelControl; }

	float getLastFrame( void ) { return m_flLastFrame; }
	void setLastFrame( float flFrame ) { m_flLastFrame = flFrame; }

	float getStartSequenceTime( void ) { return m_flStartSeq; }
	void setStartSequenceTime( float flTime ) { m_flStartSeq = flTime; }

	std::string getLastSequence( void ) { return m_strLastSequence; }
	void setLastSequence( std::string strSeq ) { m_strLastSequence = strSeq; }

	int getCurrentAnimInSequence( void ) { return m_iCurrentAnimInSeq; }
	void setCurrentAnimInSequence( int iAnim ) { m_iCurrentAnimInSeq = iAnim; }

	std::string getCurrentSequence( void ) { return m_strCurrentSequence; }
	void setCurrentSequence( std::string strSequence ) { m_strCurrentSequence = strSequence; }

private:
	std::map<std::string,CMV_AnimSequence>	m_AnimSequence;
	float	m_flLastFrame;
	float	m_flStartSeq;
	int		m_iCurrentAnimInSeq;
	std::string	m_strLastSequence;
	std::string	m_strCurrentSequence;
	CMDLControl	m_ModelControl;
};

/*
* Character Form
*/
class CCharacterFormVgui
{
public:
	// Constructor
	CCharacterFormVgui::CCharacterFormVgui();

	// Add Attack
	void addAttack( std::string strAtkName, std::string strAnimSequence );

	// Add Statistic
	void addStatistic( std::string strStName, float flValue );

	// Parse XML
	void parseXML( TiXmlElement *pForm );

	// Play Sequence From Attack
	void playSequenceFromAttack( std::string strAttack );

	// Render
	void Render( void );

	// Get Attacks
	std::map<std::string,std::string> getAttacks( void ) { return m_Attacks; }

	// Get Statistics
	std::map<std::string,float> getStatistics( void ) { return m_Statistics; }

	/*
	* Accessors
	*/
	CModelVgui *getModel( void ) { return &m_Model; }

	std::string getName( void ) { return m_strName; }
	void setName( std::string strName ) { m_strName = strName; }

	vec3_t getCameraPosition( void ) { return m_vecCameraPos; }
	void setCameraPosition( vec3_t vecCam ) { m_vecCameraPos = vecCam; }

	vec3_t getCameraAngle( void ) { return m_vecCameraAngle; }
	void setCameraAngle( vec3_t vecAngle ) { m_vecCameraAngle = vecAngle; }

private:
	CModelVgui	m_Model;	// Model
	std::string	m_strName;	// Name
	std::map<std::string,float>	m_Statistics;	// Statistics, name of stat, value of stat
	std::map<std::string,std::string>	m_Attacks;	// Attack List and associated anim sequences
	vec3_t	m_vecCameraPos;	// Camera Position
	vec3_t	m_vecCameraAngle;
};

/*
* Character
*/
class CCharacterVgui
{
public:
	// Default constructor
	CCharacterVgui();
	// Constructor that automatically parses
	CCharacterVgui( std::string strClass );

	// Parse XML
	void parseXML(std::string strFile);

	// Add Form
	CCharacterFormVgui *addForm( void );

	// Get Form by name
	CCharacterFormVgui *getForm( std::string strName );

	/*
	* Accessors
	*/
	std::list<CCharacterFormVgui>	*getForms( void ) { return &m_Forms; }

	std::string getName( void ) { return m_strName; }
	void setName( std::string strName ) { m_strName = strName; }
private:
	std::list<CCharacterFormVgui>	m_Forms;
	std::string m_strName;
};

#endif