
///////////////////////////////////////////////////////////////////////////////
//
// File   : Tools_PFX_Overrides.h
// Author : Andy Southgate
// Date   : 02-Dec-2008
//
// Copyright (C) 2008 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

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

#ifndef __TOOLS_PFX_OVERRIDES_OVERLAY_H__
#define __TOOLS_PFX_OVERRIDES_OVERLAY_H__

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

#include "Core/Asura_Maths.h"
#include "Interface/Asura_Table_Dialog.h"

#include "Misc/Tools_Modal_Overlay.h"

#include "Overrides/Tools_UI_Overrides.h"


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

class Asura_Overlay;
class Tools_PFX_OverridesOverlay_Filters;
class Tools_TableCell_SourceOverride_SourceDialog;

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

////////////////////////////////////////////////////////////////////////////////
// Class        : Tools_Overlay_MaterialResponseOverrides
// Author       : Andy Tate
// Date         : 26-Apr-2007
//
// Description  : Static class used to handle the overlay for overriding the
//				  material-response system.
////////////////////////////////////////////////////////////////////////////////

class Tools_UI_Overrides_PFXSourceInterface : public Tools_UI_Overrides_Interface
{
public:
	Tools_UI_Overrides_PFXSourceInterface() {};

	virtual ~Tools_UI_Overrides_PFXSourceInterface	() {};

	virtual bool ActivateOverrideMap		(Asura_Hash_ID uOverrideMapHash );
	virtual bool CreateNewOverrideMap		(const Asura_String &xOverrideMapName);
	virtual bool CopyOverrideMap			(Asura_Hash_ID uFrom, const Asura_String &xTo);
	virtual bool DeactivateOverrideMap		(Asura_Hash_ID uOverrideMapHash );
	virtual bool DeleteOverrideMap			(Asura_Hash_ID uOverrideMapHash );
	virtual bool RenameOverrideMap			(Asura_Hash_ID uFrom, const Asura_String &xTo );

	virtual bool IsOverrideMapActive		(Asura_Hash_ID uOverrideMapHash);
	virtual bool IsItemOverriden			(Asura_Hash_ID uItemHash);

	virtual bool DoesOverrideMapExist		(Asura_Hash_ID uOverrideMapHash);

	virtual bool GetEntryNames				(Asura_String* &pxNameArray, int &iNumEntries);
	virtual bool GetOverrideNames			(Asura_String* &pxOverrideArray, int &iNumOverrides);
	virtual Asura_Hash_ID GetCurrentOverrideMap();

	virtual bool GetOverrideMapEntry		(Asura_Hash_ID uOverrideMapHash, Asura_Hash_ID uEntryHash, Asura_Hash_ID &uOverriddenEntryHash);
	virtual bool SetOverrideMapEntry		(Asura_Hash_ID uOverrideMapHash, const Asura_String &xFrom, const Asura_String &xTo);
	virtual bool RemoveOverrideMapEntry		(Asura_Hash_ID uOverrideMapHash, Asura_Hash_ID uEntryHash);

	virtual void RefreshAll					();

};

class Tools_UI_Overrides_PFXParticleInterface : public Tools_UI_Overrides_Interface
{
public:
	Tools_UI_Overrides_PFXParticleInterface() {};

	virtual ~Tools_UI_Overrides_PFXParticleInterface	() {};

	virtual bool ActivateOverrideMap		(Asura_Hash_ID uOverrideMapHash );
	virtual bool CreateNewOverrideMap		(const Asura_String &xOverrideMapName);
	virtual bool CopyOverrideMap			(Asura_Hash_ID uFrom, const Asura_String &xTo);
	virtual bool DeactivateOverrideMap		(Asura_Hash_ID uOverrideMapHash );
	virtual bool DeleteOverrideMap			(Asura_Hash_ID uOverrideMapHash );
	virtual bool RenameOverrideMap			(Asura_Hash_ID uFrom, const Asura_String &xTo );

	virtual bool IsOverrideMapActive		(Asura_Hash_ID uOverrideMapHash);
	virtual bool IsItemOverriden			(Asura_Hash_ID uItemHash);

	virtual bool DoesOverrideMapExist		(Asura_Hash_ID uOverrideMapHash);

	virtual bool GetEntryNames				(Asura_String* &pxNameArray, int &iNumEntries);
	virtual bool GetOverrideNames			(Asura_String* &pxOverrideArray, int &iNumOverrides);
	virtual Asura_Hash_ID GetCurrentOverrideMap();

	virtual bool GetOverrideMapEntry		(Asura_Hash_ID uOverrideMapHash, Asura_Hash_ID uEntryHash, Asura_Hash_ID &uOverriddenEntryHash);
	virtual bool SetOverrideMapEntry		(Asura_Hash_ID uOverrideMapHash, const Asura_String &xFrom, const Asura_String &xTo);
	virtual bool RemoveOverrideMapEntry		(Asura_Hash_ID uOverrideMapHash, Asura_Hash_ID uEntryHash);

	virtual void RefreshAll					();

};




class Tools_PFX_Overrides
{
	friend class Tools_TableCell_SourceOverride_SourceDialog;
public:
	Tools_PFX_Overrides();
	~Tools_PFX_Overrides();

	// Public functions...
	void	Initialise		( void );
	void	Shutdown		( void );
	void	ToggleOverlay	( void );
	void	TabsDialog		( const char* const szPFXName, Asura_Tabs_Dialog* const pxTabsDialog, Asura_Vector_2& xOffset, const Asura_Vector_2& xTableSize );

	bool					IsOpen					( void )	const	{ return( m_pxOverlay != NULL ); }


	static	void	RefreshAllSources( void );
	static	void	RefreshAllParticles( void );
	static	void	RefreshSourceCell( Asura_Hash_ID uOverrideMapHash, Asura_Hash_ID uSourceHash );
	static	void	RefreshParticleCell( Asura_Hash_ID uOverrideMapHash, Asura_Hash_ID uParticleHash );

	//Called by the overlay when it gets deleted.
	void OnOverlayDeletion(Asura_Overlay* pxOverlay);

protected:

	static	void	SaveAndClose			( int iUserData )		{ ( ( Tools_PFX_Overrides* ) iUserData )->SaveAndClose(); }
	static	void	Save					( int iUserData )		{ ( ( Tools_PFX_Overrides* ) iUserData )->Save(); }
	
	void	SaveAndClose			( void );
	void	Save					( void );
	void	Close					( void );

	void	CreateOverlay			( void );
	void	AddDialogs				( Asura_Vector_2& xOffset, const Asura_Vector_2& xTableSize );


private:
	// Private variables...
	Asura_Overlay*		m_pxOverlay;							// A pointer to the current overlay.
	Asura_Tabs_Dialog*	m_pxTabsDialog;							// A pointer to the current tabs dialog.

	Asura_Vector_2		m_xOverlayPosition;						// The position of the overlay.


	Tools_UI_Overrides_PFXSourceInterface	m_xSourceOverridesUIInterface;
	Tools_UI_Overrides_PFXParticleInterface	m_xParticleOverridesUIInterface;
	Tools_UI_Overrides						m_xSourceOverridesUI;
	Tools_UI_Overrides						m_xParticleOverridesUI;

	// Private functions...
	Tools_PFX_Overrides  (const Tools_PFX_Overrides& xOther);
	Tools_PFX_Overrides&	operator=	(const Tools_PFX_Overrides& xOther);

	static Tools_PFX_Overrides* m_pxFirst;
	Tools_PFX_Overrides* m_pxNext;

};   // End of class 'Tools_Overlay_MaterialResponseOverrides'.



#endif	// ifndef __TOOLS_PFX_OVERRIDES_OVERLAY_H__

/// End of file. ///
