// IA Debugger : Global Functions
//
// YB
//
//////////////////////////////////////////////
#include "StdAfx.h"

#include "IADGlob.hpp"
#include "_IADItrf.hpp"

// For "IncAI.h" !!
#include "ACP_Base.h"
#include "IncAI.h"
// End For "IncAI.h" !!

#include "x:\cpa\main\inc\_EditID.h"

#define TID_C_szUnknownEntryName	"<< Unknown >>"

//*****************************************************************************************
CString IAD_fn_csComputeValueFromGetSetParam(struct tdstGetSetParam_ *_p_tdstGetSetParam)
{
	CString csReturnedString;

	switch ( M_GetSetParam_Type(_p_tdstGetSetParam) )
	{
	case E_vt_Boolean:
		csReturnedString.Format("%s", (M_GetSetParam_cValue(_p_tdstGetSetParam) == 0) ? "False" : "True");
		break;
	case E_vt__128To127:
		csReturnedString.Format("%i", M_GetSetParam_cValue(_p_tdstGetSetParam));
		break;
	case E_vt_0To255:
		csReturnedString.Format("%i", M_GetSetParam_ucValue(_p_tdstGetSetParam));
		break;
	case E_vt__32768To32767:
		csReturnedString.Format("%i", M_GetSetParam_wValue(_p_tdstGetSetParam));
		break;
	case E_vt_0To65535:
		csReturnedString.Format("%i", M_GetSetParam_uwValue(_p_tdstGetSetParam));
		break;
	case E_vt_Integer:
		csReturnedString.Format("%ld", M_GetSetParam_lValue(_p_tdstGetSetParam));
		break;
	case E_vt_PositiveInteger:
		csReturnedString.Format("%u", M_GetSetParam_ulValue(_p_tdstGetSetParam));
		break;
	case E_vt_Float:
		csReturnedString.Format("%f", M_GetSetParam_xValue(_p_tdstGetSetParam));
		break;
	case E_vt_String:
		csReturnedString.Format("%s", M_GetSetParam_szString(_p_tdstGetSetParam));
		break;
	case E_vt_Vector:
		csReturnedString.Format("%f ; %f ; %f", M_GetSetParam_stVertexValue(_p_tdstGetSetParam).xX,
																						M_GetSetParam_stVertexValue(_p_tdstGetSetParam).xY,
																						M_GetSetParam_stVertexValue(_p_tdstGetSetParam).xZ);
		break;
	case E_vt_Family:
		csReturnedString = IAD_fn_csSearchNameFromMotorPointer((void *)NULL, C_szFamilyTypeName);
		break;
	case E_vt_Comport:
		csReturnedString = M_GetNameComport(M_GetSetParam_pComport(_p_tdstGetSetParam));
		break;
	case E_vt_Perso:
		csReturnedString = IAD_fn_csSearchNameFromMotorPointer((void *)M_GetSetParam_p_stEngineObjValue(_p_tdstGetSetParam), C_szActorInstanceTypeName);
		break;
	case E_vt_WayPoint:
		csReturnedString = IAD_fn_csSearchNameFromMotorPointer((void *)M_GetSetParam_WayPointValue(_p_tdstGetSetParam), C_szWayPointTypeName);
		break;
	//case E_vt_Way:
	//	csReturnedString = IAD_fn_csSearchNameFromMotorPointer((void *)M_GetSetParam_WayValue(_p_tdstGetSetParam), C_szWayTypeName);
	//	break;
	case E_vt_Action:
		csReturnedString = IAD_fn_csSearchNameFromMotorPointer((void *)M_GetSetParam_ActionValue(_p_tdstGetSetParam), C_szStateTypeName);
		break;
// Shaitan Clean Env {
/*
	case E_vt_Surface:
		csReturnedString = IAD_fn_csSearchNameFromMotorPointer((void *)M_GetSetParam_SurfaceValue(_p_tdstGetSetParam), C_szSurfaceTypeName);
		break;
*/
//End Shaitan Clean Env }
	case E_vt_LipsSynchro:
		csReturnedString = IAD_fn_csSearchNameFromMotorPointer((void *)M_GetSetParam_hLipsSynchro(_p_tdstGetSetParam), C_szLipSynchroTypeName);
		break;
	case E_vt_ObjectTable:
		csReturnedString = IAD_fn_csSearchNameFromMotorPointer((void *)M_GetSetParam_hObjectTable(_p_tdstGetSetParam), C_szObjectTableTypeNAme);
		break;
	case E_vt_SuperObject:
		csReturnedString = IAD_fn_csSearchNameFromMotorPointer((void *)M_GetSetParam_SectorValue(_p_tdstGetSetParam), /*C_szObjectTableTypeNAme*/"");
		break;
// Shaitan Clean Env {
/*
	case E_vt_Environment:
		csReturnedString = IAD_fn_csSearchNameFromMotorPointer((void *)M_GetSetParam_EnvironmentValue(_p_tdstGetSetParam), C_szEnvironmentTypeName);
		break;
*/
//End Shaitan Clean Env }
	case E_vt_SoundEvent:
		csReturnedString = IAD_fn_csSearchNameFromMotorPointer((void *)M_GetSetParam_SoundEvent(_p_tdstGetSetParam), C_szSoundEventTypeName);
		break;

	default:
		csReturnedString = "Unknown";
		break;
	};

	return csReturnedString;
}

//*****************************************************************************************
CString IAD_fn_csSearchNameFromMotorPointer(void *_pvMotorData,
																						CString _csEditorObjectType)
{
	CString csReturnedString;

	CPA_BaseObject *p_clBO = g_pclInterface->GetMainWorld()->fn_p_oFindObjectWithEngine(_pvMotorData, _csEditorObjectType);
	
	csReturnedString = TID_C_szUnknownEntryName;
	if ( p_clBO != NULL )
		csReturnedString = p_clBO->GetName();

	return csReturnedString;
}
