// Saving functions
//////////////////////////////
//	Mechanics Editor
/////////////////////////////////////////
#include "StdAfx.h"

#include "_MecCard.hpp"
#include "EMECCrdT.hpp"
#include "EMECStrg.hpp"
#include "EMECFlds.hpp"

//External Modules
#include "ErO.h"
//End of External Modules

//*******************************************************************************************
// Will call one of the specific saving functions
void CPA_Meca_Card::m_fn_vSaveMecaCard(SCR_tdst_File_Description *p_tdstFile,
																			 SCR_tde_Ntfy_Action _eAction)
{
	ERROR_ASSERT( m_fn_pclGetCardType()->m_p_fn_vSave != NULL );
	
	//Moves to the End of File
	if ( _eAction == SCR_EA_Ntfy_AddSection )
 		SCR_fn_v_SvL1_ToEndSection(p_tdstFile);

	m_fn_pclGetCardType()->m_p_fn_vSave(p_tdstFile, this);

	SCR_M_SvL0_SaveBlankLine(p_tdstFile);
} 


//*******************************************************************************************
void fn_vSaveCard6(SCR_tdst_File_Description *p_tdstFile, CPA_Meca_Card *pclCard)
{
	CString csCurrentLine;

	csCurrentLine.Format("%s:%s", C_SectionIdCardCamera,
																pclCard->GetName());
 
	SCR_M_SvL0_SaveBeginSection(p_tdstFile,
															M_MAKECHAR(csCurrentLine),
															SCR_CC_C_Cfg_EOL);
	
	//Gets Base structure
	DNM_stMecCameraIdCard	* pStruct = (DNM_stMecCameraIdCard *)pclCard->m_fn_pvGetBaseAddress();

	//Angular Speed
	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntryAngularSpeed,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	2,
																	"%f",
																	DNM_M_xCameraIdCardGetAngularSpeed(pStruct));

	//Linear Speed
	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntryLinearSpeed,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	2,
																	"%f",
																	DNM_M_xCameraIdCardGetLinearSpeed(pStruct));

	//Speeding Up
	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntrySpeedingUp,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	2,
																	"%f",
																	DNM_M_xCameraIdCardGetSpeedingUp(pStruct));


	//Closes file's main section
	SCR_M_SvL0_SaveEndSection(p_tdstFile, SCR_CC_C_Cfg_EOL);
}



//*******************************************************************************************
void fn_vSaveCardRay2Egypte1(SCR_tdst_File_Description *p_tdstFile, CPA_Meca_Card *pclCard)
{
	CString csCurrentLine;

	csCurrentLine.Format("%s:%s", C_SectionIdCardBase,
																pclCard->GetName());
 
	SCR_M_SvL0_SaveBeginSection(p_tdstFile,
															M_MAKECHAR(csCurrentLine),
															SCR_CC_C_Cfg_EOL);

	//Gets Base structure
	DNM_tdstMecBaseIdCard	*pStruct = (DNM_tdstMecBaseIdCard *)pclCard->m_fn_pvGetBaseAddress();

	// Animation
	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntryBaseAnimation,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	2,
																	"%i",
																	DNM_M_bBaseIdCardIsAnimation(pStruct));

	// Collide
	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntryBaseCollide,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	2,
																	"%i",
																	DNM_M_bBaseIdCardIsCollide(pStruct));

	// Gravity
	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntryBaseGravity,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	2,
																	"%i",
																	DNM_M_bBaseIdCardIsGravity(pStruct));


	// Tilt
	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntryBaseTilt,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	2,
																	"%i",
																	DNM_M_bBaseIdCardIsTilt(pStruct));

	// Gi
	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntryBaseGi,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	2,
																	"%i",
																	DNM_M_bBaseIdCardIsGi(pStruct));


	// Climb
	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntryBaseClimb,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	2,
																	"%i",
																	DNM_M_bBaseIdCardIsClimb(pStruct));


	// On ground
	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntryBaseOnGround,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	2,
																	"%i",
																	DNM_M_bBaseIdCardIsOnGround(pStruct));


	// Spider
	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntryBaseSpider,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	2,
																	"%i",
																	DNM_M_bBaseIdCardIsSpider(pStruct));


	// Shoot
	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntryBaseShoot,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	2,
																	"%i",
																	DNM_M_bBaseIdCardIsShoot(pStruct));


	// Swim
	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntryBaseSwim,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	2,
																	"%i",
																	DNM_M_bBaseIdCardIsSwim(pStruct));


	// Collision control
	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntryBaseCollisionControl,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	2,
																	"%i",
																	DNM_M_bBaseIdCardIsCollisionControl(pStruct));


	// Keep speed.z
	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntryBaseKeepWallSpeedZ,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	2,
																	"%i",
																	DNM_M_bBaseIdCardIsKeepWallSpeedZ(pStruct));


	// Speed limit
	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntryBaseSpeedLimit,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	2,
																	"%i",
																	DNM_M_bBaseIdCardIsSpeedLimit(pStruct));

	// Inertia
	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntryBaseInertia,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	2,
																	"%i",
																	DNM_M_bBaseIdCardIsInertia(pStruct));

	// Stream
	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntryBaseStream,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	2,
																	"%i",
																	DNM_M_bBaseIdCardIsStream(pStruct));

	// Stick on platform
	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntryBaseStickOnPlatform,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	2,
																	"%i",
																	DNM_M_bBaseIdCardIsStickOnPlatform(pStruct));

	// scale
	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntryBaseUseScale,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	2,
																	"%i",
																	DNM_M_bBaseIdCardIsScale(pStruct));

	// Gravity factor
	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntryBaseGravityFactor,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	2,
																	"%lf",
																	DNM_M_xBaseIdCardGetGravityFactor(pStruct));


	// slide
	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntryBaseSlide,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	2,
																	"%lf",
																	DNM_M_xBaseIdCardGetSlide(pStruct));

	// rebound
	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntryBaseRebound,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	2,
																	"%lf",
																	DNM_M_xBaseIdCardGetRebound(pStruct));

	// slope limit

	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntryBaseSlopeLimit,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	2,
																	"%lf",
																	MTH_M_xTan (MTH_M_xDegToRad (DNM_M_xBaseIdCardGetSlopeLimit(pStruct))) );


	// inertia x
	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntryBaseInertiaFactorX,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	2,
																	"%lf",
																	DNM_M_xBaseIdCardGetInertiaFactorX(pStruct) );

	// inertia y
	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntryBaseInertiaFactorY,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	2,
																	"%lf",
																	DNM_M_xBaseIdCardGetInertiaFactorY(pStruct) );

	// inertia z
	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntryBaseInertiaFactorZ,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	2,
																	"%lf",
																	DNM_M_xBaseIdCardGetInertiaFactorZ(pStruct) );

	// tilt intensity
	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntryBaseTiltIntensity,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	2,
																	"%lf",
																	DNM_M_xBaseIdCardGetTiltIntensity(pStruct) );

	// tilt inertia
	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntryBaseTiltInertia,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	2,
																	"%lf",
																	DNM_M_xBaseIdCardGetTiltInertia(pStruct) );


	// tilt origin
	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntryBaseTiltOrigin,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	2,
																	"%lf",
																	DNM_M_xBaseIdCardGetTiltOrigin(pStruct) );


	// max speed
	SCR_M_SvL0_SaveEntry(	p_tdstFile,
												C_EntryBaseMaxSpeed,
												SCR_CC_C_Cfg_NoChar);

	SCR_fn_v_SvL0_SaveParameters_MP(p_tdstFile,
																	SCR_EF_SvL0_Scanf,
																	4,
																	"%lf,%lf,%lf",
																	MTH3D_M_xGetXofVector(DNM_M_pBaseIdCardGetMaxSpeed(pStruct)),
																	MTH3D_M_xGetYofVector(DNM_M_pBaseIdCardGetMaxSpeed(pStruct)),
																	MTH3D_M_xGetZofVector(DNM_M_pBaseIdCardGetMaxSpeed(pStruct))
																	);

	//Closes file's main section
	SCR_M_SvL0_SaveEndSection(p_tdstFile, SCR_CC_C_Cfg_EOL);
}
//ENDANNECY jt }
