#pragma once

#include "hudcomp.hpp"
#include "missionreview.hpp"

#if !defined(NO_MR)
namespace NMissionReview
{
	extern MissionReview *m_ReviewLog;
	extern Stuff::Scalar m_CurrentTime;
	extern Stuff::Scalar m_LoadedTime;
	extern Stuff::Scalar m_TotalTime;
	extern Stuff::Scalar m_SampleRate;
	extern Stuff::Scalar m_PlayBackRate;		
	extern Stuff::Time m_LastTime;					// last frame time for playback
	extern char m_ReviewMapTexture[128];

	class CReviewMap : public HUDComponent
	{
	protected:

		typedef HUDComponent inherited;

		void DrawImplementation(void);

	public:
		CReviewMap();
		~CReviewMap();
	};
	
	class CReviewMech : public HUDComponent
	{
	protected:

		typedef HUDComponent inherited;
		int m_MechID;
		Scalar curx,cury;
		Scalar rot;
		bool m_Fired,m_Hit;
		DWORD m_DamageColors[6];
		int m_DamageValues[11];
		HUDText *m_Name;
		int m_Score1,m_Score2,m_Score3;
		HUDText *m_ScoreText1,*m_ScoreText2;

		void DrawImplementation(void);

	public:
		CReviewMech(int id);
		~CReviewMech();
		void SetMechCoord (Scalar x,Scalar y)
		{ curx = x; cury = y; }
		void GetMechCoord (Scalar& x,Scalar& y)
		{ x = curx; y = cury; }
		void SetMechRot (Scalar r)
		{ rot = r; }
		void SetMechFired (bool fire)
		{ m_Fired = fire; }
		void SetMechHit (bool hit)
		{ m_Hit = hit; }
		void SetMechName (const char *name)
		{ m_Name->UpdateText (name); }
		void SetMechScore (int s1,int s2,int s3);
		void SetMechDamageLevel (Scalar *damage)
		{ 		
			Verify (damage);
			int i;
			for (i=0;i<11;i++)
			{
				m_DamageValues[i] = 0;
				if(damage[i+1] < 0.01f)
					m_DamageValues[i] = 4;
				else if(damage[i+1] < 0.1f)
					m_DamageValues[i] = 3;
				else if(damage[i+1] < 0.5f)
					m_DamageValues[i] = 2;
				else if(damage[i+1] < 0.75f)
					m_DamageValues[i] = 1;
			}
		}
	};
	
	class CReviewTimeBar : public HUDComponent
	{
	protected:

		typedef HUDComponent inherited;

		void DrawImplementation(void);

	public:
		CReviewTimeBar();
		~CReviewTimeBar();
	};

	extern CReviewMap *m_ReviewMap;
	extern CReviewTimeBar *m_ReviewTimeBar;
	extern CReviewMech *m_ReviewMechs[16];

	void InitMissionReviewDisplay (void);
	void KillMissionReviewDisplay (void);
	void PlayMissionReview (Stuff::Time time);
	int SpeedUp (void);
	int SlowDown (void);
	int Rewind (void);
	int Pause (void);
	void ReadKeyboard (void);
	int CenterOn (void *data[], int count);
}
#endif // !defined(NO_MR)
