#include "MW4Headers.hpp" #include "hudcomp.hpp" #include "HUDTimer.hpp" #include "objective.hpp" #include "mwmission.hpp" #include "aiutils.hpp" using namespace MechWarrior4; HUDTimer::HUDTimer() { m_Text = new HUDText (); Location (Point3D (400,0,0.9f)); Color (0,250,0,255); m_Timer = 0; m_TimeOffset = 0; m_Objective = NULL; m_TimeOnLeft = false; } HUDTimer::~HUDTimer() { delete m_Text; } void HUDTimer::DrawImplementation(void) { char text[500]; int time,min,sec; const char *objtext=""; MWMission *miss = Cast_Object (MWMission *,Mission::GetInstance ()); Verify (miss); MW4AI::CTimeServer& serv = miss->Timer (m_Timer); time = m_TimeOffset - (int) serv.CurrTime (); if (time < 0) time *= -1; min = time / 60; sec = time % 60; char *timetext; timetext = gos_GetFormattedTime (-1,(unsigned short) min,(unsigned short) sec); if (m_Objective) objtext = m_Objective->CurrentText (true); if (m_TimeOnLeft) sprintf (text,"%s %s",timetext,objtext); else sprintf (text,"%s %s",objtext,timetext); gos_Free (timetext); m_Text->UpdateText (text); DWORD dx,dy; Point3D textloc; textloc.x = 400; textloc.z = 0.9f; textloc.y = 3.0f; m_Text->TopLeft (textloc.x-100.0f,textloc.y-2.0f); m_Text->BottomRight (textloc.x+100.0f,textloc.y+20.0f); m_Text->Color (Color ()); m_Text->Justification (HUDText::LEFT_ALIGN); m_Text->DrawSize (dx,dy); textloc.x -= dx/2; m_Text->Draw (textloc); }