//================================================================================
//
// File   : ToolsAVP_Blueprint_Edit_Object.cpp
// Author : Kyle Stevenson
// Date   : 25-Oct-2006
//
// Copyright (C) 2006 Rebellion, All Rights Reserved.
//
//================================================================================

//================================================================================
// Include files...
//================================================================================

#include "Core/Asura.h"

// This file's header...
#include "ToolsAVP_Blueprint_Edit_Object.h"

// Asura independent header-files...
#include "Blueprint/Asura_Blueprint.h"
#include "Blueprint/Asura_Blueprint_System.h"
#include "Core/Asura_Maths.h"
#include "Debugging/Asura_Assert.h"
#include "Interface/Asura_Dialog.h"
#include "Interface/Asura_Overlay_System.h"
#include "Interface/Asura_Overlay.h"
#include "Physics/Asura_Physics_Object.h"
#include "Rendering/Asura_Colour.h"
#include "Sound/Asura_Audio_DSP.h"
#include "Sound/Asura_Audio_System.h"
#include "Sound/Asura_Sound_Mixer.h"

// Game independent header-files...
#include "Actor/Vertebrates/Human/AVP_Human_Description.h"
#include "Behaviour/BehaviourTypes/AVP_Behaviour_Types.h"
#include "Blueprint/AVP_Blueprint_HashIDs.h"
#include "Core/AVP_Settings.h"
#include "Entity/Controller/AVP_ServerEntity_Team_Alien.h"
#include "Entity/PhysicalObject/Pickup/AVP_Pickup.h"
#include "Entity/PhysicalObject/Projectile/AVP_GenericProjectileData.h"
#include "Input/AVP_Rumble_System.h"
#include "Inventory/Groups/AVP_InventoryGroup_Weapons.h"
#include "Moves/Vertebrates/AVP_MovesMelee.h"

// avp axon
#include "Core/AxonAVP_Messages.h"
#include "Behaviour/BehaviourTypes/AVP_Behaviour_Types.h"

// Tools header-files...
#include "Blueprint/Tools_Mode_Blueprint.h"
#include "Interface/Tools_ColourPicker.h"
#include "Misc/Tools_Modal_Overlay.h"
#include "Misc/Tools_Timed_Messages.h"

#include "Material/ToolsAVP_SurfaceOverlay.h"

//================================================================================
// Constant declarations...
//================================================================================

const char* ToolsAVP_Blueprint_Edit_Object::s_apszAVPTemplatedTypeNames[ AVP_NUM_TEMPLATED_TYPES ] =
{
	"Character Type",
	"Surface Type",
    "AI Behaviour",
	"Alien Spawn Method",
	"Collision Proxy",
	"Weapon Type",
	"Impact Type",
	"Weapon Slot Type",
	"Role",
	"Respawn Type",
	"AI Move In Mode",
	"AI Post Attack Action",
	"Pickup Type",
	"AI Weapon Behaviour Type",
	"Blueprint (No Export)",
	"Rumble Effect",
	"Rumble Adjust",
	"Rumble Play Priority",
	"DSP",
	"Sound Mixer Preset",
	"Grapple Event Type"
};

const char* s_aszCollisionProxyNames[ Asura_Physics_Object::NUM_COLLISION_PROXIES + 1 ] = 
{
	"OBB",
	"Sphere",
	"SphereStack",
	"Polygonal",
	"None",
};

const char* s_aszWeaponTypeNames[ NUM_AVP_INVENTORYITEMTYPES ] = 
{
	"Ranged Weapon",
	"Predator Disc",
	"Melee Weapon",
	"Other",
	"SmartGun",
	"Flamethrower Weapon",
	"Dropship Missile",
	"Unarmed",
	"Battery",
	"Taser",
	"Vision Mode (Pseudo-Type)",
	"Scoped Rifle",
	"Plasmacaster",
	"Shotgun",
	"Torch",
	"Flare",		
	"Stim",		
	"Cloak",
	"Predator Mine",
	"Tequila"
};

const char* s_aszWeaponSlotTypeNames[ AVP_InventoryGroup_Weapons::NUM_AVP_INVENTORYWEAPONSLOTTYPES ] = 
{
	"Low Priority (Pistol)",
	"Medium Priority (PulseRifle)",
	"High Priority (SmartGun)"
};

const char* s_aszImpactTypeNames[ AVP_GenericProjectileData::NUM_IMPACT_TYPES ] =
{
	"None",
	"Explode",
	"Embed"
};

const char* s_aszPickupTypeNames[ AVP_Pickup::PICKUP_TOTAL ] =
{
	"Weapon",
	"Health",
	"Ammo",
	"Tool",
	"Audio Diary"
};

const char* s_aszWeaponBehaviourTypeNames[ AVP_WEAPON_BEHAVIOUR_TYPE_MAX_TYPES ] =
{
	"None",
	"Pistol",
	"Pulserifle",
	"Shotgun",
	"Flamethrower",
	"Smartgun",
	"Scoped Rifle",
	"Taser",
	"Plasma Caster",
	"Speargun",
	"Disc"
};

const char* s_aszRumbleEffectNames[ RUMBLE_BASE_SYMWAVE + 1 ] =
{
	"Constant rumble",
	"Linearly increasing rumble ",
	"Curve with increasing gradient",
	"Curve with decreasing gradient",
	"A symmetrical wave "
};

const char* s_aszRumbleAdjustNames[ RUMBLE_ADJUST_FLIP + 1 ] =
{
	"No change",
	"Use the effect in reverse ",
	"Use the vertical reflection of the effect "
};

const char* s_aszRumblePlayNames[ AVP_Rumble_System::RUMBLE_PLAY_TOTAL ] =
{
	"Play always",
	"Play exclusive"
};

const char* g_aszGrappleEventTypeNames[NUM_AVP_GRAPPLE_EVENT_TYPES] =
{
	"Camera Photon",
	"Dismember Enemy",
	"Headbite Enemy",
	"PFX Effect",
};

// Data for the start behaviours. Could have gone internally to the AI system, but it's here instead.  :P
enum AVP_UI_Start_Behaviours
{
	AVP_UISB_ALIEN_NONE,
    AVP_UISB_ALIEN_WANDER,
    AVP_UISB_MARINE,
    AVP_UISB_PREDATOR,
	AVP_UISB_PREDATOR_TEST,
	AVP_UISB_ALIEN_LIGHTTEST,
	AVP_UISB_ALIEN_DEFAULT,
	AVP_UISB_FACEHUGGER_DEFAULT,
	AVP_NUM_UI_START_BEHAVIOURS,
};

const struct AVP_UISB_To_Behaviour_Type
{
    AVP_UISB_To_Behaviour_Type( int iBehaviourType, const char* pszBehaviourName )
    : m_iBehaviourType( iBehaviourType ), m_pszBehaviourName( pszBehaviourName )
    {
    }

    int			m_iBehaviourType;
    const char* m_pszBehaviourName;
} s_axUISBToBehaviours[ AVP_NUM_UI_START_BEHAVIOURS ] =
{
	// AVP_UISB_ALIEN_NONE
	AVP_UISB_To_Behaviour_Type( AXON_BEHAVIOUR_TYPE_UNSET, "*None*" ),
    // AVP_UISB_ALIEN_WANDER
    AVP_UISB_To_Behaviour_Type( AVP_BEHAVIOUR_TYPE_ALIEN_WANDER, "Alien Wander Test" ),
    // AVP_UISB_MARINE
    AVP_UISB_To_Behaviour_Type( AVP_BEHAVIOUR_TYPE_MARINE, "Marine" ),
    // AVP_UISB_PREDATOR
    AVP_UISB_To_Behaviour_Type( AVP_BEHAVIOUR_TYPE_PREDATOR, "Predator" ),
	// AVP_UISB_PREDATOR_TEST
	AVP_UISB_To_Behaviour_Type( AVP_BEHAVIOUR_TYPE_PREDATOR_TEST, "Predator Test" ),
	// AVP_UISB_ALIEN_LIGHTTEST
	AVP_UISB_To_Behaviour_Type( AVP_BEHAVIOUR_TYPE_ALIEN_LIGHTTEST, "Alien Light Test" ),
	// AVP_UISB_ALIEN_DEFAULT
	AVP_UISB_To_Behaviour_Type( AVP_BEHAVIOUR_TYPE_ALIEN_ROOT, "Alien Root" ),
	// AVP_UISB_FACE_HUGGER_DEFAULT
	AVP_UISB_To_Behaviour_Type( AVP_BEHAVIOUR_TYPE_FACEHUGGER, "FaceHugger Default" ),

};

//================================================================================
// Protected functions...
//================================================================================

void ToolsAVP_Blueprint_Edit_Object::GetValueString( const Asura_Value& xValue, const int iTemplatedType, Asura_String& xString )
{
    if ( iTemplatedType != -1 )
    {
		switch ( iTemplatedType )
		{
			case AVP_BP_CHARTYPE:
			{
				const AVP_Settings::Species	eSpecies = static_cast<AVP_Settings::Species>(Asura_Maths::ClampToRange( xValue.GetIntValue(), 0, (int)AVP_Settings::AVP_NUM_SPECIES - 1 ));
                xString = AVP_Settings::GetSpeciesName(eSpecies);
                return;
			}

			case AVP_BP_SURFACETYPE:
			{
				xString = xValue.GetHashStringValue();
				return;
			}

            case AVP_BP_AIBEHAVIOUR:
            {
                xString = "Unset";

                const int iValue = xValue.GetIntValue();
                for ( int iIndex = 0; iIndex < AVP_NUM_UI_START_BEHAVIOURS; ++iIndex )
                {
                    if ( s_axUISBToBehaviours[ iIndex ].m_iBehaviourType == iValue )
                    {
                        xString = s_axUISBToBehaviours[ iIndex ].m_pszBehaviourName;
						break;
                    }
                }

                return;
            }

			case AVP_BP_AIMOVEINMODE:
			{
				xString = AVP_AlienBehaviourData::s_apszMoveInModeStrings[ xValue.GetIntValue() ];
				return;
			}

			case AVP_BP_AIPOSTATTACKACTION:
			{
				xString = AVP_AlienBehaviourData::s_apszPostAttackActionStrings[ xValue.GetIntValue() ];
				return;
			}

			case AVP_BP_SPAWNMETHODS:
			{
				xString = "Not used anymore.";
				return;
			}

			case AVP_BP_COLLISIONPROXY:
			{
				xString = "Unset";
				const int iValue = xValue.GetIntValue();
				Asura_Assert( iValue >=0 && iValue <= Asura_Physics_Object::NUM_COLLISION_PROXIES, "Bad value" );
				if ( iValue >=0 && iValue <= Asura_Physics_Object::NUM_COLLISION_PROXIES )
				{
					xString = s_aszCollisionProxyNames[ iValue ];
				}
				return;
			}

			case AVP_BP_WEAPONTYPE:
			{
				const int iValue = xValue.GetIntValue();
				Asura_Assert( iValue >=0 && iValue < NUM_AVP_INVENTORYITEMTYPES, "Bad value" );
				if ( iValue >=0 && iValue < NUM_AVP_INVENTORYITEMTYPES )
				{
					xString = s_aszWeaponTypeNames[ iValue ];
				}
				return;
			}

			case AVP_BP_WEAPONSLOTTYPE:
			{
				const int iValue = xValue.GetIntValue();
				Asura_Assert( iValue >=0 && iValue < AVP_InventoryGroup_Weapons::NUM_AVP_INVENTORYWEAPONSLOTTYPES, "Bad value" );
				if ( iValue >=0 && iValue < AVP_InventoryGroup_Weapons::NUM_AVP_INVENTORYWEAPONSLOTTYPES )
				{
					xString = s_aszWeaponSlotTypeNames[ iValue ];
				}
				return;
			}

			case AVP_BP_IMPACTTYPE:
			{
				const int iValue = xValue.GetIntValue();
				Asura_Assert( iValue >=0 && iValue < AVP_GenericProjectileData::NUM_IMPACT_TYPES, "Bad value" );
				if ( iValue >=0 && iValue < AVP_GenericProjectileData::NUM_IMPACT_TYPES )
				{
					xString = s_aszImpactTypeNames[ iValue ];
				}
				break;
			}

			case AVP_BP_ROLE:
			{
				const AVP_Settings::Role eRole = static_cast<AVP_Settings::Role>(Asura_Maths::ClampToRange( xValue.GetIntValue(), 0, (int)AVP_Settings::AVP_NUM_ROLES - 1 ));
                xString = AVP_Settings::GetRoleName(eRole);
                return;
			}

			case AVP_BP_RESPAWNTYPE:
			{
				const AVP_Settings::RespawnType eRespawnType = static_cast<AVP_Settings::RespawnType>(Asura_Maths::ClampToRange( xValue.GetIntValue(), 0, (int)AVP_Settings::AVP_NUM_RESPAWNTYPES - 1 ));
				xString = AVP_Settings::GetRespawnTypeName(eRespawnType);
                return;
			}

			case AVP_BP_PICKUPTYPE:
			{
				const int iValue = xValue.GetIntValue();
				Asura_Assert( iValue >=0 && iValue < AVP_Pickup::PICKUP_TOTAL, "Bad value" );
				if ( iValue >=0 && iValue < AVP_Pickup::PICKUP_TOTAL )
				{
					xString = s_aszPickupTypeNames[ iValue ];
				}
				return;
			}

			case AVP_BP_AIWEAPONBEHAVIOURTYPE:
			{
				const int iValue = xValue.GetIntValue();
				Asura_Assert( iValue >= 0 && iValue < AVP_WEAPON_BEHAVIOUR_TYPE_MAX_TYPES, "Bad value" );
				if ( iValue >= 0 && iValue < AVP_WEAPON_BEHAVIOUR_TYPE_MAX_TYPES )
				{
					xString = s_aszWeaponBehaviourTypeNames[ iValue ];
				}
				return;
			}

			case AVP_BP_BLUEPRINT_NOEXPORT:
			{
				if ( xValue.GetHashIDValue() == ASURA_HASH_ID_UNSET )
				{
					xString = "*Unset*";
				}
				else
				{
					xString = xValue.GetHashStringValue();
					if ( xString.IsBlank() )
					{
						xString = "*Null String*";
					}
				}
				return;
			}

			case AVP_BP_RUMBLE_EFFECT:
			{
				const int iValue = xValue.GetIntValue();
				Asura_Assert( iValue >=0 && iValue < RUMBLE_BASE_SYMWAVE + 1, "Bad value" );
				if ( iValue >=0 && iValue < RUMBLE_BASE_SYMWAVE + 1 )
				{
					xString = s_aszRumbleEffectNames[ iValue ];
				}
				return;
			}

			case AVP_BP_RUMBLE_ADJUST:
			{
				const int iValue = xValue.GetIntValue();
				Asura_Assert( iValue >=0 && iValue < RUMBLE_ADJUST_FLIP + 1, "Bad value" );
				if ( iValue >=0 && iValue < RUMBLE_ADJUST_FLIP + 1 )
				{
					xString = s_aszRumbleAdjustNames[ iValue ];
				}
				return;
			}

			case AVP_BP_RUMBLE_PRIORITY:
			{
				const int iValue = xValue.GetIntValue();
				Asura_Assert( iValue >=0 && iValue < AVP_Rumble_System::RUMBLE_PLAY_TOTAL, "Bad value" );
				if ( iValue >=0 && iValue < AVP_Rumble_System::RUMBLE_PLAY_TOTAL )
				{
					xString = s_aszRumblePlayNames[ iValue ];
				}
				return;
			}

			case AVP_BP_DSP_CHAIN:
			{
				const Asura_Hash_ID uValue = xValue.GetHashIDValue();
				const Asura_Audio_DSPChain* pxChain = Asura_Audio_System::GetDSPChainByHash( uValue );
				if ( pxChain )
				{
					xString = pxChain->m_xName;
				}
				return;
			}

			case AVP_BP_SOUNDMIXER_PRESET:
			{
				if ( xValue.GetHashIDValue() == ASURA_HASH_ID_UNSET )
				{
					xString = "*None*";
				}
				else
				{
					const Asura_Hash_ID uValue = xValue.GetHashIDValue();
					const Asura_Sound_Mixer_Preset* pxPreset = Asura_Sound_Mixer_System::FindPreset( uValue );
					if ( pxPreset )
					{
						xString = pxPreset->GetName();
					}
				}
				return;
			}

			case AVP_BP_GRAPPLEEVENT_TYPE:
			{
				int iValue = xValue.GetIntValue();
				if (iValue < 0)
				{
					xString = "*None*";
				}
				else if (iValue >= NUM_AVP_GRAPPLE_EVENT_TYPES)
				{
					xString = "<UNKNOWN>";
				}
				else
				{
					xString = g_aszGrappleEventTypeNames[iValue];
				}
				return;
			}

			default: break;
		}
    }

    return PARENT::GetValueString( xValue, iTemplatedType, xString );
}

//================================================================================
// Protected functions...
//================================================================================

bool ToolsAVP_Blueprint_Edit_Object::InitialiseTemplatedTypeTemplate( Asura_Blueprint_Template* pxTemplate, u_int uType )
{
	switch( uType )
	{
		case AVP_BP_CHARTYPE:
		{
			pxTemplate->SetType( Asura_Value::VT_INT );
            pxTemplate->SetInitial( 0 );
			return true;
		}

		case AVP_BP_SURFACETYPE:
		{
			pxTemplate->SetType( Asura_Value::VT_HASH );
            pxTemplate->SetInitial( static_cast< int >( ASURA_HASH_ID_UNSET ) );
			return true;
		}

        case AVP_BP_AIBEHAVIOUR:
		case AVP_BP_AIMOVEINMODE:
		case AVP_BP_AIPOSTATTACKACTION:
        {
            pxTemplate->SetType( Asura_Value::VT_INT );
            pxTemplate->SetInitial( 0 );
            return true;
        }

		case AVP_BP_SPAWNMETHODS:
		{
			pxTemplate->SetType( Asura_Value::VT_INT );
			pxTemplate->SetInitial( 0 );
			return true;
		}

		case AVP_BP_COLLISIONPROXY:
		{
			pxTemplate->SetType( Asura_Value::VT_INT );
			pxTemplate->SetInitial( Asura_Physics_Object::NUM_COLLISION_PROXIES );
			return true;
		}

		case AVP_BP_WEAPONTYPE:
		{
			pxTemplate->SetType( Asura_Value::VT_INT );
			pxTemplate->SetInitial( 0 );
			return true;
		}

		case AVP_BP_WEAPONSLOTTYPE:
		{
			pxTemplate->SetType( Asura_Value::VT_INT );
			pxTemplate->SetInitial( 0 );
			return true;
		}

		case AVP_BP_IMPACTTYPE:
		{
			pxTemplate->SetType( Asura_Value::VT_INT );
			pxTemplate->SetInitial( 1 );
			return true;
		}

		case AVP_BP_ROLE:
		{
			pxTemplate->SetType( Asura_Value::VT_INT );
            pxTemplate->SetInitial( 0 );
			return true;
		}

		case AVP_BP_RESPAWNTYPE:
		{
			pxTemplate->SetType( Asura_Value::VT_INT );
            pxTemplate->SetInitial( 0 );
			return true;
		}

		case AVP_BP_PICKUPTYPE:
		{
			pxTemplate->SetType( Asura_Value::VT_INT );
			pxTemplate->SetInitial( 0 );
			return true;
		}

		case AVP_BP_AIWEAPONBEHAVIOURTYPE:
		{
			pxTemplate->SetType( Asura_Value::VT_INT );
			pxTemplate->SetInitial( 0 );
			return true;
		}

		case AVP_BP_BLUEPRINT_NOEXPORT:
		{
			pxTemplate->SetType( Asura_Value::VT_HASH );
			pxTemplate->SetInitial( static_cast< int >( ASURA_HASH_ID_UNSET ) );
			return true;
		}

		case AVP_BP_RUMBLE_EFFECT:
		case AVP_BP_RUMBLE_ADJUST:
		case AVP_BP_RUMBLE_PRIORITY:
		{
			pxTemplate->SetType( Asura_Value::VT_INT );
			pxTemplate->SetInitial( 0 );
			return true;
		}

		case AVP_BP_DSP_CHAIN:
		{
			pxTemplate->SetType( Asura_Value::VT_HASH );
			pxTemplate->SetInitial( static_cast< int >( ASURA_HASH_ID_UNSET ) );
			return true;
		}

		case AVP_BP_SOUNDMIXER_PRESET:
		{
			pxTemplate->SetType( Asura_Value::VT_HASH );
			pxTemplate->SetInitial( static_cast< int >( ASURA_HASH_ID_UNSET ) );
			return true;
		}

		case AVP_BP_GRAPPLEEVENT_TYPE:
		{
			pxTemplate->SetType(Asura_Value::VT_INT);
			pxTemplate->SetInitial(-1);
			return true;
		}

		default : break;
	}

	return PARENT::InitialiseTemplatedTypeTemplate( pxTemplate, uType );
}


bool ToolsAVP_Blueprint_Edit_Object::GetValueForTemplatedType( const int iTemplatedType, const Asura_Hash_ID uTemplateHashID, const Asura_String xParameterName, Asura_Value& xValue )
{	
	switch ( iTemplatedType )
	{
		case AVP_BP_CHARTYPE:
		{
			ListSelection_Overlay xTypeOverlayFac( "Pick the actor's type" );
			for( u_int j=0; j<AVP_Settings::AVP_NUM_SPECIES; ++j )
			{
				xTypeOverlayFac.AddItem( AVP_Settings::GetSpeciesName(static_cast<AVP_Settings::Species>(j)), j );
			}

			if( !xTypeOverlayFac.DoModal() ) { return false; }
			
			xValue.SetValue( xTypeOverlayFac.GetSelectionData() );

			return true;
		} 

		case AVP_BP_SURFACETYPE:
		{
			Asura_Hash_ID			uBPSelection = xValue.GetHashIDValue();
			Asura_Hash_ID			uBlueprintType = uAVP_BLUEPRINT_TYPE_SURFACEEFFECTS;
			BlueprintSelect_Overlay	xModalOverlay("Pick the surface type", &uBPSelection, &uBlueprintType, 1, &uAVP_BLUEPRINT_TYPE_SURFACEEFFECTS, 1, &uAVP_BLUEPRINT_NAME_SURFACETYPE );

			if(!xModalOverlay.DoModal())	{return false;}

			const Asura_Blueprint*	pxBlueprint		= Asura_Blueprint_System::GetBlueprintByHashID(uAVP_BLUEPRINT_TYPE_SURFACEEFFECTS, uBPSelection);
			const char*				szBlueprintName	= (pxBlueprint == NULL) ? "*None*" : pxBlueprint->GetName().GetString();

			xValue.SetValue( uBPSelection , szBlueprintName );

			return true;
		} 

        case AVP_BP_AIBEHAVIOUR:
        {
            ListSelection_Overlay xBehaviourList( "Pick the start behaviour" );
            for ( u_int iIndex = 0; iIndex < AVP_NUM_UI_START_BEHAVIOURS; ++iIndex )
            {
                xBehaviourList.AddItem( s_axUISBToBehaviours[ iIndex ].m_pszBehaviourName, s_axUISBToBehaviours[ iIndex ].m_iBehaviourType );
            }

            if ( !xBehaviourList.DoModal() ) { return false; }

            xValue.SetValue( xBehaviourList.GetSelectionData() );

            return true;
        }

		case AVP_BP_AIMOVEINMODE:
		{
			ListSelection_Overlay xStringList( "Pick the move in mode" );
			for ( int i = 0; i < AVP_AlienBehaviourData::NUM_MOVE_STYLES; ++i )
			{
				xStringList.AddItem( AVP_AlienBehaviourData::s_apszMoveInModeStrings[ i ], i );
			}

			if ( xStringList.DoModal() )
			{
				xValue.SetValue( xStringList.GetSelectionData() );
				return true;
			} 
			else
			{
				return false;
			}
		}

		case AVP_BP_AIPOSTATTACKACTION:
		{
			ListSelection_Overlay xStringList( "Pick the post attack action" );
			for ( int i = 0; i < AVP_AlienBehaviourData::NUM_POST_ATTACK_ACTIONS; ++i )
			{
				xStringList.AddItem( AVP_AlienBehaviourData::s_apszPostAttackActionStrings[ i ], i );
			}

			if ( xStringList.DoModal() )
			{
				xValue.SetValue( xStringList.GetSelectionData() );
				return true;
			} 
			else
			{
				return false;
			}
		}

		case AVP_BP_SPAWNMETHODS:
		{
			xValue.SetValue(0);
			return true;
		}

		case AVP_BP_COLLISIONPROXY:
		{
			ListSelection_Overlay xCollisionProxyList( "Pick The Collision Proxy" );

			for (u_int iIndex = 0; iIndex <= Asura_Physics_Object::NUM_COLLISION_PROXIES; ++iIndex)
			{
				xCollisionProxyList.AddItem( s_aszCollisionProxyNames[iIndex], iIndex );
			}

			if (!xCollisionProxyList.DoModal()) 
			{
				return false;
			}

			xValue.SetValue(xCollisionProxyList.GetSelectionData());
			return true;
		}

		case AVP_BP_WEAPONTYPE:
		{
			ListSelection_Overlay xWeaponTypeList( "Pick The Weapon Type" );

			for (u_int iIndex = 0; iIndex < NUM_AVP_INVENTORYITEMTYPES; ++iIndex)
			{
				xWeaponTypeList.AddItem( s_aszWeaponTypeNames[iIndex], iIndex );
			}

			if (!xWeaponTypeList.DoModal()) 
			{
				return false;
			}

			xValue.SetValue(xWeaponTypeList.GetSelectionData());
			return true;
		}

		case AVP_BP_WEAPONSLOTTYPE:
		{
			ListSelection_Overlay xWeaponTypeList( "Pick The Weapon Slot Type" );

			for (u_int iIndex = 0; iIndex < AVP_InventoryGroup_Weapons::NUM_AVP_INVENTORYWEAPONSLOTTYPES; ++iIndex)
			{
				xWeaponTypeList.AddItem( s_aszWeaponSlotTypeNames[iIndex], iIndex );
			}

			if (!xWeaponTypeList.DoModal()) 
			{
				return false;
			}

			xValue.SetValue(xWeaponTypeList.GetSelectionData());
			return true;
		}

		case AVP_BP_IMPACTTYPE:
		{
			ListSelection_Overlay xImpactTypeList( "Pick The Impact Type" );

			for (u_int iIndex = 0; iIndex < AVP_GenericProjectileData::NUM_IMPACT_TYPES; ++iIndex)
			{
				xImpactTypeList.AddItem( s_aszImpactTypeNames[iIndex], iIndex );
			}

			if (!xImpactTypeList.DoModal()) 
			{
				return false;
			}

			xValue.SetValue(xImpactTypeList.GetSelectionData());
			return true;
		}

		case AVP_BP_ROLE:
		{
			ListSelection_Overlay xTypeOverlayFac( "Pick the team's role" );
			for( u_int j=0; j<AVP_Settings::AVP_NUM_ROLES; ++j )
			{
				xTypeOverlayFac.AddItem( AVP_Settings::GetRoleName(static_cast<AVP_Settings::Role>(j)), j );
			}

			if( !xTypeOverlayFac.DoModal() ) { return false; }
			
			xValue.SetValue( xTypeOverlayFac.GetSelectionData() );

			return true;
		} 

		case AVP_BP_RESPAWNTYPE:
		{
			ListSelection_Overlay xTypeOverlayFac( "Pick the respawn type" );
			for( u_int j=0; j<AVP_Settings::AVP_NUM_RESPAWNTYPES; ++j )
			{
				xTypeOverlayFac.AddItem( AVP_Settings::GetRespawnTypeName(static_cast<AVP_Settings::RespawnType>(j)), j );
			}

			if( !xTypeOverlayFac.DoModal() ) { return false; }
			
			xValue.SetValue( xTypeOverlayFac.GetSelectionData() );

			return true;
		} 

		case AVP_BP_PICKUPTYPE:
		{
			ListSelection_Overlay xPickupList( "Pick The pickup type" );

			for (u_int iIndex = 0; iIndex < AVP_Pickup::PICKUP_TOTAL; ++iIndex)
			{
				xPickupList.AddItem( s_aszPickupTypeNames[iIndex], iIndex );
			}

			if (!xPickupList.DoModal()) 
			{
				return false;
			}

			xValue.SetValue(xPickupList.GetSelectionData());

			return true;
		}

		case AVP_BP_AIWEAPONBEHAVIOURTYPE:
		{
			ListSelection_Overlay xPickupList( "Select the AI weapon behaviour type" );

			for (u_int iIndex = 0; iIndex < AVP_WEAPON_BEHAVIOUR_TYPE_MAX_TYPES; ++iIndex)
			{
				xPickupList.AddItem( s_aszWeaponBehaviourTypeNames[iIndex], iIndex );
			}

			if (!xPickupList.DoModal()) 
			{
				return false;
			}

			xValue.SetValue(xPickupList.GetSelectionData());

			return true;
		}

		case AVP_BP_BLUEPRINT_NOEXPORT:
		{
			Asura_Hash_ID			uBPType = ASURA_HASH_ID_UNSET;
			Asura_Hash_ID			uBPSelection = xValue.GetHashIDValue();
			BlueprintSelect_Overlay	xModalOverlay("Pick the blueprint", &uBPSelection, &uBPType );

			if(!xModalOverlay.DoModal())	{return false;}

			const Asura_Blueprint*	pxBlueprint		= Asura_Blueprint_System::GetBlueprintByHashID(uBPType, uBPSelection);
			const char*				szBlueprintName	= (pxBlueprint == NULL) ? "*None*" : pxBlueprint->GetName().GetString();

			xValue.SetValue( uBPSelection , szBlueprintName );

			return true;
		} 

		case AVP_BP_RUMBLE_EFFECT:
		{
			ListSelection_Overlay xPickupList( "Pick The rumble effect type" );

			for (u_int iIndex = 0; iIndex < RUMBLE_BASE_SYMWAVE + 1; ++iIndex)
			{
				xPickupList.AddItem( s_aszRumbleEffectNames[iIndex], iIndex );
			}

			if (!xPickupList.DoModal()) 
			{
				return false;
			}

			xValue.SetValue(xPickupList.GetSelectionData());

			return true;
		}

		case AVP_BP_RUMBLE_ADJUST:
		{
			ListSelection_Overlay xPickupList( "Pick The rumble adjust type" );

			for (u_int iIndex = 0; iIndex < RUMBLE_ADJUST_FLIP + 1; ++iIndex)
			{
				xPickupList.AddItem( s_aszRumbleAdjustNames[iIndex], iIndex );
			}

			if (!xPickupList.DoModal()) 
			{
				return false;
			}

			xValue.SetValue(xPickupList.GetSelectionData());

			return true;
		}

		case AVP_BP_RUMBLE_PRIORITY:
		{
			ListSelection_Overlay xPickupList( "Pick The rumble play type" );

			for (u_int iIndex = 0; iIndex < AVP_Rumble_System::RUMBLE_PLAY_TOTAL; ++iIndex)
			{
				xPickupList.AddItem( s_aszRumblePlayNames[iIndex], iIndex );
			}

			if (!xPickupList.DoModal()) 
			{
				return false;
			}

			xValue.SetValue(xPickupList.GetSelectionData());

			return true;
		}

		case AVP_BP_DSP_CHAIN:
		{
			ListSelection_Overlay xChainList( "Pick The DSP type" );

			for (int iIndex = 0; iIndex < Asura_Audio_System::GetNumDSPChains(); ++iIndex)
			{
				const Asura_Audio_DSPChain* pxChain = Asura_Audio_System::GetDSPChainByIndex( iIndex );
				if ( pxChain )
				{
					xChainList.AddItem( pxChain->m_xName.GetString(), Asura_GetHashID(pxChain->m_xName.GetString()) );
				}
			}
			if (!xChainList.DoModal()) 
			{
				return false;
			}

			xValue.SetValue(xChainList.GetSelectionData());

			return true;
		}

		case AVP_BP_SOUNDMIXER_PRESET:
		{
			ListSelection_Overlay xPresetList( "Pick The SoundMixer Preset" );

			xPresetList.AddItem( "*None*", ASURA_HASH_ID_UNSET );

			for (u_int uIndex = 0; uIndex < Asura_Sound_Mixer_System::GetNumberOfPresets(); ++uIndex)
			{
				const Asura_Sound_Mixer_Preset* pxPreset = Asura_Sound_Mixer_System::GetPresetByIndex( uIndex );
				if ( pxPreset )
				{
					xPresetList.AddItem( pxPreset->GetName(), Asura_GetHashID(pxPreset->GetName()) );
				}
			}
			if (!xPresetList.DoModal()) 
			{
				return false;
			}

			xValue.SetValue(xPresetList.GetSelectionData());

			return true;
		}

		case AVP_BP_GRAPPLEEVENT_TYPE:
		{
			ListSelection_Overlay xOverlay( "Select grapple event type" );

			for (int i=0; i<NUM_AVP_GRAPPLE_EVENT_TYPES; ++i)
			{
				xOverlay.AddItem( g_aszGrappleEventTypeNames[i], i );
			}
			xOverlay.AddItem("*None*", -1);

			if(!xOverlay.DoModal())
			{
				// pop up a window asking if they want it to be added as 'unset'
				YesNo_Overlay xYesNo("No event type selected. Do you wish to add the parameter anyway? This will have the value '*None*'.");
				if (!xYesNo.DoModal()) { return false; }

				xValue.SetValue(-1);
				return true;
			}

			xValue.SetValue(xOverlay.GetSelectionData());

			return true;
		}

		default: break;
	}

	return PARENT::GetValueForTemplatedType( iTemplatedType, uTemplateHashID, xParameterName, xValue );
}

int ToolsAVP_Blueprint_Edit_Object::GetTemplatedTypeFromTemplateID( Asura_Hash_ID uTemplateHashID ) const
{
	for( int i=AVP_START_OF_TEMPLATED_TYPES; i<AVP_END_OF_TEMPLATED_TYPES; ++i )
	{
		if( uTemplateHashID == Asura_GetHashID(s_apszAVPTemplatedTypeNames[i - AVP_START_OF_TEMPLATED_TYPES]) ) 
		{
			return i;
		}
	}

	return PARENT::GetTemplatedTypeFromTemplateID( uTemplateHashID );
}

const char* ToolsAVP_Blueprint_Edit_Object::GetTemplatedTypeName( u_int uType ) const
{ 
	if( (uType >= AVP_START_OF_TEMPLATED_TYPES) 
	 && (uType < AVP_END_OF_TEMPLATED_TYPES) )
	{
		return s_apszAVPTemplatedTypeNames[uType - AVP_START_OF_TEMPLATED_TYPES];
	}

	return PARENT::GetTemplatedTypeName( uType ); 
}

//================================================================================
// Private functions...
//================================================================================


/// End of file. ///
