
#pragma once

#include "MW4.hpp"
#include <Adept\GUIManager.hpp>
#include <gosScript\gosScriptHeaders.hpp>

namespace ElementRenderer
{
	class Element;
}

namespace Adept
{
	class ScoreObject;
	class CameraComponent;
}


namespace MidLevelRenderer
{
	class MLRClipper;
}

namespace MechWarrior4
{
	class GUIWeaponManager;
	class GUIRadarManager;
	class GUILightAmp;
	class GUIStaticView;
	class VehicleInterface;
	class Vehicle;
	class HUDComponent;
	class HUDNav;
	class HUDTargetArrow;
	class HUDTorsoBar;
	class HUDZoom;
	class HUDHeat;
	class HUDJump;
	class HUDCoolant;
	class HUDSpeed;
	class HUDDamage;
	class HUDTargetDamage;
	class HUDWeapon;
	class HUDReticle;
	class HUDChat;
	class HUDComm;
	class HUDHelp;
	class HUDMap;
	class HUDObjective;
	class HUDScore;
	class HUDTimer;
	class HUDHelpArrow;
	class HUDDebug;
	class HUDMP;
	class HUDCamera;

	//####################################################################
	//###########################    MWGUIManager   ######################
	//####################################################################

	class MWGUIManager:
		public GUIManager
	{
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Construction, Destruction
	//
	public:
		MWGUIManager();
		~MWGUIManager();

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Initialize Functions
	//
	public:
		//Target System Stuff

		void InitializeTargetSystem();
		void Reset();
		void Hide();
		void Show();
		void ShowReticle();
		void ReshowHud (void);
		void Toggle();
		void ToggleScoring();
		void ShowScoring();
		void HideScoring();
		void ShowDebug (bool value);

		void InitializeNewVehicle(Vehicle *vehicle);
		void DisplayTargetSystem(bool locked);
		void DisplayTargetSystemLRM(bool locked);
		void DisplayTargetSystemMRM(bool locked);
		void DisplayTargetSystemSRM(bool locked);
		void DisplayTargetSystemSSRM(bool locked);
		void ShowLightAmplification();
		void HideLightAmplification();
		void ShowStaticView();
		void HideStaticView();
		void AnimateStaticView();

		void SetWeaponMode(int weapon_mode,Weapon *weap);
		void Execute();
		void ClearGUIChain();

		//GOS Script calls
		void SetSpeedBar(Stuff::Scalar value,Stuff::Scalar minForward,Stuff::Scalar minReverse,Stuff::Scalar maxForward,Stuff::Scalar maxReverse);
		void SetTorsoTwist(Stuff::Scalar value);
		void SetTorsoPitch(Stuff::Scalar value);
		void SetReticleName(const char *object_name);
// MSL 5.02 SubSystems
		void SetReticleIFFJammer(bool exists) { IFF_Jammer = exists; }
		bool GetReticleIFFJammer() { return IFF_Jammer; }
		void SetReticleAlignment(int alignment)
				{reticleAlignment = alignment;}
		void SetReticleDistance(Stuff::Scalar distance)
				{reticleDistance = distance;}
		void SetNavSystem(Stuff::Scalar facing_angle,
				Stuff::Scalar nav_point_angle,
				Stuff::Scalar range,
				int nav_point_id
		);
		void SetLeftTargetIndicator();
		void SetRightTargetIndicator();
		void SetTopTargetIndicator();
		void SetBottomTargetIndicator();
		void SetTargetIndicatorInZoom();
		void ClearTargetIndicator();
		void SetTargetPosition(Adept::CameraComponent *camera, const Stuff::Point3D& target_world, const Point3D& target_size, Stuff::Scalar cameraWidth, Stuff::Scalar cameraHeight, Stuff::Scalar cameraOffsetX, Stuff::Scalar cameraOffsetY);
		void FindTargetBoxSize(MidLevelRenderer::MLRClipper *clipper, const Point3D & target_world, const Point3D & target_size, Stuff::Scalar & targetWidth, Stuff::Scalar & targetHeight);
		enum
		{
			MaxStringLength = 128
		};


		enum {
			HIDE_ALL,
			SHOW_RETICLE,
			SHOW_ALL
		};
		int m_currentWidthRes;
		int m_isShown;
		int m_ShowLevel;				// used to reset the hud
		SlotOf <ElementRenderer::Element *> m_targetElement;
		

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Public Data
	//
	public:
		
		GUIWeaponManager * weaponManager;

		GUILightAmp *lightAmp;
//		GUILightAmp *zoomLightAmp;
		GUIStaticView *staticViewManager;

		VehicleInterface* vehicleInterface;
		SlotOf <Entity *> m_CurrentTarget;

//		HGOSFONT3D font;

		void SetNewTargetWindowEntity(Entity *new_target);

		static MWGUIManager*
			GetInstance()
		{
			return reinterpret_cast<MWGUIManager *>( GlobalPointers::GetGlobalPointer(MWGUIManagerGlobalPointerIndex));
		};

	protected:
		Stuff::Scalar maxTorsoTwist,maxTorsoPitch,maxSpeed;
		Stuff::Scalar currentSpeedValue;
		int torsoTwistValue,torsoPitchValue;
		int isReticleLocked;
		int isReticleLockedLRM;
		int isReticleLockedMRM;
		int isReticleLockedSRM;
		int isReticleLockedSSRM;
		int *damageArray;
		Scalar *armorArray;
		int *heatValue;
		int *coolantValue;
		Stuff::Scalar *jumpValue;
		Stuff::Scalar maxJumpValue;
//		int *isCoolantDirty;
//		int *isHeatDirty;
		char *reticleName;
// MSL 5.02 SubSystems
		bool IFF_Jammer; //set if the thing under the reticle has an IFF_Jammer
		int reticleAlignment;
		Stuff::Scalar reticleDistance;
		//Nav System variables
		int m_playerFacing;
		int m_navPointFacing;
		Stuff::Scalar m_navPointRange;
		char *m_navPointName;

		//Target Indicator Variables
		int m_leftTargetIndicator;
		int m_rightTargetIndicator;
		int m_topTargetIndicator;
		int m_bottomTargetIndicator;
		int m_targetIndicatorInZoom;
		Stuff::Scalar m_targetXLocation;
		Stuff::Scalar m_targetYLocation;
		Stuff::Scalar m_targetHeight;
		Stuff::Scalar m_targetWidth;

		//Torso Roation Vaules
		int m_torsoRotation;

//		int m_zoomOn;
		//Target Window Information
		int *m_targetDamageArray;
		Scalar *m_targetArmorArray;
		Stuff::Scalar m_targetTonage;
		char *m_targetWindowName;
		int m_targetWindowAlignment;

		//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		// New HUD system
		//
	protected:
		stlport::vector <HUDComponent *> m_Components;
		HUDMP *hudmp;
		HUDNav *hudnav;
		HUDTargetArrow *hudTargetArrow;
		HUDTorsoBar *hudTorsoBar;
		HUDZoom *hudZoom;
		HUDHeat *hudHeat;
		HUDCoolant *hudCoolant;
		HUDJump *hudJump;
		HUDSpeed *hudSpeed;
		HUDDamage *hudDamage;
		HUDTargetDamage *hudTargetDamage;
		HUDWeapon *hudWeapon;
		HUDReticle *hudReticle;
		HUDChat *hudChat;
		HUDComm *hudComm;
		HUDHelp *hudHelp;
		HUDMap *hudMap;
		HUDObjective *hudObjective;
		HUDScore *hudScore;
		HUDTimer *hudTimer;
		HUDHelpArrow *hudHelpArrow;
		HUDDebug *hudDebug;
		HUDCamera *hudCamera;
		GUIRadarManager *radarManager;
		Vehicle *m_Vehicle;
		bool InterfaceZoomMode;

		bool m_ShutdownMode;

		bool m_ZoomVisible;
		bool m_MapShowing;
		bool m_drawScoring;					// true for full score
		bool m_TimerShowing;
		bool m_HelpArrowShowing;
		bool m_LightAmpShowing;
		bool m_DebugShowing;

		void ClearComponents (void);
		void CreateComponents (void);

	public:
		void ToggleDebug (void)
		{ ShowDebug (!m_DebugShowing); }
		// NOTE: the HUDELEMENTS members must EXACTLY match those in MWCONST.ABI!
		enum HUDELEMENTS {
			HUD_NAV				= 0,
			HUD_TARGETARROW,
			HUD_TORSOBAR,
			HUD_ZOOM,
			HUD_HEAT,
			HUD_COOLANT,
			HUD_JUMP,
			HUD_SPEED,
			HUD_DAMAGE,
			HUD_TARGETDAMAGE,
			HUD_WEAPON,
			HUD_RETICLE,
			HUD_RADAR,
			HUD_CHAT,
			HUD_COMM,
			HUD_HELP,
			HUD_MAP,
			HUD_OBJECTIVE,
			HUD_SCORE,
			HUD_TIMER,
			HUD_HELPARROW,
			HUD_DEBUG,
			HUD_MP,
			HUD_CAMERA
		};

		char gametype[256];
		void ShowShutDown (void)
		{ m_ShutdownMode = false; }
		void HideShutDown (void)
		{ m_ShutdownMode = true; }
		void HeatLevel (Scalar level);
		void AddPPCLevel (Scalar level);
		void AddComponent (HUDComponent *);
		void RenderComponents (void);
		void UpdateComponents (void);
		void HideShutdown ()
		{
			m_ShutdownMode = true;
		}
		void ShowShutdown ()
		{
			m_ShutdownMode = false;
		}

		void ShowHudComponent (HUDELEMENTS which);
		void HideHudComponent (HUDELEMENTS which);
		bool HudComponentVisible (HUDELEMENTS which);

		HUDObjective *ObjectiveComponent (void)
		{ return hudObjective; }
		HUDComponent *Component (HUDELEMENTS which);

// MSL 5.03 Ammo Bay Fire Indicator
		void ShowFIRE (bool value);
// MSL 5.03 Jam Indicator
		void ShowJAM (bool value);
		void ShowFlag (bool value);
		void ShowKOTF (bool value);
		void MPName (const char *name);
		void MPTimeLeft (Stuff::Time value);

		void SetReticuleTarget (Entity *target_entity);

		void ShowHelpArrow (bool value);
		void ShowTimer (bool value);
		void ShowZoom (bool value);
		void SetZoomDisplayLevel (int level);
		void ShowMap (bool value);
		void ToggleMap (void)
		{
			m_MapShowing = !m_MapShowing;
			ShowMap (m_MapShowing);
		}
        // jcem
        bool IsDrawingScoring() const { return m_drawScoring; }
	};
}
