//===========================================================================//
// File:	Interface.hpp                                                       //
// Project: MUNGA           Brick: Interest Manager	                       //
// Contents: Interface specifications for interest manager						  //
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  -----------------------------------------------------------//
// 08/25/97  JMA  Infrastructure changes.                                    //
// 08/25/97  ECH  Infrastructure changes.                                    //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc.                //
// All Rights reserved worldwide                                             //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL               //
//===========================================================================//

#pragma once

#include "Adept.hpp"
#include "EntityClassData.hpp"
#include "Entity.hpp"
#include "application.hpp"
#include "control_mapping.hpp"

namespace Adept {

	class Entity__CreateMessage;

	//##########################################################################
	//####################    Interface__GameModel    ##########################
	//##########################################################################

	class Interface__GameModel:
		public Entity__GameModel
	{
	public:
		ResourceID mappingStreamResourceID;

		static void
			ConstructGameModel(Script *script);
	};

	typedef	Entity__CreateMessage				Interface__CreateMessage;
	typedef Entity__ExecutionStateEngine		Interface__ExecutionStateEngine;

	//##########################################################################
	//##########################    Interface    ###############################
	//##########################################################################

	class Interface :
		public Entity
	{
	public:
		static void
			InitializeClass();
		static void
			TerminateClass();

		typedef Entity BaseClass;

		static ClassData
			*DefaultData;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Inheritance support
	//
	public:
		typedef Interface__GameModel					GameModel;
		typedef Interface__CreateMessage				CreateMessage;
		typedef Interface__ExecutionStateEngine			ExecutionStateEngine;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Run-time Construction and Destruction Support
	//
	public:
		static Interface*
			Make(
				const CreateMessage *message,
				ReplicatorID *base_id
			);

		~Interface();

	protected:
		
		Interface(
			ClassData *class_data,
			const CreateMessage *message,
			ReplicatorID *base_id,
			ElementRenderer::Element *element
		);

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Control Support
	//
	protected:
		bool m_ChatMode;
		bool m_TeamChat;
		int m_InChatMessage;
		int m_ChatLen;
		bool m_InsertMode;
		bool m_ForceFeedBack;
		Scalar m_MouseSensitivity;
		bool m_MouseAllowed;
		int m_JoystickXAxisType;
		int m_JoystickRudderAxisType;
		int m_MouseXAxisType;
		Scalar m_joystick_throttle_center;
		Scalar m_joystick_throttle_dead_low;
		Scalar m_joystick_throttle_dead_high;

	public:

		char m_CurrentChatMessage[MaxChatSize];
		void ClearMappings (void);
		virtual void LoadControlStream (const ResourceID& control_stream);
		virtual void EnterChatMode (bool team);
		virtual void LeaveChatMode (void);
		virtual void pushChatKey (DWORD key);
		virtual void ForceFeedBack (bool value)
		{ m_ForceFeedBack = value; }
		virtual void MouseSensitivity (Scalar value)
		{ m_MouseSensitivity = value/25.0f; }			// was 0-1 and we want 0.5 to be equal to 0.02f
		virtual void MouseAllowed (bool value)
		{ m_MouseAllowed = value; }

		virtual void JoystickXAxisType (int value)
		{ m_JoystickXAxisType = value; }
		virtual void JoystickRudderAxisType (int value)
		{ m_JoystickRudderAxisType = value; }
		virtual void MouseXAxisType (int value)
		{ m_MouseXAxisType = value; }

		virtual void JoyStickThrottleCenter(Scalar s)
		{ m_joystick_throttle_center = s; }
		virtual void JoyStickThrottleLow(Scalar s)
		{ m_joystick_throttle_dead_low = s; }
		virtual void JoyStickThrottleHigh(Scalar s)
		{ m_joystick_throttle_dead_high = s; }


	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Targeting Support
	//
	public:
		Stuff::Line3D
			targetLine;
		Stuff::Scalar
			targetDistance;
		Entity__CollisionQuery
			targetQuery;
		Stuff::SlotOf<Entity*>
			reticuleEntity;
		Stuff::Point3D
			reticuleOffset;
		Stuff::Normal3D
			reticuleNormal;

		virtual bool
			ClipCameraLine(Stuff::Line3D *line)
				{Check_Object(this); return true;}

		virtual Entity*
			CastCollisionLine();

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Model Support
	//
	public:
		const GameModel*
			GetGameModel()
				{
					Check_Object(this);
					return Cast_Pointer(const GameModel*, gameModelResource.GetPointer());
				}

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Test Support
	//
	public:
		void
			TestInstance();
	};

#if 0
	//#########################################################################
	//#####################    ControlsMappingRequest    ######################
	//#########################################################################

	class ControlsMappingRequest
	{
	public:
		size_t
			recordSize;

		enum {
			DirectMapping=0,
			EventMapping=1
		};

		int
			controlsGroup,
			controlsElement,
			mappingType,
			subsystemID,
			controlMask;

		bool invert;
		
		union
		{
			Entity::AttributeID attributeID;
			Receiver::MessageID messageID;
		};

		void
			TestInstance() const
				{}
	};
#endif

}

