//
// Tools_Mode_ModuleLinking.h
//
// Created by Kevin Lea - 23/07/2001 14:02:22
// 
// Copyright (C) 2001 Rebellion, All Rights Reserved.
//

#ifdef ASURA_USE_PRAGMA_ONCE
    #pragma once
#endif

#ifndef __TOOLS_MODE_MODULELINKING_H__
#define __TOOLS_MODE_MODULELINKING_H__

#include "Tools_Mode.h"
#include "Core/Asura_Handle.h"

enum ToolsModuleLinkDirection
{
	TOOLS_MODULELINK_NORMAL,
	TOOLS_MODULELINK_REVERSED,
	TOOLS_MODULELINK_2WAY,
};

class Tools_Mode_ModuleLinking : public Tools_Mode
{
	public:

		Tools_Mode_ModuleLinking()
		{
			Initialise();
		}
		~Tools_Mode_ModuleLinking()
		{
			Shutdown();
		}

		void Initialise(void);

		void Update(void);
		void RenderWorld_PostToneMap(void);
		void RenderUI(void);
	
		void Shutdown(void);

		void QuickSave(void);
	
 		virtual bool IsModified();
        virtual void PreSave( void );
        
	private:
		//loads/saves data for this mode
		static void TransferModeData(int mode);

		static void ToggleModuleLinkOverlay(void);
		static bool ModuleLinkOverlayIsOn(void);
		static void CreateModuleLinkOverlay(void);



		static void HandleKeyboard();
		static bool TestAgainstStaticObjects(const Asura_Vector_3& xAlpha, const Asura_Vector_3& xBeta, int &iModuleIndex, const float fDistance);
		static void AddModuleLinks();
		static void SetModuleLink(int iLinkModuleIndex,Asura_Hash_ID uZoneHash,bool bLink,int iLinkDirection = TOOLS_MODULELINK_NORMAL);
		static void ClearLinksByRange();
		static void ClearLinks();
		static void ClearAllLinks();

		static void ShowModulePolygonCounts();
		static void WriteModuleLinkTextFile();
		static void CountLinkedPolygonsAndModules(int moduleIndex,int& polyCount,int& triangleCount,int& moduleCount);

		static void SetBaseModule();
		static void SetBaseModuleFromList();
		static void SetBaseModule(int iModuleIndex);

		//updates visibility/existence of static objects based on the current settings on 
		//the module linking mode overlay. RAR 10/07/03
		static void UpdateStaticObjects();
		
	
		//generated module links by doing random tests from waypoints
		static void AutoModLink();

		static float GetDistanceBetweenModules(int iModule1,int iModule2,Asura_Hash_ID uZoneHash2);

		///////////////////////////
		//data
		static Asura_Handle MenuHandle;
				
		static Asura_Vector_2 ModuleLinkOverlayPosition;
		static bool	ModuleLinkOverlayOpen;

		static bool AddingLinks;

		static bool AutoSetBaseModule;
		static bool s_bIncludeStaticObjects;
		static bool s_bStaticObjectsCreated;
		static bool s_bViewStaticObjects;
		static bool s_bStaticObjectsVisible;
		static bool s_bSelectModuleUnderCamera;
		static bool s_bIgnoreTransparentPolygons;
		static bool s_bHighlightCursorModule;
		static bool s_bShowCursorModuleName;
		static bool s_bShowBaseModuleExtents;

		static float s_fMaxLinkRange;
		static bool s_bUseMaxLinkRange;

		//For keeping track of whether the mouse button was pressed while mouse input was being taken by the mode
		static bool s_bAddingLinksUsingMouse;

		static int BaseModuleIndex;

		static int s_iLinkDirection;//values taken from enum ToolsModuleLinkDirection

		enum DialogID
		{
			DialogID_SelectModuleUnderCamera,	
		};

};


#endif//__TOOLS_MODE_MODULELINKING_H__
