
#pragma once

#include "MW4.hpp"
#include "Sensor.hpp"
#include "hudcomp.hpp"

namespace MechWarrior4
{

	class HUDWeapon;
	class HUDReticle : public HUDComponent
	{
	protected:

		typedef HUDComponent inherited;

		void DrawImplementation(void);

		Stuff::Time m_RotateTime;
		Stuff::Scalar zrot;
		DWORD m_LockColor2[3];
		int m_ReticleAlignment;
		Stuff::Scalar scalexy;
		int targeting;
		Stuff::Scalar rotclockwise;
		Stuff::Scalar rotcounterclock;
		int isReticleLocked;
		int isReticleLockedLRM;
		int isReticleLockedMRM;
		int isReticleLockedSRM;
		int isReticleLockedSSRM;
		HUDText *m_ReticleRangeText,*m_ReticleName,*m_isReticleLockedLRMText,*m_isReticleLockedMRMText,*m_isReticleLockedSRMText,*m_isReticleLockedSSRMText;
		Stuff::Scalar m_ReticleRange;
		HUDWeapon *m_Weapons;
		Stuff::Time m_HitTime;
		DWORD m_LeftHitColor,m_RightHitColor,m_ForwardHitColor,m_RearHitColor;
		DWORD m_LeftCenterColor,m_RightCenterColor,m_ForwardCenterColor,m_RearCenterColor;

		DWORD m_LockAlpha,m_AnimLockColor,m_AnimLockColorLRM,m_AnimLockColorSRM;

		void AdjustColor (DWORD& color,DWORD alpha);

	public:
		HUDReticle();
		~HUDReticle();
		virtual void Update (Stuff::Time till);
		virtual void Reset (void);
		
		void ReticleAlignment (int value)
		{ Verify (value>=0 && value<=2); m_ReticleAlignment = value; }
		void ReticleRange (Stuff::Scalar value)
		{
			char text[50];
			int temp = (int) value;
			sprintf (text,"%dm",temp);
			m_ReticleRangeText->UpdateText (text);
			m_ReticleRange = value;
		}
// MSL 5.02 SubSystems
		Stuff::Scalar GetReticleRange (void)
		{
			return m_ReticleRange;
		}
		void ReticleName (char *name)
		{ m_ReticleName->UpdateText (name); }

		void LeftHit (void);
		void RightHit (void);
		void ForwardHit (void);
		void RearHit (void);
		void AllHit (void);

		void Targeting (int value)
		{ targeting = value; }
		void IsReticleLocked (int value)
		{
			if (value && !isReticleLocked)
			{
				targeting = true;
				m_LockAlpha = 100;
				scalexy = 6.0f;
			}
			isReticleLocked = value;
		}
		void IsReticleLockedLRM (int value)
		{
			if (value && !isReticleLockedLRM)
			{
				targeting = true;
				m_LockAlpha = 100;
				scalexy = 6.0f;
			}
			isReticleLockedLRM = value;
		}
		void IsReticleLockedMRM (int value)
		{
			if (value && !isReticleLockedMRM)
			{
				targeting = true;
				m_LockAlpha = 100;
				scalexy = 6.0f;
			}
			isReticleLockedMRM = value;
		}
		void IsReticleLockedSRM (int value)
		{
			if (value && !isReticleLockedSRM)
			{
				targeting = true;
				m_LockAlpha = 100;
				scalexy = 6.0f;
			}
			isReticleLockedSRM = value;
		}
		void IsReticleLockedSSRM (int value)
		{
			if (value && !isReticleLockedSSRM)
			{
				targeting = true;
				m_LockAlpha = 100;
				scalexy = 6.0f;
			}
			isReticleLockedSSRM = value;
		}
	};

}

