//
// Tools_Phonon_Object.h
//
// Created by Richard Rice - 05/06/2002
// 
// Copyright (C) 2002 Rebellion, All Rights Reserved.
//

#ifdef ASURA_USE_PRAGMA_ONCE
    #pragma once
#endif

#ifndef _TOOLS_PHONON_OBJECT_H_
#define _TOOLS_PHONON_OBJECT_H_

// Asura
#include "Network/Asura_Guid.h"
#include "Sound/Asura_Phonon.h"
// Tools
#include "Misc/Tools_MessageLog.h"
#include "Objects/Tools_Object.h"

class Asura_Sound_Event;

class Tools_Phonon_Object : public Tools_Object
{
	public :
		Tools_Phonon_Object(const Asura_Phonon* pxPhonon);
		~Tools_Phonon_Object();

		void UpdateInitialValues();

		Asura_Phonon* GetPhonon() const;

		//virtual function overides
		void UpdatePositionInAsuraData(bool /*updateLinkedObjects*/);

		void Render();		
		const char* GetName();
		const char* GetTypeDescription(){return "Phonon";}
		void Destroy();
		void OnSelection();
		void OnDeselection();
		void OnReselection();
		void UpdateWhileSelected();
		void Update();
		void CreatePhononPropertiesOverlay();
		void UpdateIfChanged();
	 	virtual void PrintInfo(float& x,float& y);

		void UpdateUserPhononName();

		void UpdateName();

		//copy/paste support
		virtual void Copy(const Tools_Object* pxObject);
		virtual bool CanBeCopied() const {return true;}
		virtual Tools_Object* CreateObjectOfThisType() const;
		void GenerateCopiedName(const Tools_Phonon_Object* pxFromObject);

		static Tools_Phonon_Object* GetSelectedObject() {return s_pxSelectedObject;}


		static void SelectSound();
		bool PickSound();

		static void _PlaySound();
		void PlaySound();

		static void  StopTestSound();


		static void _EditBoundingBox();
		void EditBoundingBox();

		static void _EditRetriggerBoundingBox();
		void EditRetriggerBoundingBox();

		static bool IsEnabled_UseRetriggerRadius();
		static bool IsEnabled_RetriggerRadius();
		static bool IsEnabled_UseRetriggerBoundingBox();
		static bool IsEnabled_RetriggerBoundingBox();

		static void _Rename();
		void Rename();

		virtual bool IsSelectable();
		virtual bool IsHidden();

		static Tools_Phonon_Object* GetPhononObjectFromSoundGuid(Asura_Guid);

		virtual bool GetParameter(Asura_Hash_ID uParamID,class Tools_Parameter* pxParam) const;
		virtual bool SetParameter(Asura_Hash_ID uParamID,const class Tools_Parameter* pxParam);

		Asura_Guid GetGuid() const;
        bool AcquireGuid();
        // (MH - 19.11.2002) the phonon handles these messages via Asura_ServerEntity_SoundController
        bool HandlesThisMessage(int messageID);

		static void RemoveDudSoundControllers();

		static void SoundEventDeleted(const Asura_Sound_Event* pxEvent);
		static void SoundEventRenamed(Asura_Hash_ID uOldHash,Asura_Hash_ID uNewHash);
		static void HandleSoundEventReload();

		bool BelongsToMissionFile() const;
		bool CanSaveFile() const;
		void SetModified();

		Asura_Guid m_uSoundGuid;//sound guid (not an entity guid)
		Asura_Phonon m_xUserPhonon;

		bool m_bChanged;
		bool m_bOverlayNeedsRecreating;
        bool m_bStartsActiveChanged;

		float m_fPS2Frequency;
		bool m_bPS2FrequencyModified;

		Asura_String m_xName;

		//Flags to be set by the overlay when the minimum or maximum entries are modified
		bool m_bMinimumModified;
		bool m_bMaximumModified;

		unsigned m_uVolumeEditID;

		unsigned m_uRetriggerVolumeEditID;

		//for testing the current phonon
		static Asura_Phonon s_xTestPhonon;
		static Asura_Handle s_iTestPhononHandle;


	   enum DialogID
		{
			DialogID_HumanSound,
		};

	private :
		void MoveBoundingBoxes(const Asura_Vector_3& xOffset);

		//for detecting movement of the bounding boxes ,and moveing the phonon to match
		bool m_bDontDisplaceBoundingBox;

		bool m_bDontDisplaceRetriggerBoundingBox;
	

		static Tools_Phonon_Object* s_pxSelectedObject;
	
		class Tools_Default_VolumeGroupEdit_Controller* m_pxClipVolumeController;


};

class Tools_MessageLogAction_Phonon : public Tools_MessageLogAction
{
public :
	Tools_MessageLogAction_Phonon(const Asura_Phonon* pxPhonon);
	void Execute();
private :
	Asura_Guid m_uGuid;
};


#endif //_TOOLS_PHONON_OBJECT_H_
