
///////////////////////////////////////////////////////////////////////////////
//
// File   : AVP_Actor_HUDHandler.cpp
// Author : Chris Wallace
// Date   : 2-Nov-2006
//
// Copyright (C) 2006 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

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

#ifndef __AVP_ACTOR_HUDHANDLER_H__
#define __AVP_ACTOR_HUDHANDLER_H__

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

#include "Core/Asura_PlatformBasics.h"
#include "Camera/Asura_Camera.h"

#include "Blueprint/AVP_Blueprint_HashIDs.h"


////////////////////////////////////////////////////////////////////////////////
// Defines
////////////////////////////////////////////////////////////////////////////////
#define	MAX_HUD_HEALTH_ELEMENTS 5


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

class Asura_Blueprint;
class Asura_FSFX_Handler;
class Asura_Photon;
class AVP_ClientEntity_Actor;
class AVP_EntityDamage_ApplyToEntity;


////////////////////////////////////////////////////////////////////////////////
// Class        : AVP_Actor_HUDHandler
// Author       : Chris Wallace
// Date         : 2-Nov-2006
//
// Description  : 
////////////////////////////////////////////////////////////////////////////////

class AVP_Actor_HUDHandler
{
public:

	// Public enumerated types...
	enum FSFXType
	{
		FSFX_TARGETEDJUMP,
		FSFX_SCOPEDRIFLE,
		FSFX_LOWHEALTH,
		FSFX_MELEEJUMP,
		FSFX_FOCUS,
		FSFX_STIM,
		FSFX_ACIDDAMAGE,
		FSFX_DAMAGE,
		FSFX_DEATH,
		FSFX_SPRINT,
		FSFX_ZOOM,

		NUM_FSFX_TYPES
	};

	//Changed to mash all states together for consistency and reduce clutter. FS 1st May 2009
	enum HUD_STATE
	{
		HUD_NOT_VISIBLE,
		HUD_STAT_LOSS,
		HUD_STAT_GAIN,
		HUD_RELOAD_WEAPON,
		HUD_PICKUP_WEAPON,
		HUD_CHANGE_WEAPON,
		HUD_USE_STIM,
		HUD_USE_FOCUS,
		HUD_RESUME_GAME,

		NUM_HUD_STATES
	};

	// Public functions...
	explicit AVP_Actor_HUDHandler	(AVP_ClientEntity_Actor& xClient);
	virtual ~AVP_Actor_HUDHandler	();

	// Update HUD function...
	virtual	void	Update( const AVP_ClientEntity_Actor& xClient );
	virtual	void	Render( const AVP_ClientEntity_Actor& xClient );	
	virtual	void	Reset ();

	// Vision-mode functions...
	void			SetVisionMode(const AVP_ClientEntity_Actor& xClient, const Asura_Hash_ID uNewBlueprintHash, const bool bInstant);
	Asura_Hash_ID   GetVisionMode() const { return m_uVisionModeBlueprintHash; }

	void			SetTorchHDROverride( const Asura_Hash_ID uBlueprintHash );
	void			UnSetTorchHDROverride();

	// Event functions...
	virtual void	OnApplyHealth(const float fHealthIncrement);
	virtual void 	OnApplyDamage( const AVP_EntityDamage_ApplyToEntity& xDamage );
	virtual void	OnDeath(const AVP_EntityDamage_ApplyToEntity& xDamage);

	virtual void	OnBeginFalling(void);
	virtual void	OnBeginLanding(void);

	virtual void 	OnBeginMovingFast(void);
	virtual void 	OnEndMovingFast(void);

	virtual void	OnBeginZoomingIn(const u_int uZoomLevel);
	virtual void	OnBeginZoomingOut(const u_int uZoomLevel);
	virtual void	OnEndZooming(const u_int uZoomLevel);

	virtual void    OnReceiveObjective (const Asura_Guid uObjectiveGuid );
	virtual void    OnCompleteObjective(const Asura_Guid uObjectiveGuid );
	
	virtual void	OnBeginCutscene();
	virtual void	OnEndCutscene();

	// Accessor functions...
	static bool	IsHUDEnabled(void);
	static void	SetHUDEnabled(const bool bSet);


	static Asura_CameraData::HDRSettings& GetTorchHDRSettings() { return s_xTorchHDRSettings; }
	static bool  IsTorchOverride() { return s_bTorchOverride; }
	static void  SetAllowTorchOverride(bool bSet) {s_bAllowTorchOverride = bSet;}
	static bool  IsAllowTorchOverride() {return s_bAllowTorchOverride;}

	// accessor function for the dynamic HUD sub level page. 
	static void SetHUDSubLevelLoaded( bool bLoaded ) { s_bHUDSubLevelLoaded = bLoaded; }
	static bool GetHUDSubLevelLoaded() { return s_bHUDSubLevelLoaded; }
	static void SetHUDSubLevelHashID( u_int uHashID ) { s_uCurrentHUDSubLevelPage = uHashID; }
	static u_int GetHUDSubLevelHashID() { return s_uCurrentHUDSubLevelPage; }

	static bool* GetShowWeaponSelectorConsoleVarPtr();

	static const Asura_Blueprint* GetInventoryBlueprint(const Asura_Hash_ID uItemHash);

	static void  SetShowObjectiveArrow( bool bTrue ) { s_bShowObjectiveArrow = bTrue; }
	static void  SetClampedAngle( float fAngle ){ s_fClampedAngleToObjective = fAngle; }

	static void  SetCheckpointReached(){ s_bCheckpointReached = true; }
	static void  SetShowAudioDiaryPicked(){ s_bShowAudioDiaryPicked = true; }

	static void  SetHUDHealthState( u_int uHUDHealthState );
	static void	 SetHUDAmmoState( u_int uHUDAmmoState );
	static void  SetHUDEnergyState( u_int uHUDEnergyState );

	static bool	 ConsoleCmd_GetPlayerName( bool bHelp );
	
	// helper functions
	void PlayHitByAcidPFX();

	// Camera photons, used by grapples.
	u_int ApplyCameraPhoton(const Asura_Vector_3& xCameraOffset, float fRed, float fGreen, float fBlue, float fFadeInTime, float fFadeOutTime, float fPower, float fRange);
	void FinishCameraPhoton(u_int uPhotonID);

#if defined(ASURA_TOOLS)
    static bool IsCnsl_bForceFixedExposure();
#endif

#if defined(ASURA_TOOLS)
	static bool IsForceFixedExposure();
#endif
// Create console vars
#if defined(ASURA_SUPPORT_COMMAND_CONSOLE)
	static void CreateConsoleVars();
	static void CreateConsoleCommands();
#endif	// defined(ASURA_SUPPORT_COMMAND_CONSOLE)	

protected:
	// Protected functions...
	virtual void UpdateHealth( const AVP_ClientEntity_Actor& xClient );
	virtual void UpdateFOVModifiers( const AVP_ClientEntity_Actor& xClient );
	// Blueprint accessor functions...
	const Asura_Blueprint* GetActorBlueprint(void) const;
	const Asura_Blueprint* GetPlayerBlueprint(void) const;

	// HUD-specific effect functions...
	static bool	PlaySoundEvent(const Asura_Blueprint& xBlueprint, const Asura_Hash_ID uParameterHash, Asura_Handle* piHandle);
	bool	PlaySoundEvent(const Asura_Hash_ID uSoundParameterHash, Asura_Handle* piHandle);
	void	StopSoundEvent(Asura_Handle& iHandle);

	bool	SetFSFXValue(const FSFXType eType, const Asura_Hash_ID uFSFXParameterHash, const float fValue, const float fTime);
	bool	SetFSFXValue(const FSFXType eType, const Asura_Hash_ID uFSFXParameterHash, const Asura_Hash_ID uValueParameterHash, const Asura_Hash_ID uTimeParameterHash);
	bool	SetFSFXAttackSustainDecayValue(const FSFXType eType, const Asura_Hash_ID uFSFXParameterHash, const Asura_Hash_ID uStrengthParameterHash, const Asura_Hash_ID uAttackDurationParameterHash, const Asura_Hash_ID uSustainDurationParameterHash, const Asura_Hash_ID uDecayDurationParameterHash);
	bool	ResetFSFXValue(const FSFXType eType, const Asura_Hash_ID uFSFXParameterHash);

	// Multiplayer
	void	RenderMultiplayerHUD( const AVP_ClientEntity_Actor& xClient );

	static bool ConsoleCmd_ObjectiveList  ( u_int uElementIndex, bool bInterrogate, bool bHelp );
	static bool ConsoleCmd_MissionTimeHours( u_int uElementIndex, bool bInterrogate, bool bHelp );
	static bool ConsoleCmd_MissionTimeMinutes( u_int uElementIndex, bool bInterrogate, bool bHelp );
	static bool ConsoleCmd_MissionTimeSeconds( u_int uElementIndex, bool bInterrogate, bool bHelp );

	// Protected variables...
	static bool s_bHUDEnabled;

	Asura_Vector_2 m_xNoHealthPos;
	Asura_Vector_2 m_xFullHealthPos;

	//Screen values
	float m_fLeft;
	float m_fTop;

	float m_fRight;
	float m_fBottom;

	float m_fWidth;
	float m_fHeight;

	Asura_Hash_ID	m_uVisionModeBlueprintHash;

	Asura_Handle	m_iVisionModeChangeSoundHandle;
	Asura_Handle	m_iVisionModeLoopSoundHandle;
	Asura_Handle	m_iAdrenalineLoopHandle;
	Asura_Handle	m_iBreathingLoopHandle;

	u_int m_uMaxNumHealthBlocks;
	float m_fHealthPerBlock;

	//Text Rendering
	float m_fIncrement;
	float m_fTextScale;
	u_int m_uTextColour;
	u_int m_uTextFormat;

	float m_fY;					
	float m_fX;	

	float m_fDamageFadeTime;
	float m_fHealthFadeTime;
	float m_fHitByPlasmaFadeTime;
	float m_fHitByPlasmaTimer;
	float m_fHitByAcidFadeTime;
	float m_fHitByAcidTimer;
	float m_fObjectiveTimer;
	float m_fCheckpointTimer;
	float m_fAudioDiaryTimer;
	float m_fHUDStateFadeTime;

	float m_fSprintFOVDecrease;
	float m_fSprintFovFadeInTime;
	float m_fSprintFovFadeOutTime;
	float m_fTargetSprintFOV;
	float m_fCurrentSprintFOV;

	AVP_ClientEntity_Actor&	m_xOwner;
	Asura_Guid						m_uOwnerGuid;
	
	int   m_iOverlayTexture; // Texture for the triangles on the HUD Background
	u_int m_uCurrOverlay;    // Cycle through overlay files - 01, 02, 03...

	const Asura_UnicodeChar* m_wszInteractSpear;
	const Asura_UnicodeChar* m_wszInteractSpearEnemy;

	struct CameraPhotonData
	{
		Asura_Photon* m_pxPhoton;
		Asura_Vector_3 m_xCameraOffset;
		float m_fRed;
		float m_fGreen;
		float m_fBlue;
		float m_fFadeInRate;
		float m_fFadeOutRate;
		float m_fRange;
		float m_fPower;
		float m_fCurrentFade;
		bool m_bRunning;
	};
	enum { MAX_HUD_PHOTONS = 4, };

	CameraPhotonData m_axHUDPhotons[MAX_HUD_PHOTONS];

	static Asura_CameraData::HDRSettings s_xTorchHDRSettings;
	static bool  s_bTorchOverride;
	static bool  s_bAllowTorchOverride;
	static bool  s_bCheckpointReached;
	static Asura_Guid s_uObjectiveToShow;

	static float s_fWeaponAccuracy; // Accuracy for weapons, value from 0-1. 0 being the most accurate state
	static float s_fClampedAngleToObjective;

	static int s_iMissionTimeHours;
	static int s_iMissionTimeMinutes;
	static int s_iMissionTimeSeconds;

	static u_int s_uHUDHealthState;
	static u_int s_uHUDAmmoState;
	static u_int s_uHUDEnergyState;

	static float s_fHealthStateTimer;
	static float s_fAmmoStateTimer;
	static float s_fEnergyStateTimer;

private:
	// Private functions...
	AVP_Actor_HUDHandler  (const AVP_Actor_HUDHandler& xOther);

	AVP_Actor_HUDHandler&	operator=	(const AVP_Actor_HUDHandler& xOther);

	// HUD sub-level data, held here because the hash id is dynamic dependent on the level loaded. 
	static bool		s_bHUDSubLevelLoaded;
	static u_int	s_uCurrentHUDSubLevelPage;


	// Values in this block can be modified from Console.
	static bool 	s_bCaution;
	static bool 	s_bShowDamageEffect;
	static bool 	s_bShowHealthEffect;
	static bool		s_bShowWeaponSelector;
	static bool 	s_bShowHealth[ MAX_HUD_HEALTH_ELEMENTS ];
	static float 	s_fHealthParametric[ MAX_HUD_HEALTH_ELEMENTS ];
	static bool 	s_bShowObjective;
	static bool 	s_bShowObjectiveAdded;
	static bool 	s_bShowObjectiveCompleted;
	static bool 	s_bShowObjectiveArrow;
	static bool 	s_bShowAudioDiaryPicked;
	static bool		s_bShowHitByPlasma;
	static bool		s_bShowHitByAcid;
	static bool		s_bShowWeaponAccuracy;

	bool			m_bInCutscene;
	float			m_fDesiredFSFXValue[ NUM_FSFX_TYPES ];
	Asura_Hash_ID	m_uCurrentFSFXParameterHash[ NUM_FSFX_TYPES ];

};   // End of class 'AVP_Actor_HUDHandler'.


#endif   // ifndef __AVP_ACTOR_HUDHANDLER_H__


/// End of file. ///
