#include "MW4Headers.hpp"
#include "hudcomp.hpp"
#include "hudcamera.hpp"
#include "mwapplication.hpp"
#include "..\missionlang\resource.h"

using namespace MechWarrior4;

HUDCamera::HUDCamera()
{
	Location (Point3D (0,0,0.9f));
	Size (Point3D (800,600,0.9f));
	Color (255,255,255,255);

	MWApplication *app;
	app = MWApplication::GetInstance ();
	m_FactionName = new HUDText ();
	m_FactionName->UpdateText ("");
	m_FactionName->SetSize (HUDText::LARGE2_SIZE);

	m_LifeGoneText = new HUDText ();
	m_LifeGoneText->UpdateText (app->GetLocString (IDS_OUTOFLIFE));
	m_LifeGoneText->SetSize (HUDText::LARGE3_SIZE);

	m_FollowName = new HUDText ();
	m_FollowName->UpdateText ("");
	m_FollowName->SetSize (HUDText::LARGE3_SIZE);

	m_Time = gos_GetElapsedTime ();
	m_EndTime = 0;
}

HUDCamera::~HUDCamera()
{
	delete m_FactionName;
	delete m_LifeGoneText;
	delete m_FollowName;
}

void HUDCamera::Update (Time till)
{
	m_Time = till;

	inherited::Update (till);
}

void HUDCamera::OutOfLives (void)
{
	m_EndTime = m_Time + 20.0f;
}

void HUDCamera::DrawImplementation(void)
{
	Point3D loc;
	DWORD width,height;

	loc.x = 400;
	loc.y = 600;
	loc.z = 0.9f;
	if (!m_FactionName->Empty ())
	{
		m_FactionName->DrawSize (width,height);
		loc.y -= (height+5);
		loc.x = 400 - width/2.0f;
		m_FactionName->Color (0,0,0,255);
		m_FactionName->Draw (loc);
		loc.x -=2;
		loc.y -=2;
		m_FactionName->Color (0,255,0,255);
		m_FactionName->Draw (loc);
		loc.y += 2;
	}

	if (!m_FollowName->Empty ())
	{
		loc.x = 400;
		m_FollowName->DrawSize (width,height);
		loc.y -= (height + 10);
		loc.x -= width/2.0f;
		m_FollowName->Color (0,0,0,255);
		m_FollowName->Draw (loc);
		loc.x -=2;
		loc.y -=2;
		m_FollowName->Color (0,255,0,255);
		m_FollowName->Draw (loc);
		loc.y += 2;
	}
	
// MSL 5.03 Removed "Out of Lives" text from displaying on Cameraship/MR
/*	if (m_EndTime > m_Time)
	{
		loc.x = 400;
		m_LifeGoneText->DrawSize (width,height);
		loc.y -= (height+5);
		loc.x = 400 - width/2.0f;
		m_LifeGoneText->Color (0,0,0,255);
		m_LifeGoneText->Draw (loc);
		loc.x -=2;
		loc.y -=2;
		m_LifeGoneText->Color (0,255,0,255);
		m_LifeGoneText->Draw (loc);
	}
*/
}


