485 lines
15 KiB
C++
485 lines
15 KiB
C++
// To Save Models
|
|
//
|
|
// YB
|
|
/////////////////////////////////////
|
|
#include "StdAfx.h"
|
|
|
|
#include "ACP_Base.h"
|
|
#include "ITF.h"
|
|
#include "TAC.h"
|
|
#include "TFa.h"
|
|
#include "IncMEC.h"
|
|
#define D_State_Define
|
|
#include "IncGAM.h"
|
|
#undef D_State_Define
|
|
#include "GLI.h"
|
|
|
|
#include "EDACInst.hpp"
|
|
#include "EDACModl.hpp"
|
|
#include "EDACDgIf.hpp"
|
|
#include "EDACStrg.hpp"
|
|
#include "Defines.hpp"
|
|
|
|
//-----------------IR-------------------------
|
|
#include "EdIRStrg.hpp"
|
|
#include "EdIRBeEn.hpp"
|
|
#include "EdIRBeHa.hpp"
|
|
#include "EDACQuer.hpp"
|
|
//--------------------------------------------
|
|
|
|
#undef CPA_WANTS_IMPORT
|
|
#undef CPA_EXPORT
|
|
#define CPA_WANTS_EXPORT
|
|
//-----------------IR-------------------------
|
|
#include "EdIRIRD.hpp"
|
|
//--------------------------------------------
|
|
#include "_Actors.hpp"
|
|
#undef CPA_WANTS_EXPORT
|
|
#define CPA_WANTS_IMPORT
|
|
|
|
BOOL OAC_fn_bSaveData(SCRIPT_tdstSaveFile *p_tdstScriptFile,
|
|
CTL_Editor_Data *_pclData);
|
|
|
|
////////////////////////////////
|
|
// Models : Saving functions //
|
|
////////////////////////////////
|
|
|
|
//*************************************************************************
|
|
// Model Saving Function
|
|
//*************************************************************************
|
|
void EdActors_EditorActorModel::m_fn_vSaveActor(SCR_tdst_File_Description *p_stFile)
|
|
{
|
|
CString csCurrentLine;
|
|
CString csNextAndPreviousLine;
|
|
|
|
//Scripts header
|
|
SCR_M_SvL0_SaveScriptFileHeader(p_stFile);
|
|
|
|
//Actors Editor header
|
|
csNextAndPreviousLine = "+++++++++++++++++++++++++++++++++++++++++++";
|
|
csCurrentLine = "+ Actors Editor +";
|
|
SCR_M_SvL0_SaveComment(p_stFile, M_MAKECHAR(csNextAndPreviousLine));
|
|
SCR_M_SvL0_SaveComment(p_stFile, M_MAKECHAR(csCurrentLine));
|
|
SCR_M_SvL0_SaveComment(p_stFile, M_MAKECHAR(csNextAndPreviousLine));
|
|
csCurrentLine = "+ Version " + g_pclInterface->m_fn_csGetEditorVersion() + " +";
|
|
SCR_M_SvL0_SaveComment(p_stFile, M_MAKECHAR(csCurrentLine));
|
|
SCR_M_SvL0_SaveBlankLine(p_stFile);
|
|
|
|
//Computes date
|
|
SYSTEMTIME stSystemTime;
|
|
::GetLocalTime(&stSystemTime);
|
|
CTime cTime(stSystemTime);
|
|
CString csDate = cTime.Format( "%A, %B %d, %Y, %Hh%Mm ");
|
|
|
|
csCurrentLine = " Save date : " + csDate;
|
|
SCR_M_SvL0_SaveComment(p_stFile, M_MAKECHAR(csCurrentLine));
|
|
SCR_M_SvL0_SaveComment(p_stFile, M_MAKECHAR(csNextAndPreviousLine));
|
|
SCR_M_SvL0_SaveBlankLine(p_stFile);
|
|
|
|
csCurrentLine.Format("########### Model %s ###########", m_fn_csGetActorName());
|
|
csNextAndPreviousLine = "######################";
|
|
while ( csNextAndPreviousLine.GetLength() < csCurrentLine.GetLength() )
|
|
csNextAndPreviousLine += '#';
|
|
|
|
SCR_M_SvL0_SaveComment(p_stFile, M_MAKECHAR(csNextAndPreviousLine));
|
|
SCR_M_SvL0_SaveComment(p_stFile, M_MAKECHAR(csCurrentLine));
|
|
SCR_M_SvL0_SaveComment(p_stFile, M_MAKECHAR(csNextAndPreviousLine));
|
|
SCR_M_SvL0_SaveBlankLine(p_stFile);
|
|
|
|
csCurrentLine.Format("%s:%s", g_c_csActorScriptModelSectionName,
|
|
m_fn_csGetActorName());
|
|
|
|
SCR_M_SvL0_SaveBeginSection(p_stFile,
|
|
M_MAKECHAR(csCurrentLine),
|
|
SCR_CC_C_Cfg_EOL);
|
|
SCR_M_SvL0_SaveBlankLine(p_stFile);
|
|
|
|
//---------------------------------------------------------------------
|
|
//Saves Model type
|
|
SCR_M_SvL0_SaveEntry( p_stFile,
|
|
M_MAKECHAR(g_c_csModelType),
|
|
SCR_CC_C_Cfg_NoChar);
|
|
|
|
if ( m_pclActor->m_fn_bIsAGenDoor() )
|
|
csCurrentLine = g_c_csModelTypeGenDoor;
|
|
else
|
|
csCurrentLine = g_c_csModelTypeActor;
|
|
|
|
SCR_fn_v_SvL0_SaveParameters_MP(p_stFile,
|
|
SCR_EF_SvL0_Scanf,
|
|
2,
|
|
"%s",
|
|
M_MAKECHAR(csCurrentLine));
|
|
SCR_M_SvL0_SaveBlankLine(p_stFile);
|
|
|
|
//---------------------------------------------------------------------
|
|
//Saves Bitmap Name
|
|
if ( m_fn_csGetBitmapName().IsEmpty() )
|
|
csCurrentLine = "<< Unknown Bitmap name >>";
|
|
else
|
|
csCurrentLine = M_MAKECHAR(m_fn_csGetBitmapName());
|
|
|
|
SCR_M_SvL0_SaveEntry( p_stFile,
|
|
M_MAKECHAR(g_c_csBitmapName),
|
|
SCR_CC_C_Cfg_NoChar);
|
|
|
|
SCR_fn_v_SvL0_SaveParameters_MP(p_stFile,
|
|
SCR_EF_SvL0_Scanf,
|
|
2,
|
|
"%s",
|
|
M_MAKECHAR(csCurrentLine));
|
|
SCR_M_SvL0_SaveBlankLine(p_stFile);
|
|
|
|
//---------------------------------------------------------------------
|
|
//Saves base Family
|
|
if ( m_pclActor->m_pub_fn_pclGetFamily() != NULL )
|
|
csCurrentLine = m_pclActor->m_pub_fn_pclGetFamily()->GetName();
|
|
else
|
|
csCurrentLine = "<< Unknown Family name >>";
|
|
|
|
SCR_M_SvL0_SaveEntry( p_stFile,
|
|
M_MAKECHAR(g_c_csActorFamily),
|
|
SCR_CC_C_Cfg_NoChar);
|
|
|
|
SCR_fn_v_SvL0_SaveParameters_MP(p_stFile,
|
|
SCR_EF_SvL0_Scanf,
|
|
2,
|
|
"%s",
|
|
M_MAKECHAR(csCurrentLine));
|
|
SCR_M_SvL0_SaveBlankLine(p_stFile);
|
|
|
|
//---------------------------------------------------------------------
|
|
//Saves AI Model Name
|
|
//-----------------IR-------------------------
|
|
if(EDAC_fn_bMustSaveAIEntryInModel(m_pclBrain))
|
|
{
|
|
CString csBrainSectionEntry;
|
|
csBrainSectionEntry= m_pclActor->m_pub_fn_pclGetFamily()->GetName()+"\\";
|
|
csBrainSectionEntry+=m_fn_csGetActorName()+"\\";
|
|
csBrainSectionEntry+=m_fn_csGetActorName();
|
|
|
|
SCR_M_SvL0_SaveEntry( p_stFile,
|
|
M_MAKECHAR(g_c_csBrainName),
|
|
SCR_CC_C_Cfg_NoChar);
|
|
|
|
SCR_fn_v_SvL0_SaveParameters_MP(p_stFile,
|
|
SCR_EF_SvL0_Scanf,
|
|
2,
|
|
"%s",
|
|
M_MAKECHAR(csBrainSectionEntry));
|
|
SCR_M_SvL0_SaveBlankLine(p_stFile);
|
|
}
|
|
|
|
//BEGIN ROMTEAM Cristi Petrescu 98-06-
|
|
//---------------------------------------------------------------------
|
|
//Saves AI Private variable status
|
|
SCR_M_SvL0_SaveEntry( p_stFile,
|
|
M_MAKECHAR(g_c_csShowPrivateVariable),
|
|
SCR_CC_C_Cfg_NoChar);
|
|
|
|
SCR_fn_v_SvL0_SaveParameters_MP(p_stFile,
|
|
SCR_EF_SvL0_Scanf,
|
|
2,
|
|
"%d",
|
|
(int) m_pclBrain -> m_bShowPrivateVariable);
|
|
|
|
SCR_M_SvL0_SaveBlankLine(p_stFile);
|
|
//END ROMTEAM Cristi Petrescu 98-06-
|
|
|
|
//--------------------------------------------
|
|
|
|
//---------------------------------------------------------------------
|
|
//Saves all MS
|
|
csCurrentLine = "___________________ Group Separator ___________________";
|
|
BOOL bReturn = TRUE;
|
|
EdActors_ActorMiniStructureList *pclCurrentGroup;
|
|
POSITION pos = m_clListOfAMSLists.GetHeadPosition();
|
|
|
|
while ( (pos != NULL) && (bReturn) )
|
|
{
|
|
SCR_M_SvL0_SaveComment(p_stFile, M_MAKECHAR(csCurrentLine));
|
|
SCR_M_SvL0_SaveBlankLine(p_stFile);
|
|
|
|
pclCurrentGroup = m_clListOfAMSLists.GetNext(pos);
|
|
|
|
bReturn = m_fn_bSaveMSList(p_stFile, pclCurrentGroup);
|
|
}
|
|
|
|
if ( !bReturn )
|
|
{
|
|
CString csMessage = "There was a problem to save Editor Actor Model\ncalled ' ";
|
|
csMessage += m_fn_csGetActorName() + " ',\nin the MS save process, in the group :\n";
|
|
csMessage += pclCurrentGroup->m_fn_csGetGroupScriptName();
|
|
|
|
EdActors_InformationDialog dial(&g_oBaseFrame, csMessage);
|
|
dial.DoModal();
|
|
}
|
|
|
|
//Closes file's main section
|
|
SCR_M_SvL0_SaveEndSection(p_stFile, SCR_CC_C_Cfg_EOL);
|
|
}
|
|
|
|
////////////////////////////////
|
|
// Actors : Saving functions //
|
|
////////////////////////////////
|
|
|
|
//*************************************************************************
|
|
BOOL EdActors_EditorActor::m_fn_bSaveMSList(SCRIPT_tdstSaveFile *p_tdstScriptFile,
|
|
EdActors_ActorMiniStructureList *mclMSList)
|
|
{
|
|
BOOL bReturn = TRUE;
|
|
|
|
POSITION pos = mclMSList->GetHeadPosition();
|
|
while ( (pos != NULL) && (bReturn) )
|
|
{
|
|
bReturn = mclMSList->GetNext(pos)->m_fn_bSaveMS(p_tdstScriptFile, mclMSList->m_fn_csGetGroupScriptName());
|
|
|
|
SCR_M_SvL0_SaveBlankLine(p_tdstScriptFile);
|
|
}
|
|
|
|
return bReturn;
|
|
}
|
|
|
|
|
|
//////////////////////////
|
|
// MS : Saving function //
|
|
//////////////////////////
|
|
|
|
//*************************************************************************
|
|
BOOL EdActors_ActorMiniStructure::m_fn_bSaveMS(SCRIPT_tdstSaveFile *p_tdstScriptFile,
|
|
CString csGroupScriptName)
|
|
{
|
|
BOOL bReturn = TRUE;
|
|
|
|
char *a_szParams_3;
|
|
if ( m_fn_bIsAllocated() )
|
|
a_szParams_3 = (char *)LPCTSTR(g_c_csAllocatedMS);
|
|
else
|
|
a_szParams_3 = (char *)LPCTSTR(g_c_csNotAllocatedMS);
|
|
|
|
CString csSection;
|
|
csSection.Format("%s:%s(%s,%s)", g_c_csMSSection,
|
|
m_fn_csGetScriptName(),
|
|
csGroupScriptName,
|
|
a_szParams_3);
|
|
|
|
SCR_M_SvL0_SaveBeginSection(p_tdstScriptFile,
|
|
M_MAKECHAR(csSection),
|
|
SCR_CC_C_Cfg_EOL);
|
|
|
|
if ( m_fn_bIsAllocated() )
|
|
{
|
|
POSITION pos = m_pclDataList->GetHeadPosition();
|
|
while ( pos != NULL )
|
|
OAC_fn_bSaveData(p_tdstScriptFile, m_pclDataList->GetNext(pos));
|
|
}
|
|
|
|
//Closes MS Section
|
|
SCRIPT_vSaveEndSection(p_tdstScriptFile);
|
|
|
|
return bReturn;
|
|
}
|
|
|
|
//////////////////////////////////////////
|
|
// Datas : Saving & Loading functions //
|
|
//////////////////////////////////////////
|
|
|
|
//************************************************************************
|
|
BOOL OAC_fn_bSaveData(SCRIPT_tdstSaveFile *p_tdstScriptFile,
|
|
CTL_Editor_Data *_pclData)
|
|
{
|
|
BOOL bReturn = TRUE;
|
|
|
|
//Saves Data
|
|
////////////////////////////
|
|
char *a_szParams[64]; //Limit to 64 parameters !!!
|
|
////////////////////////////
|
|
switch ( OAC_fn_tdeGetLink(_pclData) )
|
|
{
|
|
case OAC_LINK_MODE__LINKED:
|
|
a_szParams[0] = (char *)LPCTSTR(g_c_csLinkedField);
|
|
break;
|
|
|
|
case OAC_LINK_MODE__NOT_LINKED:
|
|
a_szParams[0] = (char *)LPCTSTR(g_c_csNotLinkedField);
|
|
break;
|
|
|
|
case OAC_LINK_MODE__ALWAYS_LINKED:
|
|
a_szParams[0] = (char *)LPCTSTR(g_c_csAlwaysLinkedField);
|
|
break;
|
|
|
|
case OAC_LINK_MODE__NEVER_LINKED:
|
|
a_szParams[0] = (char *)LPCTSTR(g_c_csNeverLinkedField);
|
|
break;
|
|
|
|
default:
|
|
bReturn = FALSE;
|
|
break;
|
|
}
|
|
|
|
CStringList *pcslParams = _pclData->m_fn_pcslFormatDataValueString();
|
|
long c_lI = 1; //Param #0 is reserved !!
|
|
POSITION pos = pcslParams->GetHeadPosition();
|
|
while ( pos != NULL )
|
|
{
|
|
a_szParams[c_lI] = (char *)LPCTSTR(pcslParams->GetNext(pos));
|
|
c_lI ++;
|
|
}
|
|
|
|
SCR_M_SvL0_SaveEntry( p_tdstScriptFile,
|
|
M_MAKECHAR(_pclData->m_pub_fn_csGetDataName()),
|
|
SCR_CC_C_Cfg_NoChar);
|
|
|
|
SCR_fn_v_SvL0_SaveParameters_AP(p_tdstScriptFile,
|
|
SCR_EF_SvL0_Normal,
|
|
c_lI,
|
|
a_szParams);
|
|
|
|
return bReturn;
|
|
}
|
|
|
|
|
|
// Shaitan => state list in the level
|
|
//////////////////////
|
|
// Save State List //
|
|
//////////////////////
|
|
//************************************************************************
|
|
void EdActors_MyDocument::s_m_fn_vCallBackSaveStateList (SCR_tdst_File_Description *_p_stFile,
|
|
char *_p_szSectionName,
|
|
void *_p_vData,
|
|
SCR_tde_Ntfy_Action _eAction)
|
|
{
|
|
CPA_Family *pFamily = (CPA_Family *) _p_vData;
|
|
CPA_Action *pAction;
|
|
CPA_State *pState;
|
|
POSITION pos, pos1;
|
|
|
|
char szSectionName[SCR_CV_ui_Cfg_MaxLenName];
|
|
char szFileName[SCR_CV_ui_Cfg_MaxLenName];
|
|
|
|
// save begin section
|
|
SCR_fn_v_RdL0_ComputeSectionName(szSectionName, NULL, C_SectionCreateListOfState, "");
|
|
SCR_M_SvL0_SaveBeginSection(_p_stFile, szSectionName, SCR_CC_C_Cfg_EOL);
|
|
|
|
// for each used action of the family
|
|
pos = pFamily->m_oListOfUsedActions.GetHeadPosition();
|
|
while (pos)
|
|
{
|
|
pAction = pFamily->m_oListOfUsedActions.GetNext(pos);
|
|
|
|
// for each state of the action
|
|
pos1 = pAction->m_oListOfStates.GetHeadPosition();
|
|
while (pos1)
|
|
{
|
|
pState = pAction->m_oListOfStates.GetNext(pos1);
|
|
|
|
// save entry
|
|
SCR_M_SvL0_SaveEntry(_p_stFile, C_Entry_State, SCR_CC_C_Cfg_NoChar);
|
|
// compute section name for state
|
|
sprintf(szFileName, "%s\\%s.sta", pFamily->GetName(), pFamily->GetName());
|
|
SCR_fn_v_RdL0_ComputeSectionName(szSectionName, szFileName, C_SectionCreateNewState, (char *) (LPCSTR) pState->GetName());
|
|
// save parameter
|
|
SCR_fn_v_SvL0_SaveParameters_MP(_p_stFile, SCR_EF_SvL0_Scanf, 1, "%s", szSectionName);
|
|
}
|
|
}
|
|
SCR_M_SvL0_SaveEndSection(_p_stFile, SCR_CC_C_Cfg_EOL);
|
|
}
|
|
// End Shaitan => state list in the level
|
|
|
|
// Shaitan => module list in the level
|
|
//////////////////////
|
|
// Save PO List //
|
|
//////////////////////
|
|
//************************************************************************
|
|
void EdActors_MyDocument::s_m_fn_vCallBackSavePOList (SCR_tdst_File_Description *_p_stFile,
|
|
char *_p_szSectionName,
|
|
void *_p_vData,
|
|
SCR_tde_Ntfy_Action _eAction)
|
|
{
|
|
CPA_Family *pFamily = (CPA_Family *) _p_vData;
|
|
CPA_BaseObject *pPO;
|
|
POSITION pos;
|
|
|
|
char szSectionName[SCR_CV_ui_Cfg_MaxLenName];
|
|
|
|
// save begin section
|
|
SCR_fn_v_RdL0_ComputeSectionName(szSectionName, NULL, C_SectionCreateListOfPOs, "");
|
|
SCR_M_SvL0_SaveBeginSection(_p_stFile, szSectionName, SCR_CC_C_Cfg_EOL);
|
|
|
|
// for each used action of the family
|
|
pos = pFamily->m_oListOfUsedPOs.GetHeadPosition();
|
|
while (pos)
|
|
{
|
|
pPO = pFamily->m_oListOfUsedPOs.GetNext(pos);
|
|
|
|
// save entry
|
|
SCR_M_SvL0_SaveEntry(_p_stFile, C_Entry_LoadPO, SCR_CC_C_Cfg_NoChar);
|
|
// save parameter
|
|
SCR_fn_v_SvL0_SaveParameters_MP(_p_stFile, SCR_EF_SvL0_Scanf, 1, "%s", (char *) (LPCSTR) ((CPA_SaveObject *)pPO)->GetReferencedSectionName());
|
|
}
|
|
SCR_M_SvL0_SaveEndSection(_p_stFile, SCR_CC_C_Cfg_EOL);
|
|
}
|
|
// End Shaitan => module list in the level
|
|
|
|
//////////////////////
|
|
// Save of FIX file //
|
|
//////////////////////
|
|
//************************************************************************
|
|
void EdActors_MyDocument::s_m_fn_vCallBackSaveFixFile(SCR_tdst_File_Description *_p_stFile,
|
|
char *_p_szSectionName,
|
|
void *_p_vData,
|
|
SCR_tde_Ntfy_Action _eAction)
|
|
{
|
|
const CString c_csPreLoadSection_EntryName = "PreloadSection";
|
|
const CString c_csSecondPassForCharacter_EntryName = "SecondPassForCharacter";
|
|
|
|
//Begins main Section
|
|
SCR_M_SvL0_SaveBeginSection(_p_stFile,
|
|
"PreloadSectionInFix:Characters",
|
|
SCR_CC_C_Cfg_EOL);
|
|
|
|
//Recurses for all Instances
|
|
g_pclInterface->m_clDocument.m_pri_fn_vSaveAllActorsInFixFile(_p_stFile, &g_pclInterface->m_clDocument.m_clInstancesList, c_csPreLoadSection_EntryName);
|
|
//Recurses for all Always
|
|
g_pclInterface->m_clDocument.m_pri_fn_vSaveAllActorsInFixFile(_p_stFile, &g_pclInterface->m_clDocument.m_clAlwaysList, c_csPreLoadSection_EntryName);
|
|
|
|
SCR_M_SvL0_SaveBlankLine(_p_stFile);
|
|
|
|
//Recurses for all Instances
|
|
g_pclInterface->m_clDocument.m_pri_fn_vSaveAllActorsInFixFile(_p_stFile, &g_pclInterface->m_clDocument.m_clInstancesList, c_csSecondPassForCharacter_EntryName);
|
|
//Recurses for all Always
|
|
g_pclInterface->m_clDocument.m_pri_fn_vSaveAllActorsInFixFile(_p_stFile, &g_pclInterface->m_clDocument.m_clAlwaysList, c_csSecondPassForCharacter_EntryName);
|
|
|
|
//Closes main Section
|
|
SCRIPT_vSaveEndSection(_p_stFile);
|
|
}
|
|
|
|
//************************************************************************
|
|
void EdActors_MyDocument::m_pri_fn_vSaveAllActorsInFixFile(SCR_tdst_File_Description *_p_stFile,
|
|
CPA_BaseObjectList *_pclList,
|
|
CString _csEntryName)
|
|
{
|
|
//Recurses for all Actors...
|
|
|
|
//... for 'PreloadSection' entries
|
|
CPA_Actor *pclCurrentActor;
|
|
Position pos = _pclList->GetHeadPosition();
|
|
while ( pos != 0 )
|
|
{
|
|
pclCurrentActor = (CPA_Actor *)_pclList->GetNext(pos);
|
|
|
|
if ( (pclCurrentActor->m_fn_bIsAnInstance()) && (pclCurrentActor->m_pub_fn_bIsInFix()) )
|
|
{
|
|
SCR_M_SvL0_SaveEntry( _p_stFile,
|
|
M_MAKECHAR(_csEntryName),
|
|
SCR_CC_C_Cfg_NoChar);
|
|
|
|
SCR_fn_v_SvL0_SaveParameters_MP(_p_stFile,
|
|
SCR_EF_SvL0_Scanf,
|
|
2,
|
|
"%s",
|
|
M_MAKECHAR(pclCurrentActor->GetReferencedSectionName()));
|
|
}
|
|
}
|
|
}
|