
///////////////////////////////////////////////////////////////////////////////
//
// File   : Tools_Overlay_FacialAnimation_EditFaceType.h
// Author : Andy Tate
// Date   : 13-Jun-2008
//
// Copyright (C) 2008 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

#ifdef ASURA_USE_PRAGMA_ONCE
	#pragma once
#endif   // ifdef ASURA_USE_PRAGMA_ONCE

#ifndef __TOOLS_OVERLAY_FACIALANIMATION_EDITFACETYPE_H__
#define __TOOLS_OVERLAY_FACIALANIMATION_EDITFACETYPE_H__

#if defined(ASURA_USE_FACIAL_ANIMATION_SYSTEM)

////////////////////////////////////////////////////////////////////////////////
// Include files...
////////////////////////////////////////////////////////////////////////////////

#include "Interface/Asura_Overlay.h"
#include "Interface/Asura_Table_Dialog.h"


////////////////////////////////////////////////////////////////////////////////
// Forward class declarations...
////////////////////////////////////////////////////////////////////////////////

class Asura_List_Dialog;
class Tools_FacialAnimation_FaceType;
class Tools_FacialAnimation_FaceType_MuscleGroup;


////////////////////////////////////////////////////////////////////////////////
// Class declaration...
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
// Class        : Tools_Overlay_FacialAnimation_EditFaceType
// Author       : Andy Tate
// Date         : 13-Jun-2008
//
// Description  : Class used for the overlay to edit face-type properties.
////////////////////////////////////////////////////////////////////////////////

class Tools_Overlay_FacialAnimation_EditFaceType : public Asura_Overlay
{
public:
	// Public functions...
	static void	CreateOverlay(const bool bNewType, const Asura_String& xPath, Tools_FacialAnimation_FaceType& xType);
	static void	CloseOverlay(void);

	static bool	OverlayExists(void)		{ return(s_pxThis != NULL); }

	// Accessor functions...
	Tools_FacialAnimation_FaceType_MuscleGroup*	FindMuscleGroup(const u_int uIndex);
	void										SetAsChanged(void);

	Tools_FacialAnimation_FaceType&			GetFaceType(void)		{ return(m_xType); }
	const Tools_FacialAnimation_FaceType&	GetFaceType(void) const	{ return(m_xType); }

	const char*	GetPhonemeName(const u_int uIndex) const	{ return(m_pszPhonemeNames[uIndex]); }


protected:
	// Protected variables...

	// Protected functions...
	Tools_Overlay_FacialAnimation_EditFaceType(const bool bNewType, const Asura_String& xPath, Tools_FacialAnimation_FaceType& xType);
	virtual ~Tools_Overlay_FacialAnimation_EditFaceType();

	void	UpdateMuscleGroups(void);
	void	UpdatePhonemes(void);
	void	UpdateMappings(void);

	void	AddOverlayItems(Asura_Vector_2& xOffset);

	// Table-dialogue cell creation functions...
	static Asura_TableCell_Dialog*	CreateMuscleGroupTableCell(Asura_Table_Dialog& xTableDialog, const Asura_Vector_2& xOffset, const Asura_Vector_2& xMinCellSize, const u_int uRow, const u_int uColumn, void* const pUserData);
	static Asura_TableCell_Dialog*	CreateMappingTableCell(Asura_Table_Dialog& xTableDialog, const Asura_Vector_2& xOffset, const Asura_Vector_2& xMinCellSize, const u_int uRow, const u_int uColumn, void* const pUserData);

	// Event functions...
	static void	OnAddMuscleGroupSelected(void);
	static void	OnDeleteMuscleGroupSelected(void);
	static void	OnMoveSelectedMuscleGroupUp(void);
	static void	OnMoveSelectedMuscleGroupDown(void);

	static void	OnAddPhonemeSelected(void);
	static void	OnDeletePhonemeSelected(void);
	static void	OnMoveSelectedPhonemeUp(void);
	static void	OnMoveSelectedPhonemeDown(void);

	static void	OnSaveAndCloseSelected(void);

	// Query functions...
	static bool	HasMuscleGroupCurrentlySelected(void);
	static bool	CanMoveSelectedMuscleGroupUp(void);
	static bool	CanMoveSelectedMuscleGroupDown(void);

	static bool	HasPhonemeCurrentlySelected(void);
	static bool	CanMoveSelectedPhonemeUp(void);
	static bool	CanMoveSelectedPhonemeDown(void);


private:
	// Private typedefs...
	typedef Asura_Overlay PARENT;

	// Private enumerated types...
	enum MuscleGroupColumn
	{
		MGC_NAME,
		MGC_CONTROL_TYPE,

		MAX_MUSCLE_GROUP_COLUMNS
	};

	enum MappingColumn
	{
		MC_PHONEME,
		MC_FACE_POSE,

		MAX_MAPPING_COLUMNS
	};

	// Private variables...
	Asura_String					m_xPath;					// The name of the face-file we're using.
	Tools_FacialAnimation_FaceType&	m_xType;					// A reference to the face-type we're editing.

	bool							m_bChanged;					// Flag to say whether any data has changed on this overlay.

	int								m_iNumMuscleGroups;			// The number of muscle-groups in the list.
	char const**					m_pszMuscleGroupNames;		// Pointer to an array of names for the muscle-groups.
	Asura_Table_Dialog*				m_pxMuscleGroupDialogue;	// The muscle-group dialogue to be used.

	int								m_iCurrentPhoneme;			// The currently selected phoneme.
	int								m_iNumPhonemes;				// The number of phonemes in the list.
	char const**					m_pszPhonemeNames;			// Pointer to an array of names for the phonemes.
	Asura_List_Dialog*				m_pxPhonemeDialogue;		// The phoneme dialogue to be used.

	Asura_Table_Dialog*				m_pxMappingDialogue;		// The dialogue used to map phonemes to animations.

	// Static variables...
	static const char*									s_aszMuscleGroupColumnNames[MAX_MUSCLE_GROUP_COLUMNS];	// Array of names for the columns in the muscle-group table.
	static const char*									s_aszMappingColumnNames[MAX_MAPPING_COLUMNS];			// Array of names for the columns in the mapping table.
	static Tools_Overlay_FacialAnimation_EditFaceType*	s_pxThis;												// We only ever create a single instance of this overlay.

	// Private functions...
	Tools_Overlay_FacialAnimation_EditFaceType(void);
	Tools_Overlay_FacialAnimation_EditFaceType(const Tools_Overlay_FacialAnimation_EditFaceType& xOther);

	Tools_Overlay_FacialAnimation_EditFaceType&	operator=(const Tools_Overlay_FacialAnimation_EditFaceType& xOther);

};   // End of class 'Tools_Overlay_FacialAnimation_EditFaceType'.



////////////////////////////////////////////////////////////////////////////////
// Class        : Tools_TableCell_FaceTypeSelectFacePose_Dialog
// Author       : Andy Tate
// Date         : 13-May-2008
//
// Description  : Class used to create the dialogue for a particular cell in 
//				  the face-type table for facial-animations.
////////////////////////////////////////////////////////////////////////////////

class Tools_TableCell_FaceTypeSelectFacePose_Dialog : public Asura_TableCell_Dialog
{
public:
	// Public functions...
	Tools_TableCell_FaceTypeSelectFacePose_Dialog(Asura_Table_Dialog& xTableDialogue, const Asura_Vector_2& xOffset, const Asura_Vector_2& xMinCellSize, const u_int uRow, const u_int uColumn, Tools_Overlay_FacialAnimation_EditFaceType& xEditFaceTypeOverlay);
//	virtual ~Tools_TableCell_FaceTypeSelectFacePose_Dialog();

	// Overridden functions...
	virtual int	Compare(const Asura_TableCell_Dialog& xOther) const	{ return(0); }


protected:
	// Protected variables...
	Tools_Overlay_FacialAnimation_EditFaceType&	m_xEditFaceTypeOverlay;	// A reference to the overlay we're a part of.
	Tools_FacialAnimation_FaceType&				m_xFaceType;			// A reference to the muscle-group to use.
	const char*									m_szPhonemeName;		// The name of the phoneme we're to select the mapping for.
	Asura_Function_Dialog*						m_pxFacePoseDialogue;	// A pointer to the dialogue used to select a face-pose.

	// Protected functions...
	static void	OnSelectFacePose(int iUserData);


private:
	// Private typedefs...
	typedef Asura_TableCell_Dialog PARENT;

	// Private variables...

	// Private functions...
	Tools_TableCell_FaceTypeSelectFacePose_Dialog(void);
	Tools_TableCell_FaceTypeSelectFacePose_Dialog(const Tools_TableCell_FaceTypeSelectFacePose_Dialog& xOther);

	Tools_TableCell_FaceTypeSelectFacePose_Dialog&	operator=(const Tools_TableCell_FaceTypeSelectFacePose_Dialog& xOther);

};   // End of class 'Tools_TableCell_FaceTypeSelectFacePose_Dialog'.

#endif	//defined(ASURA_USE_FACIAL_ANIMATION_SYSTEM)

#endif   // ifndef __TOOLS_OVERLAY_FACIALANIMATION_EDITFACETYPE_H__


/// End of file. ///
