//////////////////////////////////////////////////////////////////////////////////////
// 
// FILE : Tools_Entity_AdvancedLight.h
//
// AUTHOR : Martin G. Harris
//
// Copyright 2002 Rebellion, All Rights Reserved.
//
//////////////////////////////////////////////////////////////////////////////////////

#ifdef ASURA_USE_PRAGMA_ONCE
    #pragma once
#endif

#ifndef _TOOLS_ENTITY_ADVANCED_LIGHT_H_
#define _TOOLS_ENTITY_ADVANCED_LIGHT_H_

#ifndef ASURA_TARGET_SM3

#include "Tools_Entity_Object.h"

#include "Shapes/Asura_Shapes.h"
#include "Core/Asura_String.h"
#include "Network/Asura_Message.h"
#include "Entity/PhysicalObject/Asura_ServerEntity_AdvancedLight.h"
#include "Entity/Tools_Entity_DestructibleLight.h"

//////////////////////////////////////////////////////////////////////////////////
// Tools_Entity_AdvancedLight											    //
//////////////////////////////////////////////////////////////////////////////////
class Tools_Entity_AdvancedLight : public virtual Tools_Entity_DestructibleLight
{
protected:
	Tools_Entity_AdvancedLight(Asura_ServerEntity_AdvancedLight* pxDestLight);
	virtual ~Tools_Entity_AdvancedLight();
	
	// virtual function overrides
	virtual void PrintInfo(float& x,float& y) {};

	virtual bool DealsInternallyWithActivate() const { return true; }
	virtual void AddOverlayControls(Asura_Overlay* pxNewOverlay, Asura_Vector_2& xOffset);
	virtual void UpdateWhileSelected();
	virtual void Render(void);

	virtual void OnSelection();
	virtual void OnDeselection();

	virtual void Destroy()
	{
		Tools_Entity_DestructibleLight::Destroy();
		s_pxCurrentSelectedAdvLight = NULL;
	}

	virtual const char* GetTypeDescription(void)
	{
		return Tools_Entity_AdvancedLight::s_szLongName;
	}

	virtual void SetPhotonToValuesOfEntity(void);

	virtual void Copy(const Tools_Object*);
	virtual bool CanBeCopied() const {return Type == TOT_Entity_AdvancedLight;}
	virtual Tools_Object* CreateObjectOfThisType() const;

	static const char* GetNamePrefix() { return "AL_"; }
	virtual const char* GetMyNamePrefix() const { return Tools_Entity_AdvancedLight::GetNamePrefix(); }

public :
	
	bool HandlesThisMessage(int messageID)
	{
		if(messageID == ASURA_MSG_ACTIVATE ||
			messageID == ASURA_MSG_DEACTIVATE)
		{
			return true;
		}
		return false;
	}
	
protected:
	/* Data */

	enum FADE_PHASE
	{
		FADE_PHASE_NONE = -1,
			
		FADE_PHASE_UP,
		FADE_PHASE_DOWN,
		FADE_PHASE_ATEND,
		FADE_PHASE_ATSTART,
	};

	enum DialogID
	{
		DialogID_SelectMarker
	};

	
	Asura_ServerEntity_AdvancedLight* m_pxAdvLight;

	// handle flicker/fade and radius change
	float m_fStrobeTimer;
	float m_fCurrentStrobeDuration;
	
	// colour fade 
	float m_fFadeTimer;
	float m_fCurrentFadeDuration;
	FADE_PHASE m_eColourFadePhase;  
	
	// radius change
	float m_fRadiusTimer;
	float m_fCurrentRadiusDuration;
	FADE_PHASE m_eRadiusPhase;  

	// control variables
	bool m_bFlicker;
	bool m_bColourFade;
	bool m_bRangeFade;

	bool m_bPrevFlicker;
	bool m_bPrevColourFade;
	bool m_bPrevRangeFade;


	bool m_bActive;
	bool m_bUseMasterOrient;

	float m_fEndColourR;
	float m_fEndColourG;
	float m_fEndColourB;
	
	float m_fStartColourR;
	float m_fStartColourG;
	float m_fStartColourB;

	// dialogs
	class Asura_Dialog* m_pxMinTimeOffDlg;
	class Asura_Dialog* m_pxMaxTimeOffDlg;
	class Asura_Dialog* m_pxMinTimeOnDlg;
	class Asura_Dialog* m_pxMaxTimeOnDlg;

	class Asura_Dialog* m_pxMinStartColourTimeDlg;
	class Asura_Dialog* m_pxMaxStartColourTimeDlg;
	class Asura_Dialog* m_pxMinFadeDownTimeDlg;
	class Asura_Dialog* m_pxMaxFadeDownTimeDlg;
	class Asura_Dialog* m_pxMinEndColourTimeDlg;
	class Asura_Dialog* m_pxMaxEndColourTimeDlg;
	class Asura_Dialog* m_pxMinFadeUpTimeDlg;
	class Asura_Dialog* m_pxMaxFadeUpTimeDlg;

	class Asura_Dialog* m_pxStartRedDlg;
	class Asura_Dialog* m_pxStartGreenDlg;
	class Asura_Dialog* m_pxStartBlueDlg;

	class Asura_Dialog* m_pxEndRedDlg;
	class Asura_Dialog* m_pxEndGreenDlg;
	class Asura_Dialog* m_pxEndBlueDlg;
	
	class Asura_Dialog* m_pxMinStartRangeTimeDlg;
	class Asura_Dialog* m_pxMaxStartRangeTimeDlg;
	class Asura_Dialog* m_pxMinRangeDownTimeDlg;
	class Asura_Dialog* m_pxMaxRangeDownTimeDlg;
	class Asura_Dialog* m_pxMinEndRangeTimeDlg;
	class Asura_Dialog* m_pxMaxEndRangeTimeDlg;
	class Asura_Dialog* m_pxMinRangeUpTimeDlg;
	class Asura_Dialog* m_pxMaxRangeUpTimeDlg;
	
	class Asura_Dialog* m_pxStartRangeDlg;
	class Asura_Dialog* m_pxEndRangeDlg;

////////////////////
// Static members //
////////////////////
public:
	static void Project_Create(); // Create project specific tools static object.
	
	static void CreateFlickerDlg(void);
	static void CreateColourFadeDlg(void);
	static void CreateRangeFadeDlg(void);
	static void CreateAttachDlg(void);
	static void UpdateAttachDlg();
	static void CreateSelectMasterDlg(void);

	static void SetAttachOffset(void);
	static void SetAttachMarker();
	static void SetMasterObject(void);
	static void UnattachLight(void);

	static void GetAttachMarkerName(Asura_String& xName);
	
protected:
	static const char* const s_szLongName;
	static const char* const s_szShortName;
	static Tools_Entity_AdvancedLight* s_pxCurrentSelectedAdvLight;
	static bool s_bResetCurrentLightPtrOnDeselect;
	static bool s_bModified;

private :
	static Asura_Hashed_List<Tools_Entity_AdvancedLight> s_xList;
};

#endif // #ifndef ASURA_TARGET_SM3

#endif //_TOOLS_ENTITY_ADVANCED_LIGHT_H_
