163 lines
4.7 KiB
C++
163 lines
4.7 KiB
C++
// **********************************************************************************
|
|
// * "Anims.c" *
|
|
// * Written by : Mihaela Tancu *
|
|
// **********************************************************************************
|
|
|
|
|
|
#include <windows.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <direct.h>
|
|
|
|
#include "Anims.h"
|
|
|
|
MLT_tdstAnim **g_hAnimInFile;
|
|
long g_lAnimIndex;
|
|
|
|
/*
|
|
=======================================================================================
|
|
Name: MLT_xLoadAnim
|
|
Description:
|
|
Author: Mihaela Tancu
|
|
=======================================================================================
|
|
*/
|
|
SCR_tde_Anl_ReturnValue MLT_xLoadAnim(SCR_tdst_File_Description *p_fFile, char *szAction, char *szParams[], SCR_tde_Anl_Action cType)
|
|
{
|
|
MLT_tdstAnim *p_stAnim;
|
|
|
|
switch (cType)
|
|
{
|
|
case SCR_EA_Anl_BeginSection:
|
|
p_stAnim=(MLT_tdstAnim*)malloc(sizeof(MLT_tdstAnim));
|
|
SCR_M_RdL0_SetSectionLong(0,0,(long)p_stAnim);
|
|
SCR_M_RdL0_SetContextLong(0,0,(long)p_stAnim);
|
|
sprintf(p_stAnim->sName,"%s",SCR_M_RdL0_GetCompleteSectionNameR(0));
|
|
strcpy(p_stAnim->sAnimation,"");
|
|
break;
|
|
|
|
case SCR_EA_Anl_Entry:
|
|
SCR_M_RdL0_GetContextLong(0,0,MLT_tdstAnim*,p_stAnim);
|
|
|
|
// Loading of object's Anim
|
|
if (strcmp(szAction,M_Animation)==0)
|
|
{
|
|
sprintf(p_stAnim->sAnimation,"%s",szParams[0]);
|
|
}
|
|
break;
|
|
|
|
case SCR_EA_Anl_EndSection:
|
|
break;
|
|
}
|
|
return SCR_ERV_Anl_NormalReturn;
|
|
}
|
|
|
|
|
|
/*
|
|
=======================================================================================
|
|
Name: GLI_xLoadSTACallback
|
|
Description:
|
|
Author: Mihaela Tancu
|
|
=======================================================================================
|
|
*/
|
|
SCR_tde_Anl_ReturnValue GLI_xLoadSTACallback(SCR_tdst_File_Description *p_fFile, char *szAction, char *szParams[], SCR_tde_Anl_Action cType)
|
|
{
|
|
MLT_tdstAnim **p_xAnimInFile;
|
|
long xNbAnim;
|
|
|
|
switch (cType)
|
|
{
|
|
case SCR_EA_Anl_BeginSection:
|
|
p_xAnimInFile = (MLT_tdstAnim**)malloc(sizeof(MLT_tdstAnim*));
|
|
|
|
SCR_M_RdL0_SetContextLong(0,0,(long)p_xAnimInFile);
|
|
SCR_M_RdL0_SetContextLong(0,1,(long)0);
|
|
break;
|
|
|
|
case SCR_EA_Anl_EndSubSection:
|
|
if (strcmp(szParams[0],M_CreateNewState)==0)
|
|
{
|
|
MLT_tdstAnim *hAnim;
|
|
|
|
SCR_M_RdL0_GetContextLong(0,0,MLT_tdstAnim**,p_xAnimInFile);
|
|
SCR_M_RdL0_GetContextLong(0,1,long,xNbAnim);
|
|
|
|
p_xAnimInFile = (MLT_tdstAnim**)realloc(p_xAnimInFile,(++xNbAnim)*sizeof(MLT_tdstAnim*));
|
|
|
|
SCR_M_RdL0_GetSectionLong(1,0,MLT_tdstAnim*,hAnim);
|
|
p_xAnimInFile[xNbAnim-1]=hAnim;
|
|
|
|
SCR_M_RdL0_SetContextLong(0,0,(long)p_xAnimInFile);
|
|
SCR_M_RdL0_SetContextLong(0,1,(long)xNbAnim);
|
|
}
|
|
break;
|
|
|
|
case SCR_EA_Anl_EndSection:
|
|
SCR_M_RdL0_GetContextLong(0,0,MLT_tdstAnim**,p_xAnimInFile);
|
|
SCR_M_RdL0_GetContextLong(0,1,long,xNbAnim);
|
|
SCR_M_RdL0_SetSectionLong(0,0,(long)p_xAnimInFile);
|
|
SCR_M_RdL0_SetSectionLong(0,1,(long)xNbAnim);
|
|
break;
|
|
}
|
|
return SCR_ERV_Anl_NormalReturn;
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
=======================================================================================
|
|
Name: GLI_xLoadSTACallback
|
|
Description: init for loading an STA file
|
|
Author: Mihaela Tancu
|
|
=======================================================================================
|
|
*/
|
|
void MLT_vInitSTALoad()
|
|
{
|
|
// Init des scripts et lecture du fichier
|
|
SCR_fn_v_RdL0_RegisterCallback(M_CreateNewState,MLT_xLoadAnim, SCR_CRC_c_RdL0_ForSection);
|
|
SCR_fn_v_RdL0_RegisterCallback(M_FichierSTA,GLI_xLoadSTACallback, SCR_CRC_c_RdL0_ForFile);
|
|
}
|
|
|
|
|
|
/*
|
|
=======================================================================================
|
|
Name: MLT_vLoadSTAFileInLib
|
|
Description: Load Sta file in a lib
|
|
Author: Mihaela Tancu
|
|
=======================================================================================
|
|
*/
|
|
void MLT_vLoadSTAFileInLib(char *szFileName)
|
|
{
|
|
SCR_tdst_Cxt_Values *p_stVal;
|
|
|
|
if(SCR_fn_c_RdL0_IsSectionExists(szFileName))
|
|
{
|
|
p_stVal = SCR_fnp_st_RdL0_AnalyseSection(szFileName, SCR_CDF_uw_Anl_ForceAnalyse);
|
|
|
|
g_hAnimInFile = (MLT_tdstAnim **)SCR_M_ul_RdL0_ExtractLongValue(p_stVal,0);
|
|
g_lAnimIndex = (long)SCR_M_ul_RdL0_ExtractLongValue(p_stVal,1);
|
|
}
|
|
}
|
|
|
|
/*
|
|
=======================================================================================
|
|
Name: MLT_vEraseSTALib
|
|
Description: free all the object in the list
|
|
Author: Mihaela Tancu
|
|
=======================================================================================
|
|
*/
|
|
void MLT_vEraseSTALib()
|
|
{
|
|
int i;
|
|
|
|
if(g_hAnimInFile == NULL) return;
|
|
|
|
for(i=0; i<g_lAnimIndex; i++)
|
|
{
|
|
if(g_hAnimInFile[i] == NULL) continue;
|
|
free(g_hAnimInFile[i]);
|
|
}
|
|
g_lAnimIndex = 0;
|
|
free(g_hAnimInFile);
|
|
g_hAnimInFile = NULL;
|
|
}
|