Add rayman2 source files

This commit is contained in:
2024-09-18 02:33:44 +08:00
parent bcc093f8ed
commit fb036c54fd
14339 changed files with 2596224 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
LIBRARY
EXPORTS
fn_p_szGetCPAVersion
fn_p_stGetDLLIdentity
fn_p_oGetDLL
fn_vInitDll
SECTIONS
.data READ WRITE

View File

@@ -0,0 +1,6 @@
// StdAfx.cpp : source file that includes just the standard includes
// EdCarac.pch will be the pre-compiled header
// StdAfx.obj will contain the pre-compiled type information
#include "StdAfx.h"

View File

@@ -0,0 +1,124 @@
// MainFrm.cpp : implementation of the CPA_PartGen_MainFrame class
////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "x:\cpa\main\inc\_EditID.h"
#include "TUT.h"
#include "PGen_Res.h"
#include "TPGMainF.hpp"
#include "_Minterf.hpp"
#include "TPG_View.hpp"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
HCURSOR g_hcursor_CloseHand;
HCURSOR g_hcursor_UpDownHand;
/////////////////////////////////////////////////////////////////////////////
// CPA_PartGen_MainFrame
BEGIN_MESSAGE_MAP(CPA_PartGen_MainFrame, CSplitFrame)
//{{AFX_MSG_MAP(CPA_PartGen_MainFrame)
ON_WM_HELPINFO()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPA_PartGen_MainFrame construction/destruction
//*******************************************************************************
CPA_PartGen_MainFrame::CPA_PartGen_MainFrame()
{
//Loads a special cursor
g_hcursor_UpDownHand = AfxGetApp()->LoadCursor(IDC_CURSOR_UPDOWN_HAND);
g_hcursor_CloseHand = AfxGetApp()->LoadCursor(IDC_CURSOR_CLOSED_HAND);
}
//*******************************************************************************
CPA_PartGen_MainFrame::~CPA_PartGen_MainFrame()
{
}
//*******************************************************************************
BOOL CPA_PartGen_MainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
if ( !(CreateSplitter(C_cVerticalSplitter, 2)) )
return FALSE;
HINSTANCE hOldInstance = AfxGetResourceHandle();
//Creates Dialog List View
CPA_DialogList *pclDialogList = new CPA_DialogList;
g_pclInterface->m_clDocument.m_pub_p_clDialogList = pclDialogList;
pclDialogList->fn_vInitDialog(g_pclInterface, this);
SetPaneView(0, pclDialogList, "Particles Generator", g_pclInterface->m_clDocument.m_ulListViewHeight);
//*** register DialogList for Tut
TUT_M_vGetTutDll();
TUT_M_vRegisterDialogList( pclDialogList, "TPG_ListOfGeneratorsSystemsOrEnvironments",
"TPG_NoTree",
"TPG_SelectGeneratorsSystemsOrEnvironmentsList",
"TPG_NoTest" );
AfxSetResourceHandle(g_stPartGenDLLIdentity.hModule);
//Creates Control view
if ( !CreateView(1,
RUNTIME_CLASS(TPG_View),
"View",
450)
)
return FALSE;
TPG_View *p_clView = (TPG_View *)m_fn_p_oGetPane(1);
p_clView->OnInitialUpdate();
g_pclInterface->m_clDocument.m_pub_fn_vFillControlLists();
g_pclInterface->m_clDocument.m_pub_fn_vBuildAllEnumDescriptors();
AfxSetResourceHandle(hOldInstance);
return TRUE;
}
//*******************************************************************************
BOOL CPA_PartGen_MainFrame::OnHelpInfo(HELPINFO* pHelpInfo)
{
::WinHelp(m_hWnd,
LPCTSTR(g_pclInterface->m_clDocument.m_csHelpFileNameAndPath),
HELP_FINDER,
0);
return FALSE;
}
//*******************************************************************************
//*******************************************************************************
/////////////////////////////////////////////////////////////////////////////
// CPA_PartGen_MainFrame diagnostics
#ifdef _DEBUG
void CPA_PartGen_MainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CPA_PartGen_MainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,963 @@
////////////////////////////////////////////
//
// All CallBacks used by TPG
//
////////////////////////////////////////////
#include "StdAfx.h"
#define D_MSPrtSrc_StructureDefine
#include "ErO.h"
#include "MTH.h"
#include "TPG_ClBk.hpp"
#include "_Minterf.hpp"
#include "Tpg_Strg.hpp"
#include "TPG_Spri.hpp"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/*
=======================================================================================
General function
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : Get a PrtSrc owner data in Editor data
Returns (PRT_tdstParticlesSource )
----------------------------------------------------------------------------------------
*/
PRT_tdstParticlesSource *fn_CB_p_stGetOwnerPrtSrc( CTL_Editor_Data *_p_clData )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
CTL_OwnerData *p_clOwnerData;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"Function to get ParticlesSource Owner data",
"fn_CB_p_stGetOwnerPrtSrc",
E_ERROR_GRAVITY_FATAL,
"Ownerdata (PrtSrc) is NULL"
);
p_clOwnerData = _p_clData->m_pub_fn_pclGetOwnerDataWithName( "PrtSrc" );
ERROR_ASSERT( p_clOwnerData != NULL );
return (PRT_tdstParticlesSource *) p_clOwnerData->m_pub_fn_pvGetDataPtr();
}
/*
----------------------------------------------------------------------------------------
Description : Check data passed to some call back
Returns (PRT_tdstParticlesSource )
----------------------------------------------------------------------------------------
*/
void fn_CB_vCheckData( CTL_Editor_Data *_p_clData )
{
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"Function to check data",
"fn_CB_p_oCheckData",
E_ERROR_GRAVITY_FATAL,
"Data is NULL"
);
ERROR_ASSERT( _p_clData != NULL );
}
/*
----------------------------------------------------------------------------------------
Description : get and check current enum value of an enum data
----------------------------------------------------------------------------------------
*/
CTL_Editor_EnumElement *fn_CB_p_oGetCurrentEnumElement( CTL_Editor_Data *_p_clData )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
CTL_Editor_EnumElement *p_clEnumElement;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"Function to retrieve current enum value",
"fn_CB_p_oGetCurrentEnumElement",
E_ERROR_GRAVITY_FATAL,
"Enum current value is NULL"
);
p_clEnumElement = ((CTL_Editor_EnumData*)_p_clData)->m_pclCurrentValue;
ERROR_ASSERT( p_clEnumElement != NULL );
return p_clEnumElement;
}
//////////////////////////////////////////////////
// Can Be Displayed CallBacks
//////////////////////////////////////////////////
//*** Probability for source generation mode *****
BOOL g_fn_bCallBackCanBeDisplayedSourceProbability( CTL_Editor_Control *_p_clControl )
{
CTL_OwnerData *p_clOwnerData;
unsigned char *p_ucGenerationMode;
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"Is source generation probability displayed ?",
"g_fn_bCallBackCanBeDisplayedSourceProbability",
E_ERROR_GRAVITY_FATAL,
"OwnerData to get generation mode is NULL"
);
p_clOwnerData = _p_clControl->m_fn_pclGetEditedData()->m_pub_fn_pclGetOwnerDataWithName( "GenerationMode" );
ERROR_ASSERT( p_clOwnerData != NULL );
p_ucGenerationMode = (unsigned char*)( p_clOwnerData->m_pub_fn_pvGetDataPtr() );
return (*p_ucGenerationMode == PRT_C_ucProbabilistGeneration);
}
//*** Nb Frames For source generation mode ****
BOOL g_fn_bCallBackCanBeDisplayedSourceNbFrames( CTL_Editor_Control *_p_clControl )
{
CTL_OwnerData *p_clOwnerData;
unsigned char *p_ucGenerationMode;
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"Is source nb frames generation displayed ?",
"g_fn_bCallBackCanBeDisplayedSourceNbFrames",
E_ERROR_GRAVITY_FATAL,
"OwnerData to get generation mode is NULL"
);
p_clOwnerData = _p_clControl->m_fn_pclGetEditedData()->m_pub_fn_pclGetOwnerDataWithName( "GenerationMode" );
ERROR_ASSERT( p_clOwnerData != NULL );
p_ucGenerationMode = (unsigned char*) p_clOwnerData->m_pub_fn_pvGetDataPtr();
return (*p_ucGenerationMode == PRT_C_ucCrenelGeneration);
}
//*** Nb Particles For source nb particles to generate mode
BOOL g_fn_bCallBackCanBeDisplayedSourceNbParticles( CTL_Editor_Control *_p_clControl )
{
CTL_OwnerData *p_clOwnerData;
unsigned char *p_ucNbParticlesMode;
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"Is source nb particles constant displayed ?",
"g_fn_bCallBackCanBeDisplayedSourceNbParticles",
E_ERROR_GRAVITY_FATAL,
"OwnerData to get nb particles to generate mode is NULL"
);
p_clOwnerData = _p_clControl->m_fn_pclGetEditedData()->m_pub_fn_pclGetOwnerDataWithName( "NbParticlesMode" );
ERROR_ASSERT( p_clOwnerData != NULL );
p_ucNbParticlesMode = (unsigned char*) p_clOwnerData->m_pub_fn_pvGetDataPtr();
return (*p_ucNbParticlesMode == PRT_C_ucConstantNb);
}
//*** Nb Particles Min/Max For source nb particles to generate mode
BOOL g_fn_bCallBackCanBeDisplayedSourceNbParticlesMinMax( CTL_Editor_Control *_p_clControl )
{
CTL_OwnerData *p_clOwnerData;
unsigned char *p_ucNbParticlesMode;
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"Is source nb particles min/max displayed ?",
"g_fn_bCallBackCanBeDisplayedSourceNbParticles",
E_ERROR_GRAVITY_FATAL,
"OwnerData to get nb particles to generate mode is NULL"
);
p_clOwnerData = _p_clControl->m_fn_pclGetEditedData()->m_pub_fn_pclGetOwnerDataWithName( "NbParticlesMode" );
ERROR_ASSERT( p_clOwnerData != NULL );
p_ucNbParticlesMode = (unsigned char*) p_clOwnerData->m_pub_fn_pvGetDataPtr();
return (*p_ucNbParticlesMode == PRT_C_ucProbabilistNb);
}
//*** Quad geometry for source ********************
BOOL g_fn_bCallBackCanBeDisplayedSourceGeometryQuad( CTL_Editor_Control *_p_clControl )
{
CTL_OwnerData *p_clOwnerData;
unsigned char *p_ucNbParticlesMode;
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"Is points 1 and 2 displayed ?",
"g_fn_bCallBackCanBeDisplayedSourceGeometryQuad",
E_ERROR_GRAVITY_FATAL,
"OwnerData to get geometry mode is NULL"
);
p_clOwnerData = _p_clControl->m_fn_pclGetEditedData()->m_pub_fn_pclGetOwnerDataWithName( "GeometryMode" );
ERROR_ASSERT( p_clOwnerData != NULL );
p_ucNbParticlesMode = (unsigned char*) p_clOwnerData->m_pub_fn_pvGetDataPtr();
return (*p_ucNbParticlesMode == PRT_C_ucQuad);
}
//*** Constant Life time ********************
BOOL g_fn_bCallBackCanBeDisplayedSourceConstantLifeTime( CTL_Editor_Control *_p_clControl )
{
CTL_OwnerData *p_clOwnerData;
unsigned char *p_ucMode;
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"Is constant life time displayed ?",
"g_fn_bCallBackCanBeDisplayedSourceConstantLifeTime",
E_ERROR_GRAVITY_FATAL,
"OwnerData to get geometry mode is NULL"
);
p_clOwnerData = _p_clControl->m_fn_pclGetEditedData()->m_pub_fn_pclGetOwnerDataWithName( "LifeMode" );
ERROR_ASSERT( p_clOwnerData != NULL );
p_ucMode = (unsigned char*) p_clOwnerData->m_pub_fn_pvGetDataPtr();
return (*p_ucMode == PRT_C_ucConstantLifeTime);
}
//*** Probabilist Life time ********************
BOOL g_fn_bCallBackCanBeDisplayedSourceProbabilistLifeTime( CTL_Editor_Control *_p_clControl )
{
CTL_OwnerData *p_clOwnerData;
unsigned char *p_ucMode;
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"Are min/max life time displayed ?",
"g_fn_bCallBackCanBeDisplayedSourceProbabilistLifeTime",
E_ERROR_GRAVITY_FATAL,
"OwnerData to get geometry mode is NULL"
);
p_clOwnerData = _p_clControl->m_fn_pclGetEditedData()->m_pub_fn_pclGetOwnerDataWithName( "LifeMode" );
ERROR_ASSERT( p_clOwnerData != NULL );
p_ucMode = (unsigned char*) p_clOwnerData->m_pub_fn_pvGetDataPtr();
return (*p_ucMode == PRT_C_ucProbabilistLifeTime);
}
//*** GameMaterials for system *********************
BOOL g_fn_bCallBackCanBeDisplayedSystemGameMaterials( CTL_Editor_Control * _p_clControl)
{
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Is GameMaterials displayed ?",
"g_fn_bCallBackCanBeDisplayedSystemGameMaterials",
E_ERROR_GRAVITY_FATAL,
"OwnerData to get objects type is NULL");
CTL_OwnerData *p_clOwnerData = _p_clControl->m_fn_pclGetEditedData()->m_pub_fn_pclGetOwnerDataWithName( "ObjectsType" );
ERROR_ASSERT( p_clOwnerData != NULL );
ACP_tdxIndex *p_xType = (ACP_tdxIndex*)( p_clOwnerData->m_pub_fn_pvGetDataPtr() );
return( (*p_xType == PRT_C_xPointParticles) || (*p_xType == PRT_C_xSegmentParticles) );
}
//*** Sprites for system
BOOL g_fn_bCallBackCanBeDisplayedSystemSprites( CTL_Editor_Control * _p_clControl)
{
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Is sprites displayed ?",
"g_fn_bCallBackCanBeDisplayedSystemSprites",
E_ERROR_GRAVITY_FATAL,
"OwnerData to get objects type is NULL");
CTL_OwnerData *p_clOwnerData = _p_clControl->m_fn_pclGetEditedData()->m_pub_fn_pclGetOwnerDataWithName( "ObjectsType" );
ERROR_ASSERT( p_clOwnerData != NULL );
ACP_tdxIndex *p_xType = (ACP_tdxIndex*)( p_clOwnerData->m_pub_fn_pvGetDataPtr() );
return( *p_xType == PRT_C_xSpriteParticles );
}
//*** Min Max points for environment box with generator not linked
BOOL g_fn_bCallBackCanBeDisplayedEnvBox( CTL_Editor_Control * _p_clControl)
{
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Are min and max points for box displayed ?",
"g_fn_bCallBackCanBeDisplayedEnvBox",
E_ERROR_GRAVITY_FATAL,
"OwnerData to get environment type is NULL");
CTL_OwnerData *p_clOwnerData = _p_clControl->m_fn_pclGetEditedData()->m_pub_fn_pclGetOwnerDataWithName( "EnvType" );
ERROR_ASSERT( p_clOwnerData != NULL );
unsigned long *p_ulType = (unsigned long*)( p_clOwnerData->m_pub_fn_pvGetDataPtr() );
return( *p_ulType == PRT_C_ulAlignedBoxEnv );
}
//*** Sphere center for environment box with generator not linked
BOOL g_fn_bCallBackCanBeDisplayedEnvSphere( CTL_Editor_Control * _p_clControl)
{
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Is center for sphere displayed ?",
"g_fn_bCallBackCanBeDisplayedEnvSphere",
E_ERROR_GRAVITY_FATAL,
"OwnerData to get environment type is NULL");
CTL_OwnerData *p_clOwnerData = _p_clControl->m_fn_pclGetEditedData()->m_pub_fn_pclGetOwnerDataWithName( "EnvType" );
ERROR_ASSERT( p_clOwnerData != NULL );
unsigned long *p_ulType = (unsigned long*)( p_clOwnerData->m_pub_fn_pvGetDataPtr() );
return( *p_ulType == PRT_C_ulSphereEnv );
}
////////////////////////////////////////
// Data Changed CallBacks
////////////////////////////////////////
//*** data changed for generator ******
void g_fn_vCallBackDataChangedGenerator( CTL_Editor_Data *_p_clData, CTL_eUpdateReason _eReason, long _lUserReason )
{
CTL_OwnerData *p_clOwnerData;
CPA_PartGen_Generator *p_clGenerator;
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"CallBack to notify generator data has changed",
"g_fn_vCallBackDataChangedGenerator",
E_ERROR_GRAVITY_FATAL,
"OwnerData to get edited generator is NULL"
);
p_clOwnerData = _p_clData->m_pub_fn_pclGetOwnerDataWithName( "EditedGenerator" );
ERROR_ASSERT( p_clOwnerData != NULL );
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"CallBack to notify generator data has changed",
"g_fn_vCallBackDataChangedGenerator",
E_ERROR_GRAVITY_FATAL,
"Edited generator is NULL"
);
p_clGenerator = (CPA_PartGen_Generator*) p_clOwnerData->m_pub_fn_pvGetDataPtr();
ERROR_ASSERT( p_clGenerator != NULL );
p_clGenerator->fn_vNotifySave();
}
//*** data changed for Particle source ******
void fn_vCBPrtSrcDataChanged( CTL_Editor_Data *_p_clData, CTL_eUpdateReason _eReason, long _lUserReason )
{
CTL_OwnerData *p_clOwnerData;
CPA_PartGen_Source *p_oPrtSrc;
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"CallBack to notify Particle source data has changed",
"fn_vCBPrtSrcDataChanged",
E_ERROR_GRAVITY_FATAL,
"OwnerData to get edited source is NULL"
);
p_clOwnerData = _p_clData->m_pub_fn_pclGetOwnerDataWithName( "EditedSource" );
ERROR_ASSERT( p_clOwnerData != NULL );
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"CallBack to notify Particle source data has changed",
"fn_vCBPrtSrcDataChanged",
E_ERROR_GRAVITY_FATAL,
"Edited particle source is NULL"
);
p_oPrtSrc = (CPA_PartGen_Source *) p_clOwnerData->m_pub_fn_pvGetDataPtr();
ERROR_ASSERT( p_oPrtSrc != NULL );
p_oPrtSrc->fn_vNotifySave();
}
//*** data changed for Particle system ******
void g_fn_vCallBackDataChangedSystem( CTL_Editor_Data *_p_clData, CTL_eUpdateReason _eReason, long _lUserReason )
{
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"CallBack to notify system data has changed",
"g_fn_vCallBackDataChangedSystem",
E_ERROR_GRAVITY_FATAL,
"OwnerData to get edited system is NULL");
CTL_OwnerData *p_clOwnerData = _p_clData->m_pub_fn_pclGetOwnerDataWithName( "EditedSystem" );
ERROR_ASSERT( p_clOwnerData != NULL );
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"CallBack to notify system data has changed",
"g_fn_vCallBackDataChangedSystem",
E_ERROR_GRAVITY_FATAL,
"Edited system is NULL");
CPA_PartGen_System *p_clSystem = (CPA_PartGen_System*)( p_clOwnerData->m_pub_fn_pvGetDataPtr() );
ERROR_ASSERT( p_clSystem != NULL );
p_clSystem->fn_vNotifySave();
}
//*** data changed for Particle environment ******
void g_fn_vCallBackDataChangedEnv( CTL_Editor_Data *_p_clData, CTL_eUpdateReason _eReason, long _lUserReason )
{
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"CallBack to notify environment data has changed",
"g_fn_vCallBackDataChangedEnv",
E_ERROR_GRAVITY_FATAL,
"OwnerData to get edited environment is NULL");
CTL_OwnerData *p_clOwnerData = _p_clData->m_pub_fn_pclGetOwnerDataWithName( "EditedEnv" );
ERROR_ASSERT( p_clOwnerData != NULL );
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"CallBack to notify environment data has changed",
"g_fn_vCallBackDataChangedEnv",
E_ERROR_GRAVITY_FATAL,
"Edited environment is NULL");
CPA_PartGen_Environment *p_clEnv = (CPA_PartGen_Environment*)( p_clOwnerData->m_pub_fn_pvGetDataPtr() );
ERROR_ASSERT( p_clEnv != NULL );
p_clEnv->fn_vNotifySave();
}
/////////////////////////////////////////////////////
// Data Changed Special CallBacks
/////////////////////////////////////////////////////
//*** Display generator for combo changed ***********
void g_fn_vCallBackDataChangedSpecialDisplayGenerator( CTL_Editor_Data *_p_clData, CTL_eUpdateReason _eReason, long _lUserReason )
{
if( _eReason == CTL_UPDATE_REASON__DATA_MODIFIED_BY_USER )
g_pclInterface->m_pub_fn_p_clGetDocument()->m_pub_fn_vDisplayCurrentGenerator();
}
void g_fn_vCallBackDataChangedSpecialDisplayAll( CTL_Editor_Data *_p_clData, CTL_eUpdateReason _eReason, long _lUserReason )
{
if( _eReason == CTL_UPDATE_REASON__DATA_MODIFIED_BY_USER )
g_pclInterface->m_pub_fn_p_clGetDocument()->m_pub_fn_vUpdateGenerator(g_pclInterface->m_pub_fn_p_clGetDocument()->m_pub_p_clCurrentGenerator );
}
///////////////////////////////////////////////////
// Read/Write Modification CallBacks
///////////////////////////////////////////////////
///// Check if source is loaded before it is used by generator /////////////
void g_fn_vModificationWriteGeneratorSource( CTL_Editor_Data *_p_clData )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
CTL_Editor_EnumElement *p_clEnumElement;
CPA_PartGen_Source *p_oPrtSrc;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
fn_CB_vCheckData( _p_clData );
p_clEnumElement = fn_CB_p_oGetCurrentEnumElement(_p_clData);
if( p_clEnumElement->m_pub_fn_lGetValue() == (long)0 )
{
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"Function to modify system associated to generator",
"g_fn_vModificationWriteGeneratorSystem",
E_ERROR_GRAVITY_WARNING,
"Set a NULL System"
);
p_oPrtSrc = (CPA_PartGen_Source *)p_clEnumElement->m_pub_fn_pvGetAdditionnalPointer();
ERROR_ASSERT( p_oPrtSrc != NULL );
if( p_oPrtSrc != NULL )
{
p_oPrtSrc->m_pub_fn_vLoadIfUnloaded();
p_clEnumElement->m_pub_fn_vSetValue( ((long) p_oPrtSrc->GetData()) );
}
}
}
///// Check system is loaded before it is used by generator /////////////
void g_fn_vModificationWriteGeneratorSystem( CTL_Editor_Data *_p_clData )
{
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Function to modify system associated to generator",
"g_fn_vModificationWriteGeneratorSystem",
E_ERROR_GRAVITY_FATAL,
"Data is NULL");
ERROR_ASSERT( _p_clData != NULL );
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Function to modify system associated to generator",
"g_fn_vModificationWriteGeneratorSystem",
E_ERROR_GRAVITY_FATAL,
"Enum current value is NULL");
CTL_Editor_EnumElement *p_clEnumElement = ((CTL_Editor_EnumData*)_p_clData)->m_pclCurrentValue;
ERROR_ASSERT( p_clEnumElement != NULL );
if( p_clEnumElement->m_pub_fn_lGetValue() == (long)0 )
{
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Function to modify system associated to generator",
"g_fn_vModificationWriteGeneratorSystem",
E_ERROR_GRAVITY_WARNING,
"Set a NULL System");
CPA_PartGen_System *p_clSystem = (CPA_PartGen_System*)p_clEnumElement->m_pub_fn_pvGetAdditionnalPointer();
ERROR_ASSERT( p_clSystem != NULL );
if( p_clSystem != NULL )
{
p_clSystem->m_pub_fn_vLoadIfUnloaded();
p_clEnumElement->m_pub_fn_vSetValue( ((long)p_clSystem->GetData()) );
}
}
}
///// Check environment is loaded before it is used by generator /////////////
void g_fn_vModificationWriteGeneratorEnvironment( CTL_Editor_Data *_p_clData )
{
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Function to modify environment associated to generator",
"g_fn_vModificationWriteGeneratorEnvironment",
E_ERROR_GRAVITY_FATAL,
"Data is NULL");
ERROR_ASSERT( _p_clData != NULL );
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Function to modify environment associated to generator",
"g_fn_vModificationWriteGeneratorEnvironment",
E_ERROR_GRAVITY_FATAL,
"Enum current value is NULL");
CTL_Editor_EnumElement *p_clEnumElement = ((CTL_Editor_EnumData*)_p_clData)->m_pclCurrentValue;
ERROR_ASSERT( p_clEnumElement != NULL );
if( p_clEnumElement->m_pub_fn_lGetValue() == (long)0 )
{
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Function to modify environment associated to generator",
"g_fn_vModificationWriteGeneratorEnvironment",
E_ERROR_GRAVITY_WARNING,
"Set a NULL environment");
CPA_PartGen_Environment *p_clEnv = (CPA_PartGen_Environment*)p_clEnumElement->m_pub_fn_pvGetAdditionnalPointer();
ERROR_ASSERT( p_clEnv != NULL );
if( p_clEnv != NULL )
{
p_clEnv->m_pub_fn_vLoadIfUnloaded();
p_clEnumElement->m_pub_fn_vSetValue( (long)(p_clEnv->GetData()) );
}
}
}
///// Check environment is loaded before it is used by generator /////////////
void g_fn_vModificationWriteGeneratorLinkedGenerator( CTL_Editor_Data *_p_clData )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
CTL_Editor_EnumElement *p_clEnumElement;
CPA_PartGen_Generator *p_oLinkedGen;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
fn_CB_vCheckData( _p_clData );
p_clEnumElement = fn_CB_p_oGetCurrentEnumElement(_p_clData);
if( p_clEnumElement->m_pub_fn_lGetValue() == (long)0 )
{
p_oLinkedGen = (CPA_PartGen_Generator *) p_clEnumElement->m_pub_fn_pvGetAdditionnalPointer();
if( p_oLinkedGen != NULL )
{
//p_oLinkedGen->m_pub_fn_vLoadIfUnloaded();
g_pclInterface->fn_bLoadBaseObject( p_oLinkedGen );
p_clEnumElement->m_pub_fn_vSetValue( (long)(p_oLinkedGen->GetData()) );
/*
* todo : check for loop
*/
}
}
}
///// Read Nb frames generation using Nb frames total ///////////////////////////
void g_fn_vModificationReadSourceNbFramesGeneration( CTL_Editor_Data *_p_clData )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
PRT_tdstParticlesSource *p_stPrtSrc;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
fn_CB_vCheckData( _p_clData );
p_stPrtSrc = fn_CB_p_stGetOwnerPrtSrc( _p_clData );
((CTL_Editor_IntegerData *) _p_clData)->m_lCurrentValue -= (long) p_stPrtSrc->xNbFramesNoGeneration;
}
///// write nb frames total using nb frames generation ///////////////////////////
void g_fn_vModificationWriteSourceNbFramesGeneration( CTL_Editor_Data *_p_clData )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
PRT_tdstParticlesSource *p_stPrtSrc;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
fn_CB_vCheckData( _p_clData );
p_stPrtSrc = fn_CB_p_stGetOwnerPrtSrc( _p_clData );
((CTL_Editor_IntegerData *) _p_clData)->m_lCurrentValue += (long) p_stPrtSrc->xNbFramesNoGeneration;
}
//*** Get GameMaterial used by system with point or segment
void g_fn_vModificationReadSystemGameMaterials( CTL_Editor_Data *_p_clData )
{
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Function to get GameMaterial from Point or Segment",
"g_fn_vModificationReadSystemGameMaterials",
E_ERROR_GRAVITY_FATAL,
"Data is NULL");
ERROR_ASSERT( _p_clData != NULL );
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Function to get GameMaterial from Point or Segment",
"g_fn_vModificationReadSystemGameMaterials",
E_ERROR_GRAVITY_FATAL,
"EnumElement is NULL");
CTL_Editor_EnumElement *p_clEnumElement = ((CTL_Editor_EnumData*)_p_clData)->m_pclCurrentValue;
ERROR_ASSERT( p_clEnumElement != NULL );
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Function to get GameMaterial from Point or Segment",
"g_fn_vModificationReadSystemGameMaterials",
E_ERROR_GRAVITY_FATAL,
"OwnerData to get objects type is NULL");
CTL_OwnerData *p_clOwnerData = _p_clData->m_pub_fn_pclGetOwnerDataWithName( "ObjectsType" );
ERROR_ASSERT( p_clOwnerData != NULL );
ACP_tdxIndex *p_xType = (ACP_tdxIndex*)( p_clOwnerData->m_pub_fn_pvGetDataPtr() );
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Function to get GameMaterial from Point or Segment",
"g_fn_vModificationReadSystemGameMaterials",
E_ERROR_GRAVITY_FATAL,
"OwnerData to get edited system is NULL");
p_clOwnerData = _p_clData->m_pub_fn_pclGetOwnerDataWithName( "EditedSystem" );
ERROR_ASSERT( p_clOwnerData != NULL );
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Function to get GameMaterial from Point or Segment",
"g_fn_vModificationReadSystemGameMaterials",
E_ERROR_GRAVITY_FATAL,
"Edited system is NULL");
CPA_PartGen_System *p_clSystem = (CPA_PartGen_System*)( p_clOwnerData->m_pub_fn_pvGetDataPtr() );
ERROR_ASSERT( p_clSystem != NULL );
if( *p_xType == PRT_C_xPointParticles )
p_clEnumElement->m_pub_fn_vSetValue( (long)p_clSystem->m_pub_fn_hGetPointGameMaterial() );
if( *p_xType == PRT_C_xSegmentParticles )
p_clEnumElement->m_pub_fn_vSetValue( (long)p_clSystem->m_pub_fn_hGetSegmentGameMaterial() );
}
///// Create Point, Segment or Sprite for system //////////////////////
void g_fn_vModificationWriteSystemObjects( CTL_Editor_Data *_p_clData )
{
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Function to create Point, Segment or Sprite",
"g_fn_vModificationWriteSystemObjects",
E_ERROR_GRAVITY_FATAL,
"Data is NULL");
ERROR_ASSERT( _p_clData != NULL );
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Function to create Point, Segment or Sprite",
"g_fn_vModificationWriteSystemObjects",
E_ERROR_GRAVITY_FATAL,
"EnumElement is NULL");
CTL_Editor_EnumElement *p_clEnumElement = ((CTL_Editor_EnumData*)_p_clData)->m_pclCurrentValue;
ERROR_ASSERT( p_clEnumElement != NULL );
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Function to create Point, Segment or Sprite",
"g_fn_vModificationWriteSystemObjects",
E_ERROR_GRAVITY_FATAL,
"OwnerData to get objects type is NULL");
CTL_OwnerData *p_clOwnerData = _p_clData->m_pub_fn_pclGetOwnerDataWithName( "ObjectsType" );
ERROR_ASSERT( p_clOwnerData != NULL );
ACP_tdxIndex *p_xType = (ACP_tdxIndex*)( p_clOwnerData->m_pub_fn_pvGetDataPtr() );
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Function to create Point, Segment or Sprite",
"g_fn_vModificationWriteSystemObjects",
E_ERROR_GRAVITY_FATAL,
"OwnerData to get edited system is NULL");
p_clOwnerData = _p_clData->m_pub_fn_pclGetOwnerDataWithName( "EditedSystem" );
ERROR_ASSERT( p_clOwnerData != NULL );
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Function to create Point, Segment or Sprite",
"g_fn_vModificationWriteSystemObjects",
E_ERROR_GRAVITY_FATAL,
"Edited system is NULL");
CPA_PartGen_System *p_clSystem = (CPA_PartGen_System*)( p_clOwnerData->m_pub_fn_pvGetDataPtr() );
ERROR_ASSERT( p_clSystem != NULL );
if( *p_xType == PRT_C_xPointParticles )
p_clSystem->m_pub_fn_vSetObjectPoint( (GMT_tdxHandleToGameMaterial)p_clEnumElement->m_pub_fn_lGetValue() );
if( *p_xType == PRT_C_xSegmentParticles )
p_clSystem->m_pub_fn_vSetObjectSegment( (GMT_tdxHandleToGameMaterial)p_clEnumElement->m_pub_fn_lGetValue() );
if( *p_xType == PRT_C_xSpriteParticles )
{
if( p_clEnumElement->m_pub_fn_lGetValue() == 0 )
{
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Function to create Point, Segment or Sprite",
"g_fn_vModificationWriteSystemObjects",
E_ERROR_GRAVITY_WARNING,
"Set a NULL Sprite !");
TPG_Sprite *p_clSprite = (TPG_Sprite*)p_clEnumElement->m_pub_fn_pvGetAdditionnalPointer();
ERROR_ASSERT( p_clSprite != NULL );
if( p_clSprite != NULL )
{
p_clSprite->m_pub_fn_vLoadSprite();
p_clEnumElement->m_pub_fn_vSetValue( (long)p_clSprite->m_pub_fn_hGetSprite() );
}
}
p_clSystem->m_pub_fn_vSetObjectSprite( (ACP_tdxHandleOfSprite)p_clEnumElement->m_pub_fn_lGetValue() );
}
}
///// Save min max point in environment or in generator linked //
void g_fn_vModificationWriteEnvBox( CTL_Editor_Data *_p_clData )
{
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Update engine data min max points for environment",
"g_fn_vModificationWriteEnvBox",
E_ERROR_GRAVITY_FATAL,
"Data is NULL");
ERROR_ASSERT( _p_clData != NULL );
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Update engine data min max points for environment",
"g_fn_vModificationWriteEnvBox",
E_ERROR_GRAVITY_FATAL,
"OwnerData to get edited environment is NULL");
CTL_OwnerData *p_clOwnerData = _p_clData->m_pub_fn_pclGetOwnerDataWithName( "EditedEnv" );
ERROR_ASSERT( p_clOwnerData != NULL );
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Update engine data min max points for environment",
"g_fn_vModificationWriteEnvBox",
E_ERROR_GRAVITY_FATAL,
"Edited environment is NULL");
CPA_PartGen_Environment *p_clEnv = (CPA_PartGen_Environment*)( p_clOwnerData->m_pub_fn_pvGetDataPtr() );
ERROR_ASSERT( p_clEnv != NULL );
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Update engine data min max points for environment",
"g_fn_vModificationWriteEnvBox",
E_ERROR_GRAVITY_FATAL,
"Edited engine environment is NULL");
ERROR_ASSERT( p_clEnv->m_pri_p_stEnv != NULL );
if( p_clEnv->m_pri_p_clGenerator == NULL )
{
MTH3D_M_vCopyVector( (&(p_clEnv->m_pri_p_stEnv->stMinPoint)), (&(p_clEnv->m_pri_stMinPoint)) );
MTH3D_M_vCopyVector( (&(p_clEnv->m_pri_p_stEnv->stMaxPoint)), (&(p_clEnv->m_pri_stMaxPoint)) );
}
else
{
if( p_clEnv->m_pri_p_clGenerator->m_pub_fn_bGetLinkToEnv() )
{
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Update engine data min max points for environment",
"g_fn_vModificationWriteEnvBox",
E_ERROR_GRAVITY_FATAL,
"Engine generator using edited environment is NULL");
ERROR_ASSERT( p_clEnv->m_pri_p_clGenerator->m_pri_hGenerator != NULL );
MTH3D_M_vCopyVector( (&(p_clEnv->m_pri_p_clGenerator->m_pri_hGenerator->stMinPoint)), (&(p_clEnv->m_pri_stMinPoint)) );
MTH3D_M_vCopyVector( (&(p_clEnv->m_pri_p_clGenerator->m_pri_hGenerator->stMaxPoint)), (&(p_clEnv->m_pri_stMaxPoint)) );
}
else
{
MTH3D_M_vCopyVector( (&(p_clEnv->m_pri_p_stEnv->stMinPoint)), (&(p_clEnv->m_pri_stMinPoint)) );
MTH3D_M_vCopyVector( (&(p_clEnv->m_pri_p_stEnv->stMaxPoint)), (&(p_clEnv->m_pri_stMaxPoint)) );
}
}
}
///// Save sphere center in environment or in generator linked ////
void g_fn_vModificationWriteEnvSphere( CTL_Editor_Data *_p_clData )
{
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Update engine data center of sphere for environment",
"g_fn_vModificationWriteEnvSphere",
E_ERROR_GRAVITY_FATAL,
"Data is NULL");
ERROR_ASSERT( _p_clData != NULL );
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Update engine data center of sphere for environment",
"g_fn_vModificationWriteEnvSphere",
E_ERROR_GRAVITY_FATAL,
"OwnerData to get edited environment is NULL");
CTL_OwnerData *p_clOwnerData = _p_clData->m_pub_fn_pclGetOwnerDataWithName( "EditedEnv" );
ERROR_ASSERT( p_clOwnerData != NULL );
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Update engine data center of sphere for environment",
"g_fn_vModificationWriteEnvSphere",
E_ERROR_GRAVITY_FATAL,
"Edited environment is NULL");
CPA_PartGen_Environment *p_clEnv = (CPA_PartGen_Environment*)( p_clOwnerData->m_pub_fn_pvGetDataPtr() );
ERROR_ASSERT( p_clEnv != NULL );
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Update engine data center of sphere for environment",
"g_fn_vModificationWriteEnvSphere",
E_ERROR_GRAVITY_FATAL,
"Edited engine environment is NULL");
ERROR_ASSERT( p_clEnv->m_pri_p_stEnv != NULL );
if( p_clEnv->m_pri_p_clGenerator == NULL )
{
MTH3D_M_vCopyVector( (&(p_clEnv->m_pri_p_stEnv->stSphereCenter)), (&(p_clEnv->m_pri_stSphereCenter)) );
}
else
{
if( p_clEnv->m_pri_p_clGenerator->m_pub_fn_bGetLinkToEnv() )
{
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Update engine data center of sphere for environment",
"g_fn_vModificationWriteEnvSphere",
E_ERROR_GRAVITY_FATAL,
"Engine generator using edited environment is NULL");
ERROR_ASSERT( p_clEnv->m_pri_p_clGenerator->m_pri_hGenerator != NULL );
MTH3D_M_vCopyVector( (&(p_clEnv->m_pri_p_clGenerator->m_pri_hGenerator->stMinPoint)), (&(p_clEnv->m_pri_stSphereCenter)) );
}
else
{
MTH3D_M_vCopyVector( (&(p_clEnv->m_pri_p_stEnv->stSphereCenter)), (&(p_clEnv->m_pri_stSphereCenter)) );
}
}
}
///////////////////////////////////////////////////////////////////////////////////
// Must be read_written CallBacks
///////////////////////////////////////////////////////////////////////////////////
//*** Is GameMaterial data of system is taken into account ************************
BOOL g_fn_bCallBackMustBeReadWrittenSystemGameMaterial( CTL_Editor_Data * _p_clData )
{
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Is GameMaterial data taken into account ?",
"g_fn_bCallBackMustBeReadWrittenSystemGameMaterial",
E_ERROR_GRAVITY_FATAL,
"OwnerData to get objects type is NULL");
CTL_OwnerData *p_clOwnerData = _p_clData->m_pub_fn_pclGetOwnerDataWithName( "ObjectsType" );
ERROR_ASSERT( p_clOwnerData != NULL );
ACP_tdxIndex *p_xType = (ACP_tdxIndex*)( p_clOwnerData->m_pub_fn_pvGetDataPtr() );
return( (*p_xType == PRT_C_xPointParticles) || (*p_xType == PRT_C_xSegmentParticles) );
}
//*** Is Sprite data of system is taken into account
BOOL g_fn_bCallBackMustBeReadWrittenSystemSprite( CTL_Editor_Data * _p_clData )
{
ERROR_PREPARE_M(g_c_csPartGenModuleNameForErrors,
"Is sprite data taken into account ?",
"g_fn_bCallBackMustBeReadWrittenSystemSprite",
E_ERROR_GRAVITY_FATAL,
"OwnerData to get objects type is NULL");
CTL_OwnerData *p_clOwnerData = _p_clData->m_pub_fn_pclGetOwnerDataWithName( "ObjectsType" );
ERROR_ASSERT( p_clOwnerData != NULL );
ACP_tdxIndex *p_xType = (ACP_tdxIndex*)( p_clOwnerData->m_pub_fn_pvGetDataPtr() );
return( *p_xType == PRT_C_xSpriteParticles );
}
//ROMTEAM Bugs Correction (Cristian Stegaru 24/03/98)
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : g_fnCanISelectThisItemCallBack
// Date : 98-03
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : this function is called from a combobox when a selection is changed
// if the selected item is valid approve the selection
// Author : Stegaru Cristian - CPA2
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
int g_fnCanISelectThisItemCallBack (CTL_Editor_Data * p_clData, CTL_Editor_EnumElement *pNewElement)
{
ASSERT (pNewElement);
CString csSelectedString = pNewElement->m_pub_fn_csGetElementName();
if ("No Element" == csSelectedString)
return 1;
ASSERT (p_clData);
CString csDataName = p_clData->m_pub_fn_csGetDataName ();
if ("Environment" != csDataName)
return 1;
//get the current generator
CTL_OwnerData *p_clOwnerData = p_clData->m_pub_fn_pclGetOwnerDataWithName( "EditedGenerator" );
ASSERT( p_clOwnerData != NULL );
CPA_PartGen_Generator *p_clGenerator = (CPA_PartGen_Generator*)( p_clOwnerData->m_pub_fn_pvGetDataPtr() );
ASSERT (p_clGenerator);
ASSERT (g_pclInterface->m_clDocument.m_pub_p_clCurrentGenerator == p_clGenerator);
CString csCurrentGeneratorName = p_clGenerator->GetName ();
CPA_PartGen_Environment *pSelectedEnv = (CPA_PartGen_Environment*)pNewElement->m_pub_fn_pvGetAdditionnalPointer();
ASSERT (pSelectedEnv);
PRT_tdstParticlesEnvironment *pSelectedEngEnv = pSelectedEnv->m_pub_fn_p_stGetEnv();
//check every generator to see if the environment is already used
CPA_BaseObjectList * p_clList = g_pclInterface->GetMainWorld()->fn_p_oGetOriginalObjectList(C_szPartGenGeneratorName);
CPA_PartGen_Generator *p_Generator = NULL;
Position pos = p_clList->GetHeadPosition();
while (pos != NULL)
{
p_Generator = (CPA_PartGen_Generator *)p_clList->GetNext (pos);
ASSERT (p_Generator);
if (p_Generator->GetName() == csCurrentGeneratorName) //don't count the current generator
continue;
tdxHandleToParticleGenerator pEngGenerator = p_Generator->m_pub_fn_hGetGenerator();
if (NULL == pEngGenerator)
continue;
PRT_tdstParticlesEnvironment *pEngEnv = pEngGenerator->p_stPrtEnv;
if (NULL == pEngEnv)
continue;
if (pSelectedEngEnv == pEngEnv)
{
AfxMessageBox ("This environment is already used.\nPlease, select another one.");
return 0;
}
}
return 1;
}
//ENDROMTEAM Bugs Correction (Cristian Stegaru)

View File

@@ -0,0 +1,517 @@
///////////////////////////////////////////////////
//
// Particles Generator Environment
//
///////////////////////////////////////////////////
#include "StdAfx.h"
#define D_MSPrtSrc_StructureDefine
#include "TPG_OEnv.hpp"
#include "_Minterf.hpp"
#include "TPG_Strg.hpp"
#include "TPG_ClBk.hpp"
#include "PRT.h"
#include "GAM.h"
#include "MTH.h"
#include "ErO.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
////////////////////////////////////////////////
// Constructor and Destructor
////////////////////////////////////////////////
CPA_PartGen_Environment::CPA_PartGen_Environment(CString _csName, PRT_tdstParticlesEnvironment *_p_stEnv, BOOL _bIsLoaded )
: CPA_SaveObject( g_pclInterface, g_C_csPartGenEnvName, E_ss_Responsible )
{
// Initialization for CPA_SaveObject
SetSectionData( this );
SetCallBackSave( m_s_fn_vCallBackSaveEnv );
SetDataPath( C_szEffectPath );
if ( fn_eRename(_csName) != E_mc_None )
SetDefaultValidName();
fn_vUpdateSectionName();
m_pri_p_clGenerator = NULL;
if( _bIsLoaded )
{
if ( _p_stEnv == NULL ) //created when new button is pressed : engine object is created
{
SetExistingSection( FALSE );
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"Creating a new environment",
"CPA_PartGen_Environment::CPA_PartGen_Environment",
E_ERROR_GRAVITY_FATAL,
"the engine object is not allocated"
);
PRT_fn_vCreateParticlesEnvironment( &_p_stEnv );
ERROR_ASSERT( _p_stEnv != NULL );
fn_vUpdateData( (void*)_p_stEnv );
m_pri_p_stEnv = _p_stEnv;
m_pub_fn_vSetEnvType(PRT_C_ulSphereEnv);
m_pub_fn_vSetBoxMin( 0.0, 0.0, 0.0 );
m_pub_fn_vSetBoxMax( 1.0, 1.0, 1.0 );
m_pub_fn_vSetSphereCenter( 0.0, 0.0, 0.0 );
}
else //created using linktable : engine object is loaded and used
{
SetExistingSection( TRUE );
fn_vUpdateData( (void*)_p_stEnv );
m_pri_p_stEnv = _p_stEnv;
}
m_pri_fn_vSetInternalPoints();
m_pri_fn_vFillDataList();
}
else //created : engine object is not loaded now
{
fn_vUpdateData( NULL );
m_pri_p_stEnv = NULL;
SetExistingSection( TRUE );
}
SetAvailable( _bIsLoaded );
}
CPA_PartGen_Environment::~CPA_PartGen_Environment()
{
fn_vNotifyUnSave();
}
//*********************************************
// Updates the pointer on engine object
void CPA_PartGen_Environment::m_pub_fn_vSetEnv( PRT_tdstParticlesEnvironment *_p_stEnv )
{
fn_vUpdateData( (void*)_p_stEnv );
m_pri_p_stEnv = _p_stEnv;
SetAvailable( TRUE );
m_pri_fn_vSetInternalPoints();
m_pri_fn_vFillDataList();
}
void CPA_PartGen_Environment::m_pub_fn_vSetGenerator( CPA_PartGen_Generator *_p_clGen )
{
m_pri_p_clGenerator = _p_clGen;
m_pri_fn_vSetInternalPoints();
}
/////////////////////////////////////////
// virtual functions
/////////////////////////////////////////
long CPA_PartGen_Environment::GetDataType( void )
{
return( 0 );
}
void* CPA_PartGen_Environment::GetData( void )
{
return (void*)m_pri_p_stEnv;
}
CString CPA_PartGen_Environment::fn_csComputeReferencedSectionName(const CString _csNewName)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
char szSectionName[ SCR_CV_ui_Cfg_MaxLenName ];
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
sprintf( szSectionName, "%s^%s:%s", C_szEnvironmentFileName, C_SectionPrtEnvDescription, (char *) LPCTSTR( _csNewName ) );
return( szSectionName );
}
//****************************************************
// load the engine object if necessary
BOOL CPA_PartGen_Environment::m_pub_fn_vLoadIfUnloaded()
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
SCR_tdst_Cxt_Values *p_stValues;
PRT_tdstParticlesEnvironment *p_stEnv;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
if ( fn_bIsAvailable() )
return FALSE;
p_stValues = SCR_fnp_st_RdL0_AnalyseSection((char *)LPCTSTR(GetReferencedSectionName()), SCR_CDF_uw_Anl_Normal);
p_stEnv = (PRT_tdstParticlesEnvironment*)p_stValues->a_ulValues[0];
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"Loading an unloaded environment",
"CPA_PartGen_Environment::m_pub_fn_vLoadIfUnloaded",
E_ERROR_GRAVITY_FATAL,
"the loaded engine object is null"
);
ERROR_ASSERT( p_stEnv != NULL );
fn_vUpdateData( (void*) p_stEnv );
m_pri_p_stEnv = p_stEnv;
SetAvailable(TRUE);
m_pri_fn_vFillDataList();
return TRUE;
}
//////////////////////////////////////////////////
// Environment Type
void CPA_PartGen_Environment::m_pub_fn_vSetEnvType( short _wIndex )
{
PRT_M_vSetTypeParticlesEnvironment( m_pri_p_stEnv, (unsigned long)_wIndex );
fn_vNotifySave();
}
short CPA_PartGen_Environment::m_pub_fn_wGetEnvType()
{
return (short)m_pri_p_stEnv->ulEnvType;
}
/////////////////////////////////////////////////
// Min Max for Box type
void CPA_PartGen_Environment::m_pri_fn_vSetInternalPoints()
{
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"Initialize internal data min max points and center for environment",
"CPA_PartGen_Environment::m_pri_fn_vSetInternalPoints",
E_ERROR_GRAVITY_FATAL,
"Edited engine environment is NULL"
);
ERROR_ASSERT( m_pri_p_stEnv != NULL );
if( m_pri_p_clGenerator == NULL )
{
MTH3D_M_vCopyVector( (&m_pri_stMinPoint), (&(m_pri_p_stEnv->stMinPoint)) );
MTH3D_M_vCopyVector( (&m_pri_stMaxPoint), (&(m_pri_p_stEnv->stMaxPoint)) );
MTH3D_M_vCopyVector( (&m_pri_stSphereCenter), (&(m_pri_p_stEnv->stSphereCenter)) );
}
else
{
if( m_pri_p_clGenerator->m_pub_fn_bGetLinkToEnv() )
{
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"Initialize internal data min max points and center for environment",
"CPA_PartGen_Environment::m_pri_fn_vSetInternalPoints",
E_ERROR_GRAVITY_FATAL,
"Engine generator using the edited environment is NULL"
);
ERROR_ASSERT( m_pri_p_clGenerator->m_pri_hGenerator != NULL );
MTH3D_M_vCopyVector( (&m_pri_stMinPoint), (&(m_pri_p_clGenerator->m_pri_hGenerator->stMinPoint)) );
MTH3D_M_vCopyVector( (&m_pri_stMaxPoint), (&(m_pri_p_clGenerator->m_pri_hGenerator->stMaxPoint)) );
MTH3D_M_vCopyVector( (&m_pri_stSphereCenter), (&(m_pri_p_clGenerator->m_pri_hGenerator->stMinPoint)) );
}
else
{
MTH3D_M_vCopyVector( (&m_pri_stMinPoint), (&(m_pri_p_stEnv->stMinPoint)) );
MTH3D_M_vCopyVector( (&m_pri_stMaxPoint), (&(m_pri_p_stEnv->stMaxPoint)) );
MTH3D_M_vCopyVector( (&m_pri_stSphereCenter), (&(m_pri_p_stEnv->stSphereCenter)) );
}
}
}
void CPA_PartGen_Environment::m_pub_fn_vSetBoxMin( double _dMinX, double _dMinY, double _dMinZ )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
MTH3D_tdstVector stBoxMin;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
MTH3D_M_vSetVectorElements( &stBoxMin, MTH_M_xDoubleToReal(_dMinX), MTH_M_xDoubleToReal(_dMinY), MTH_M_xDoubleToReal(_dMinZ) );
MTH3D_M_vCopyVector ( &((m_pri_p_stEnv)->stMinPoint), ( &stBoxMin ) );
fn_vNotifySave();
}
double CPA_PartGen_Environment::m_pub_fn_dGetBoxMinX()
{
return MTH_M_xRealToDouble( MTH3D_M_xGetXofVector( &m_pri_stMinPoint ) );
}
double CPA_PartGen_Environment::m_pub_fn_dGetBoxMinY()
{
return MTH_M_xRealToDouble( MTH3D_M_xGetYofVector( &m_pri_stMinPoint ) );
}
double CPA_PartGen_Environment::m_pub_fn_dGetBoxMinZ()
{
return MTH_M_xRealToDouble( MTH3D_M_xGetZofVector( &m_pri_stMinPoint ) );
}
void CPA_PartGen_Environment::m_pub_fn_vSetBoxMax( double _dMaxX, double _dMaxY, double _dMaxZ )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
MTH3D_tdstVector stBoxMax;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
MTH3D_M_vSetVectorElements( &stBoxMax, MTH_M_xDoubleToReal(_dMaxX), MTH_M_xDoubleToReal(_dMaxY), MTH_M_xDoubleToReal(_dMaxZ) );
MTH3D_M_vCopyVector ( &((m_pri_p_stEnv)->stMaxPoint), ( &stBoxMax ) );
fn_vNotifySave();
}
double CPA_PartGen_Environment::m_pub_fn_dGetBoxMaxX()
{
return MTH_M_xRealToDouble( MTH3D_M_xGetXofVector( &m_pri_stMaxPoint ) );
}
double CPA_PartGen_Environment::m_pub_fn_dGetBoxMaxY()
{
return MTH_M_xRealToDouble( MTH3D_M_xGetYofVector( &m_pri_stMaxPoint ) );
}
double CPA_PartGen_Environment::m_pub_fn_dGetBoxMaxZ()
{
return MTH_M_xRealToDouble( MTH3D_M_xGetZofVector( &m_pri_stMaxPoint ) );
}
///////////////////////////////////////////////////////
// Center and Radius for Sphere type
void CPA_PartGen_Environment::m_pub_fn_vSetSphereCenter( double _dCenterX, double _dCenterY, double _dCenterZ )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
MTH3D_tdstVector stSphereCenter;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
MTH3D_M_vSetVectorElements( &stSphereCenter, MTH_M_xDoubleToReal(_dCenterX), MTH_M_xDoubleToReal(_dCenterY), MTH_M_xDoubleToReal(_dCenterZ) );
MTH3D_M_vCopyVector ( &((m_pri_p_stEnv)->stSphereCenter), ( &stSphereCenter ) );
fn_vNotifySave();
}
double CPA_PartGen_Environment::m_pub_fn_dGetSphereCenterX()
{
//ROMTEAM Bugs Correction (Cristian Stegaru 24/03/98)
// return MTH_M_xRealToDouble( MTH3D_M_xGetXofVector( &m_pri_stSphereCenter ) );
return MTH_M_xRealToDouble (MTH3D_M_xGetXofVector (&m_pri_p_stEnv->stSphereCenter));
//ENDROMTEAM Bugs Correction (Cristian Stegaru)
}
double CPA_PartGen_Environment::m_pub_fn_dGetSphereCenterY()
{
//ROMTEAM Bugs Correction (Cristian Stegaru 24/03/98)
// return MTH_M_xRealToDouble( MTH3D_M_xGetYofVector( &m_pri_stSphereCenter ) );
return MTH_M_xRealToDouble (MTH3D_M_xGetYofVector (&m_pri_p_stEnv->stSphereCenter));
//ENDROMTEAM Bugs Correction (Cristian Stegaru)
}
double CPA_PartGen_Environment::m_pub_fn_dGetSphereCenterZ()
{
//ROMTEAM Bugs Correction (Cristian Stegaru 24/03/98)
// return MTH_M_xRealToDouble( MTH3D_M_xGetZofVector( &m_pri_stSphereCenter ) );
return MTH_M_xRealToDouble (MTH3D_M_xGetZofVector (&m_pri_p_stEnv->stSphereCenter));
//ENDROMTEAM Bugs Correction (Cristian Stegaru)
}
double CPA_PartGen_Environment::m_pub_fn_dGetSphereRadius()
{
return MTH_M_xRealToDouble( m_pri_p_stEnv->xRadius );
}
///////////////////////////////////////////////////////
// Acceleration and Range
void CPA_PartGen_Environment::m_pub_fn_vSetAcceleration( double _dAccelerX, double _dAccelerY, double _dAccelerZ )
{
MTH3D_tdstVector stAcceleration;
MTH3D_M_vSetVectorElements( &stAcceleration, MTH_M_xDoubleToReal(_dAccelerX), MTH_M_xDoubleToReal(_dAccelerY), MTH_M_xDoubleToReal(_dAccelerZ) );
PRT_M_vSetAccelerationParticlesEnvironment( m_pri_p_stEnv, ( &stAcceleration ) );
fn_vNotifySave();
}
double CPA_PartGen_Environment::m_pub_fn_dGetAccelerX()
{
return MTH_M_xRealToDouble( MTH3D_M_xGetXofVector( &((m_pri_p_stEnv)->stAcceleration )) );
}
double CPA_PartGen_Environment::m_pub_fn_dGetAccelerY()
{
return MTH_M_xRealToDouble( MTH3D_M_xGetYofVector( &((m_pri_p_stEnv)->stAcceleration )) );
}
double CPA_PartGen_Environment::m_pub_fn_dGetAccelerZ()
{
return MTH_M_xRealToDouble( MTH3D_M_xGetZofVector( &((m_pri_p_stEnv)->stAcceleration) ) );
}
void CPA_PartGen_Environment::m_pub_fn_vSetRange( double _dRange )
{
PRT_M_vSetAccelerationRangeParticlesEnvironment( m_pri_p_stEnv, MTH_M_xDoubleToReal(_dRange) );
fn_vNotifySave();
}
double CPA_PartGen_Environment::m_pub_fn_dGetRange()
{
return MTH_M_xRealToDouble( m_pri_p_stEnv->xAccelerationRange );
}
/////////////////////////////////////////////////////
// CallBack and function for save
void CPA_PartGen_Environment::m_s_fn_vCallBackSaveEnv
(
SCR_tdst_File_Description *_p_stFile,
char *_p_szSectionName,
void *_p_vData,
SCR_tde_Ntfy_Action _eAction
)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
CPA_PartGen_Environment *p_clEnv;
char szSectionName[ SCR_CV_ui_Cfg_MaxLenName ];
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"Saving an environment",
"CPA_PartGen_Environment::m_s_fn_vCallBackSaveEnv",
E_ERROR_GRAVITY_FATAL,
"trying to save a NULL environment"
);
p_clEnv = (CPA_PartGen_Environment*)_p_vData;
ERROR_ASSERT( p_clEnv != NULL );
switch( _eAction )
{
case SCR_EA_Ntfy_AddSection:
case SCR_EA_Ntfy_AddOrModifySection:
case SCR_EA_Ntfy_AddOrRebuildSection:
case SCR_EA_Ntfy_RebuildSection:
case SCR_EA_Ntfy_ModifySection:
{
sprintf( szSectionName, "%s:%s", C_SectionPrtEnvDescription, (char *) LPCTSTR(p_clEnv->GetName()) );
SCR_M_SvL0_SaveBeginSection( _p_stFile, szSectionName, SCR_CC_C_Cfg_EOL );
p_clEnv->m_pri_fn_vSaveEnv( _p_stFile );
SCR_M_SvL0_SaveEndSection( _p_stFile, SCR_CC_C_Cfg_EOL );
p_clEnv->fn_vSectionSaved();
}
break;
case SCR_EA_Ntfy_DeleteIfExists:
case SCR_EA_Ntfy_DeleteSection:
p_clEnv->fn_vSectionDeleted();
break;
}
}
void CPA_PartGen_Environment::m_pri_fn_vSaveEnv( SCR_tdst_File_Description *_p_stFile )
{
short wIndex = m_pub_fn_wGetEnvType();
SCR_M_SvL0_SaveEntry( _p_stFile, C_EntryPrtEnvType, SCR_CC_C_Cfg_NoChar );
SCR_fn_v_SvL0_SaveParameters_MP( _p_stFile, SCR_EF_SvL0_Scanf, 1, M_MAKECHAR(g_C_a_csEnvironmentTypeName[wIndex]) );
switch( wIndex )
{
case ((short)PRT_C_ulAlignedBoxEnv):
SCR_M_SvL0_SaveEntry( _p_stFile, C_EntryPrtEnvMinMaxPoint, SCR_CC_C_Cfg_NoChar );
SCR_fn_v_SvL0_SaveParameters_MP
(
_p_stFile, SCR_EF_SvL0_Scanf, 7, "%.3f,%.3f,%.3f,%.3f,%.3f,%.3f",
m_pub_fn_dGetBoxMinX(), m_pub_fn_dGetBoxMinY(), m_pub_fn_dGetBoxMinZ(),
m_pub_fn_dGetBoxMaxX(), m_pub_fn_dGetBoxMaxY(), m_pub_fn_dGetBoxMaxZ()
);
break;
case ((short)PRT_C_ulSphereEnv):
SCR_M_SvL0_SaveEntry( _p_stFile, C_EntryPrtEnvSphere, SCR_CC_C_Cfg_NoChar );
SCR_fn_v_SvL0_SaveParameters_MP
(
_p_stFile, SCR_EF_SvL0_Scanf, 5, "%.3f,%.3f,%.3f,%.3f",
m_pub_fn_dGetSphereCenterX(), m_pub_fn_dGetSphereCenterY(), m_pub_fn_dGetSphereCenterZ(),
m_pub_fn_dGetSphereRadius()
);
break;
}
SCR_M_SvL0_SaveEntry( _p_stFile, C_EntryPrtEnvAcceleration, SCR_CC_C_Cfg_NoChar );
SCR_fn_v_SvL0_SaveParameters_MP
(
_p_stFile, SCR_EF_SvL0_Scanf, 5, "%.3f,%.3f,%.3f,%.3f",
m_pub_fn_dGetAccelerX(), m_pub_fn_dGetAccelerY(), m_pub_fn_dGetAccelerZ(),
m_pub_fn_dGetRange()
);
}
void CPA_PartGen_Environment::m_pri_fn_vFillDataList()
{
CTL_Editor_Data *p_clData = NULL;
CTL_Editor_EnumDescriptor *p_clEnumDescriptor = NULL;
//**** Environment type *********************
p_clEnumDescriptor = m_pub_fn_p_clGetDocument()->m_pub_fn_p_clGetEnumDescriptorByName( "Env_Type" );
p_clData = m_pub_clDataList.m_fn_pclAddEnumData( p_clEnumDescriptor, "Environment Type" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_p_stEnv->ulEnvType) );
p_clData->m_pub_fn_vSetDataChangedSpecialCallBackFunction( g_fn_vCallBackDataChangedSpecialDisplayGenerator );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedEnv" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( g_fn_vCallBackDataChangedEnv );
//*** Box Min env *******************************
p_clData = m_pub_clDataList.m_fn_pclAddVectorData( sizeof(MTH_tdxReal), "Min" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_stMinPoint) );
p_clData->m_pub_fn_pclAddOwnerData( (void*)&(m_pri_p_stEnv->ulEnvType), "EnvType" );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedEnv" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( g_fn_vCallBackDataChangedEnv );
p_clData->m_pub_fn_vSetModificationFunctionWhenWrite( g_fn_vModificationWriteEnvBox );
//*** Box Max env *******************************
p_clData = m_pub_clDataList.m_fn_pclAddVectorData( sizeof(MTH_tdxReal), "Max" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_stMaxPoint) );
p_clData->m_pub_fn_pclAddOwnerData( (void*)&(m_pri_p_stEnv->ulEnvType), "EnvType" );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedEnv" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( g_fn_vCallBackDataChangedEnv );
p_clData->m_pub_fn_vSetModificationFunctionWhenWrite( g_fn_vModificationWriteEnvBox );
//*** Sphere Center *****************************
p_clData = m_pub_clDataList.m_fn_pclAddVectorData( sizeof(MTH_tdxReal), "Center" );
//ROMTEAM Bugs Correction (Cristian Stegaru 24/03/98)
// p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_stSphereCenter) );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_p_stEnv->stSphereCenter) );
//ENDROMTEAM Bugs Correction (Cristian Stegaru)
p_clData->m_pub_fn_pclAddOwnerData( (void*)&(m_pri_p_stEnv->ulEnvType), "EnvType" );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedEnv" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( g_fn_vCallBackDataChangedEnv );
p_clData->m_pub_fn_vSetModificationFunctionWhenWrite( g_fn_vModificationWriteEnvSphere );
//*** Sphere radius ******************************
p_clData = m_pub_clDataList.m_fn_pclAddDecimalData( sizeof(MTH_tdxReal), "Radius" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_p_stEnv->xRadius) );
p_clData->m_pub_fn_pclAddOwnerData( (void*)&(m_pri_p_stEnv->ulEnvType), "EnvType" );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedEnv" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( g_fn_vCallBackDataChangedEnv );
//*** Acceleration ******************************
p_clData = m_pub_clDataList.m_fn_pclAddVectorData( sizeof(MTH_tdxReal), "Acceleration" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_p_stEnv->stAcceleration) );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedEnv" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( g_fn_vCallBackDataChangedEnv );
//*** Acceleration range *******************************
p_clData = m_pub_clDataList.m_fn_pclAddDecimalData( sizeof(MTH_tdxReal), "Range" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_p_stEnv->xAccelerationRange) );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedEnv" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( g_fn_vCallBackDataChangedEnv );
}
CPA_PartGen_MyDocument * CPA_PartGen_Environment::m_pub_fn_p_clGetDocument()
{
return g_pclInterface->m_pub_fn_p_clGetDocument();
}

View File

@@ -0,0 +1,542 @@
////////////////////////////////////////////////////
//
// Particles Generator and Source
//
////////////////////////////////////////////////////
#include "StdAfx.h"
#define D_MSPrtSrc_StructureDefine
#include "TPG_OGen.hpp"
#include "TPG_OEnv.hpp"
#include "TPG_OSys.hpp"
#include "_Minterf.hpp"
#include "TPG_Strg.hpp"
#include "TPG_ClBk.hpp"
#include "PRT.h"
#include "MTH.h"
#include "CTL.h"
#include "ErO.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
////////////////////////////////////////////
// Constructor and destructor
////////////////////////////////////////////
CPA_PartGen_Generator:: CPA_PartGen_Generator(CString _csName, tdxHandleToParticleGenerator _hGenerator, BOOL _bIsLoaded)
: CPA_SaveObject( g_pclInterface, g_C_csPartGenGeneratorName, E_ss_Responsible )
{
//*** initialization for CPA_SaveObject
SetSectionData( this );
SetCallBackSave( m_s_fn_vCallBackSaveGenerator );
SetDataPath( C_szEffectPath );
if ( fn_eRename(_csName) != E_mc_None )
SetDefaultValidName();
fn_vUpdateSectionName();
//*** Section to save the associated source ***
/*
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"Creating a new generator",
"CPA_PartGen_Generator::CPA_PartGen_Generator",
E_ERROR_GRAVITY_FATAL,
"the new section for the source associated is not allocated"
);
m_pri_p_clSourceSection = new CPA_SectionObject
(
m_pri_fn_csGetSourceReferencedSectionName(),
C_szEffectPath,
m_s_fn_vCallBackSaveSource,
this
);
ERROR_ASSERT( m_pri_p_clSourceSection != NULL );
*/
if ( !_bIsLoaded ) //object find in a script file but not loaded in link table
{
fn_vUpdateData(NULL);
m_pri_hGenerator = NULL;
//m_pri_p_stSource = NULL;
SetExistingSection( TRUE );
//m_pri_p_clSourceSection->SetExistingSection( TRUE );
}
else
{
if ( _hGenerator == NULL )
{
SetExistingSection( FALSE );
//m_pri_p_clSourceSection->SetExistingSection( FALSE );
// for a new generator, initializes all the values
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"Creating a new generator",
"CPA_PartGen_Generator::CPA_PartGen_Generator",
E_ERROR_GRAVITY_FATAL,
"the engine object generator is not allocated"
);
_hGenerator= fn_hParticleGeneratorAllocation();
ERROR_ASSERT( _hGenerator != NULL );
fn_vUpdateData( (void*)_hGenerator );
m_pri_hGenerator = _hGenerator;
m_pub_fn_vSetEnvActiveWater( TRUE );
m_pub_fn_vSetEnvActiveAir( TRUE );
m_pub_fn_vSetLinkToEnv( FALSE );
/*
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"Creating a new generator",
"CPA_PartGen_Generator::CPA_PartGen_Generator",
E_ERROR_GRAVITY_FATAL,
"the engine object source is not allocated"
);
PRT_fn_vCreateParticlesSource( &m_pri_p_stSource );
ERROR_ASSERT( m_pri_p_stSource != NULL );
fn_vPrtGenSetSrc( m_pri_hGenerator, m_pri_p_stSource );
m_pub_fn_vSetGenerationMode( (short)PRT_C_ucNoGeneration );
m_pub_fn_vSetNbGenerateMode( (short)PRT_C_ucConstantNb );
m_pub_fn_vSetGeometryMode( (short)PRT_C_ucPoint);
m_pub_fn_vSetLinkMode( (short)PRT_C_ucRotationLink);
m_pub_fn_vSetSpeed( (double)0 );
m_pub_fn_vSetSpeedRange( (double)0 );
*/
m_pri_fn_vFillDataList();
}
else
{
SetExistingSection( TRUE );
//m_pri_p_clSourceSection->SetExistingSection( TRUE );
fn_vUpdateData( (void*)_hGenerator );
m_pri_hGenerator = _hGenerator;
//m_pri_p_stSource = fn_p_stPrtGenGetSrc(m_pri_hGenerator);
CPA_PartGen_Environment *p_clEnv = m_pub_fn_p_clGetEnv();
p_clEnv->m_pub_fn_vSetGenerator( this );
m_pri_fn_vFillDataList();
}
}
SetAvailable( _bIsLoaded );
}
CPA_PartGen_Generator::~CPA_PartGen_Generator()
{
fn_vNotifyUnSave();
}
///////////////////////////////////////
// Virtual functions
long CPA_PartGen_Generator::GetDataType( void )
{
return( 0 );
}
void* CPA_PartGen_Generator::GetData( void )
{
return (void*) m_pri_hGenerator;
}
CString CPA_PartGen_Generator::fn_csComputeReferencedSectionName(const CString _csNewName)
{
CString csReturnedName = "Generators.prt^";
csReturnedName += C_SectionParticleGenerator;
csReturnedName += ":";
return( csReturnedName + _csNewName );
}
void CPA_PartGen_Generator::fn_vNotifySave( void )
{
CPA_SaveObject::fn_vNotifySave();
//m_pri_p_clSourceSection->fn_vWriteSection();
}
void CPA_PartGen_Generator::fn_vNotifyUnSave( void )
{
CPA_SaveObject::fn_vNotifyUnSave();
//m_pri_p_clSourceSection->fn_vDeleteSection();
}
//**************************************************
// Load if necessary
BOOL CPA_PartGen_Generator::m_pub_fn_vLoadIfUnloaded()
{
if ( !fn_bIsAvailable() )
{
CString csSectionName = GetReferencedSectionName();
SCR_tdst_Cxt_Values *p_stValues;
p_stValues = SCR_fnp_st_RdL0_AnalyseSection((char *)LPCTSTR(csSectionName), SCR_CDF_uw_Anl_Normal);
tdxHandleToParticleGenerator hGenerator = (tdxHandleToParticleGenerator)p_stValues->a_ulValues[0];
fn_vUpdateData( (void*)hGenerator );
m_pri_hGenerator = hGenerator;
//m_pri_p_stSource = fn_p_stPrtGenGetSrc(m_pri_hGenerator);
SetAvailable(TRUE);
m_pri_fn_vFillDataList();
return TRUE;
}
return FALSE;
}
/*
----------------------------------------------------------------------------------------
Description : set engine data
_hGenerator -> engine generator
----------------------------------------------------------------------------------------
*/
void CPA_PartGen_Generator::m_pub_fn_vSetGenerator( tdxHandleToParticleGenerator _hGenerator)
{
fn_vUpdateData( (void*) _hGenerator );
m_pri_hGenerator = _hGenerator;
SetAvailable( TRUE );
m_pri_fn_vFillDataList();
}
//***************************************************************
// returns a pointer on the associated ParticleSource
CPA_PartGen_Source* CPA_PartGen_Generator::m_pub_fn_p_clGetSource()
{
PRT_tdstParticlesSource *p_stPrtSrc;
if( m_pri_hGenerator == NULL )
return NULL;
if( (p_stPrtSrc = fn_p_stPrtGenGetSrc( m_pri_hGenerator )) == NULL )
return NULL;
return g_pclInterface->m_pub_fn_p_clFindSourceWithEngine( p_stPrtSrc );
}
//***************************************************************
// returns a pointer on the system associated
CPA_PartGen_System* CPA_PartGen_Generator::m_pub_fn_p_clGetSystem()
{
PRT_tdstParticlesSystem *p_stSystem;
if( m_pri_hGenerator == NULL )
return NULL;
p_stSystem = fn_p_stPrtGenGetPrtSys( m_pri_hGenerator );
if( p_stSystem == NULL )
return NULL;
return g_pclInterface->m_pub_fn_p_clFindSystemWithEngine( p_stSystem );
}
//***************************************************************
// returns a pointer on the environment associated
CPA_PartGen_Environment* CPA_PartGen_Generator::m_pub_fn_p_clGetEnv()
{
PRT_tdstParticlesEnvironment *p_stEnv;
if( m_pri_hGenerator == NULL )
return NULL;
p_stEnv = fn_p_stPrtGenGetPrtEnv( m_pri_hGenerator );
if( p_stEnv == NULL )
return NULL;
return g_pclInterface->m_pub_fn_p_clFindEnvWithEngine( p_stEnv );
}
//***************************************************************
// returns a pointer on the linked generator associated
CPA_PartGen_Generator *CPA_PartGen_Generator::m_pub_fn_p_oGetLinkedPrtGen()
{
tdxHandleToParticleGenerator hPrtGen;
if( m_pri_hGenerator == NULL )
return NULL;
hPrtGen = fn_hPrtGenGetLinkedGen( m_pri_hGenerator );
if( hPrtGen == NULL )
return NULL;
return g_pclInterface->m_pub_fn_p_clFindPrtGenWithEngine( hPrtGen );
}
///////////////////////////////////////////////
// Associated source, System and Environment
void CPA_PartGen_Generator::m_pub_fn_vSetSource( CPA_PartGen_Source* _p_oPrtSrc )
{
if( _p_oPrtSrc != NULL )
fn_vPrtGenSetSrc( m_pri_hGenerator, _p_oPrtSrc->m_pub_fn_p_stGetSource() );
else
fn_vPrtGenSetSrc( m_pri_hGenerator, NULL );
fn_vNotifySave();
}
void CPA_PartGen_Generator::m_pub_fn_vSetSystem( CPA_PartGen_System* _p_clSystem )
{
if( _p_clSystem != NULL )
fn_vPrtGenSetPrtSys( m_pri_hGenerator, _p_clSystem->m_pub_fn_p_stGetSystem() );
else
fn_vPrtGenSetPrtSys( m_pri_hGenerator, NULL );
fn_vNotifySave();
}
void CPA_PartGen_Generator::m_pub_fn_vSetEnv( CPA_PartGen_Environment* _p_clEnv )
{
if( _p_clEnv != NULL )
{
fn_vPrtGenSetPrtEnv( m_pri_hGenerator, _p_clEnv->m_pub_fn_p_stGetEnv() );
m_pub_fn_vSetGenInEnv();
}
else
fn_vPrtGenSetPrtEnv( m_pri_hGenerator, NULL );
fn_vNotifySave();
}
void CPA_PartGen_Generator::m_pub_fn_vSetGenInEnv()
{
CPA_PartGen_Environment *p_clEnv = m_pub_fn_p_clGetEnv();
p_clEnv->m_pub_fn_vSetGenerator( this );
}
//////////////////////////////////////////////////
// Link to environment
void CPA_PartGen_Generator::m_pub_fn_vSetLinkToEnv( BOOL _bFlag )
{
fn_vPrtGenSetLinkValue( m_pri_hGenerator, (unsigned char)_bFlag );
fn_vNotifySave();
}
BOOL CPA_PartGen_Generator::m_pub_fn_bGetLinkToEnv()
{
return (BOOL)fn_ucPrtGenGetLinkValue( m_pri_hGenerator );
}
///////////////////////////////////////////////////////
// Environment Mask
void CPA_PartGen_Generator::m_pub_fn_vSetEnvActiveWater( BOOL _bFlag )
{
long lMask = fn_lPrtGenGetEnvironmentMask( m_pri_hGenerator );
lMask = ( _bFlag ? (lMask | C_lEnvironmentWater) : (lMask & (C_lAllEnvironments - C_lEnvironmentWater)) );
fn_vPrtGenSetEnvironmentMask( m_pri_hGenerator, lMask );
fn_vNotifySave();
}
void CPA_PartGen_Generator::m_pub_fn_vSetEnvActiveAir( BOOL _bFlag )
{
long lMask = fn_lPrtGenGetEnvironmentMask( m_pri_hGenerator );
lMask = ( _bFlag ? (lMask | C_lEnvironmentAir) : (lMask & (C_lAllEnvironments - C_lEnvironmentAir)) );
fn_vPrtGenSetEnvironmentMask( m_pri_hGenerator, lMask );
fn_vNotifySave();
}
long CPA_PartGen_Generator::m_pub_fn_lGetEnvironmentMask()
{
return fn_lPrtGenGetEnvironmentMask( m_pri_hGenerator );
}
/////////////////////////////////////////////////////////
// CallBack and function for save
void CPA_PartGen_Generator::m_s_fn_vCallBackSaveGenerator
(
SCR_tdst_File_Description *_p_stFile,
char *_p_szSectionName,
void *_p_vData,
SCR_tde_Ntfy_Action _eAction
)
{
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"Saving a generator",
"CPA_PartGen_Generator::m_s_fn_vCallBackSaveGenerator",
E_ERROR_GRAVITY_FATAL,
"trying to save a NULL generator"
);
CPA_PartGen_Generator *p_clGen = (CPA_PartGen_Generator*)_p_vData;
ERROR_ASSERT( p_clGen != NULL );
CString csHeaderName = C_SectionParticleGenerator;
switch( _eAction )
{
case SCR_EA_Ntfy_AddSection:
case SCR_EA_Ntfy_AddOrModifySection:
case SCR_EA_Ntfy_AddOrRebuildSection:
case SCR_EA_Ntfy_RebuildSection:
case SCR_EA_Ntfy_ModifySection:
csHeaderName += ":";
csHeaderName += p_clGen->GetName();
SCR_M_SvL0_SaveBeginSection( _p_stFile, M_MAKECHAR(csHeaderName), SCR_CC_C_Cfg_EOL );
p_clGen->m_pri_fn_vSaveGenerator( _p_stFile );
SCR_M_SvL0_SaveEndSection( _p_stFile, SCR_CC_C_Cfg_EOL );
p_clGen->fn_vSectionSaved();
break;
case SCR_EA_Ntfy_DeleteIfExists:
case SCR_EA_Ntfy_DeleteSection:
p_clGen->fn_vSectionDeleted();
break;
}
}
void CPA_PartGen_Generator::m_pri_fn_vSaveGenerator( SCR_tdst_File_Description *_p_stFile )
{
// associated source
CPA_PartGen_Source *p_oPrtSrc = m_pub_fn_p_clGetSource();
if( p_oPrtSrc != NULL )
{
SCR_M_SvL0_SaveEntry( _p_stFile, C_EntryPrtGenLoadParticleSource, SCR_CC_C_Cfg_NoChar );
SCR_fn_v_SvL0_SaveParameters_MP( _p_stFile, SCR_EF_SvL0_Scanf, 1, M_MAKECHAR( p_oPrtSrc->GetReferencedSectionName() ) );
}
// associated system
CPA_PartGen_System *p_clSys = m_pub_fn_p_clGetSystem();
if( p_clSys != NULL )
{
SCR_M_SvL0_SaveEntry( _p_stFile, C_EntryPrtGenLoadParticleSystem, SCR_CC_C_Cfg_NoChar );
SCR_fn_v_SvL0_SaveParameters_MP( _p_stFile, SCR_EF_SvL0_Scanf, 1, M_MAKECHAR( p_clSys->GetReferencedSectionName() ) );
}
// associated environment
CPA_PartGen_Environment *p_clEnv = m_pub_fn_p_clGetEnv();
if( p_clEnv != NULL )
{
SCR_M_SvL0_SaveEntry( _p_stFile, C_EntryPrtGenLoadParticleEnvironment, SCR_CC_C_Cfg_NoChar );
SCR_fn_v_SvL0_SaveParameters_MP( _p_stFile, SCR_EF_SvL0_Scanf, 1, M_MAKECHAR( p_clEnv->GetReferencedSectionName() ) );
}
// linked to environment
SCR_M_SvL0_SaveEntry( _p_stFile, C_EntryPrtGenLinkedToEnvironment, SCR_CC_C_Cfg_NoChar );
if( m_pub_fn_bGetLinkToEnv() )
SCR_fn_v_SvL0_SaveParameters_MP( _p_stFile, SCR_EF_SvL0_Scanf, 1, C_szLinkedToEnvironment );
else
SCR_fn_v_SvL0_SaveParameters_MP( _p_stFile, SCR_EF_SvL0_Scanf, 1, C_szNotLinkedToEnvironment );
// environment mask
SCR_M_SvL0_SaveEntry( _p_stFile, C_EntryPrtGenEnvironmentMask, SCR_CC_C_Cfg_NoChar );
SCR_fn_v_SvL0_SaveParameters_MP( _p_stFile, SCR_EF_SvL0_Scanf, 2, "%d", m_pub_fn_lGetEnvironmentMask() );
// linked generator data
CPA_PartGen_Generator *p_oPrtGen = m_pub_fn_p_oGetLinkedPrtGen();
if (p_oPrtGen != NULL)
{
// linked generator mask
SCR_M_SvL0_SaveEntry( _p_stFile, C_EntryPrtGenLinkedPrtGenMask, SCR_CC_C_Cfg_NoChar );
SCR_fn_v_SvL0_SaveParameters_MP( _p_stFile, SCR_EF_SvL0_Scanf, 2, "%d", fn_lPrtGenGetEnvironmentMask( m_pri_hGenerator ) );
// linked generator reference
SCR_M_SvL0_SaveEntry( _p_stFile, C_EntryPrtGenLinkedPrtGen, SCR_CC_C_Cfg_NoChar );
SCR_fn_v_SvL0_SaveParameters_MP( _p_stFile, SCR_EF_SvL0_Scanf, 1, M_MAKECHAR( p_oPrtGen->GetReferencedSectionName() ) );
}
}
void CPA_PartGen_Generator::m_pri_fn_vFillDataList()
{
m_pri_fn_vFillGeneratorDataList();
}
void CPA_PartGen_Generator::m_pri_fn_vFillGeneratorDataList()
{
CTL_Editor_Data *p_clData = NULL;
CTL_Editor_EnumDescriptor *p_clEnumDescriptor = NULL;
CTL_Editor_MaskDescriptor *p_clMaskDescriptor = NULL;
//*** Associated Source **************************
p_clEnumDescriptor = m_pub_fn_p_clGetDocument()->m_pub_fn_p_clGetEnumDescriptorByName( "Generator_Source" );
p_clData = m_pub_clGeneratorDataList.m_fn_pclAddEnumData( p_clEnumDescriptor, "Source" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_hGenerator->p_stPrtSrc) );
p_clData->m_pub_fn_vSetModificationFunctionWhenWrite( g_fn_vModificationWriteGeneratorSource );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedGenerator" );
p_clData->m_pub_fn_vSetDataChangedSpecialCallBackFunction( g_fn_vCallBackDataChangedSpecialDisplayAll );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( g_fn_vCallBackDataChangedGenerator );
//*** Associated System **************************
p_clEnumDescriptor = m_pub_fn_p_clGetDocument()->m_pub_fn_p_clGetEnumDescriptorByName( "Generator_System" );
p_clData = m_pub_clGeneratorDataList.m_fn_pclAddEnumData( p_clEnumDescriptor, "System" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_hGenerator->p_stPrtSys) );
p_clData->m_pub_fn_vSetModificationFunctionWhenWrite( g_fn_vModificationWriteGeneratorSystem );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedGenerator" );
p_clData->m_pub_fn_vSetDataChangedSpecialCallBackFunction( g_fn_vCallBackDataChangedSpecialDisplayAll );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( g_fn_vCallBackDataChangedGenerator );
//*** Associated environment *********************
p_clEnumDescriptor = m_pub_fn_p_clGetDocument()->m_pub_fn_p_clGetEnumDescriptorByName( "Generator_Env" );
p_clData = m_pub_clGeneratorDataList.m_fn_pclAddEnumData( p_clEnumDescriptor, "Environment" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_hGenerator->p_stPrtEnv) );
p_clData->m_pub_fn_vSetModificationFunctionWhenWrite( g_fn_vModificationWriteGeneratorEnvironment );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedGenerator" );
p_clData->m_pub_fn_vSetDataChangedSpecialCallBackFunction( g_fn_vCallBackDataChangedSpecialDisplayAll );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( g_fn_vCallBackDataChangedGenerator );
//*** Environment Mask ************************
p_clMaskDescriptor = m_pub_fn_p_clGetDocument()->m_pub_fn_p_clGetMaskDescriptorByName( "Generator_Mask_Env" );
p_clData = m_pub_clGeneratorDataList.m_fn_pclAddMaskedData( p_clMaskDescriptor, "Environment Mask" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_hGenerator->lEnvironmentMask) );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedGenerator" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( g_fn_vCallBackDataChangedGenerator );
//*** Link To Environment ************************
p_clData = m_pub_clGeneratorDataList.m_fn_pclAddBooleanData( "Link To Environment" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_hGenerator->ucLinkedToEnvironment) );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedGenerator" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( g_fn_vCallBackDataChangedGenerator );
//*** Linked generator mask ************************
p_clMaskDescriptor = m_pub_fn_p_clGetDocument()->m_pub_fn_p_clGetMaskDescriptorByName( "Generator_Mask_LinkedGen" );
p_clData = m_pub_clGeneratorDataList.m_fn_pclAddMaskedData( p_clMaskDescriptor, "Linked Generator Mask" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_hGenerator->ulLinkedPrtGenMask) );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedGenerator" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( g_fn_vCallBackDataChangedGenerator );
//*** linked generator **************************
p_clEnumDescriptor = m_pub_fn_p_clGetDocument()->m_pub_fn_p_clGetEnumDescriptorByName( "Generator_LinkedGenerator" );
p_clData = m_pub_clGeneratorDataList.m_fn_pclAddEnumData( p_clEnumDescriptor, "Linked Generator" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_hGenerator->p_stLinkedPrtGen) );
p_clData->m_pub_fn_vSetModificationFunctionWhenWrite( g_fn_vModificationWriteGeneratorLinkedGenerator );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedGenerator" );
p_clData->m_pub_fn_vSetDataChangedSpecialCallBackFunction( g_fn_vCallBackDataChangedSpecialDisplayAll );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( g_fn_vCallBackDataChangedGenerator );
}
CPA_PartGen_MyDocument * CPA_PartGen_Generator::m_pub_fn_p_clGetDocument()
{
return g_pclInterface->m_pub_fn_p_clGetDocument();
}

View File

@@ -0,0 +1,805 @@
/*
=======================================================================================
Name : TPG_OSrc.cpp
Author : vincent lhullier Date :20/03/98
Description : implementation of editor ParticleSource object class
=======================================================================================
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "StdAfx.h"
#include "TPG_OSys.hpp"
#include "_Minterf.hpp"
#include "TPG_Strg.hpp"
#include "TPG_ClBk.hpp"
#include "PRT.h"
#include "GAM.h"
#include "MTH.h"
#include "ErO.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
//////////////////////////////////////
// Constructor and Destructor
//////////////////////////////////////
CPA_PartGen_Source::CPA_PartGen_Source(CString _csName ) : CPA_SaveObject( g_pclInterface, g_C_csPartGenSourceName, E_ss_Responsible )
{
SetSectionData( this );
SetCallBackSave( m_s_fn_vCallBackSaveSource );
SetDataPath( C_szEffectPath );
if ( fn_eRename(_csName) != E_mc_None )
SetDefaultValidName();
fn_vUpdateSectionName();
SetExistingSection( FALSE );
PRT_fn_vCreateParticlesSource( &m_pri_p_stPrtSrc );
fn_vUpdateData( (void*) m_pri_p_stPrtSrc );
//m_pri_hGameMaterial = NULL;
//m_pri_hSprite = NULL;
m_pri_fn_vFillDataList();
}
CPA_PartGen_Source::CPA_PartGen_Source(CString _csName, PRT_tdstParticlesSource* _p_stPrtSrc, BOOL _bIsLoaded ) : CPA_SaveObject( g_pclInterface, g_C_csPartGenSourceName, E_ss_Responsible )
{
SetSectionData( this );
SetCallBackSave( m_s_fn_vCallBackSaveSource );
SetDataPath( C_szEffectPath );
if ( fn_eRename(_csName) != E_mc_None )
SetDefaultValidName();
fn_vUpdateSectionName();
SetExistingSection( TRUE );
SetAvailable( _bIsLoaded );
fn_vUpdateData( (void*) _p_stPrtSrc );
m_pri_p_stPrtSrc = _p_stPrtSrc;
//m_pri_hGameMaterial = NULL;
//m_pri_hSprite = NULL;
if( _bIsLoaded )
{
//m_pri_fn_vSetInternalParticle();
m_pri_fn_vFillDataList();
}
}
CPA_PartGen_Source::~CPA_PartGen_Source()
{
fn_vNotifyUnSave();
}
void CPA_PartGen_Source::m_pub_fn_vSetSource( PRT_tdstParticlesSource *_p_stPrtSrc )
{
fn_vUpdateData( (void*)_p_stPrtSrc );
m_pri_p_stPrtSrc = _p_stPrtSrc;
SetAvailable( TRUE );
//m_pri_fn_vSetInternalParticle();
m_pri_fn_vFillDataList();
}
////////////////////////////////////
// Virtual functions
long CPA_PartGen_Source::GetDataType( void )
{
return( 0 );
}
void* CPA_PartGen_Source::GetData( void )
{
return (void*) m_pri_p_stPrtSrc;
}
CString CPA_PartGen_Source::fn_csComputeReferencedSectionName(const CString _csNewName)
{
CString csResult = "generators.prt^";
csResult += C_SectionParticleSource;
csResult += ":";
return( csResult + _csNewName );
}
//*************************************************
// Load if necessary
BOOL CPA_PartGen_Source::m_pub_fn_vLoadIfUnloaded()
{
if ( !fn_bIsAvailable() )
{
SCR_tdst_Cxt_Values *p_stValues;
p_stValues = SCR_fnp_st_RdL0_AnalyseSection((char *)LPCTSTR(GetReferencedSectionName()), SCR_CDF_uw_Anl_Normal);
m_pri_p_stPrtSrc = (PRT_tdstParticlesSource *) p_stValues->a_ulValues[0];
fn_vUpdateData( (void*) m_pri_p_stPrtSrc );
SetAvailable(TRUE);
//m_pri_fn_vSetInternalParticle();
m_pri_fn_vFillDataList();
return TRUE;
}
return FALSE;
}
///////////////////////////
// Source via Generator
///////////////////////////
/*
CString CPA_PartGen_Source::m_pri_fn_csGetSourceReferencedSectionName()
{
CString csResult = "Generators.prt^";
csResult += C_SectionParticleSource;
csResult += ":";
csResult += GetName();
return (csResult + "Source");
}
*/
///////////////////////////////////////////////////////
// Generation Mode and parameters
void CPA_PartGen_Source::m_pub_fn_vSetGenerationMode( short _wIndex )
{
PRT_M_vSetGenerationModeParticlesSource( m_pri_p_stPrtSrc, (unsigned char)_wIndex );
fn_vNotifySave();
}
long CPA_PartGen_Source::m_pub_fn_lGetGenerationMode()
{
return (long) m_pri_p_stPrtSrc->ucGenerationMode;
}
/*
void CPA_PartGen_Source::m_pub_fn_vSetGenerationProba( double _dValue )
{
PRT_M_vSetGenerationProbabilityParticlesSource( m_pri_p_stPrtSrc, MTH_M_xDoubleToReal(_dValue) );
fn_vNotifySave();
}
*/
double CPA_PartGen_Source::m_pub_fn_dGetGenerationProba()
{
return MTH_M_xRealToDouble( m_pri_p_stPrtSrc->xGenerationProbability );
}
/*
void CPA_PartGen_Source::m_pub_fn_vSetNbNoGeneration( long _lValue )
{
ACP_tdxIndex xNbGeneration = m_pri_p_stPrtSrc->xNbFramesTotal - m_pri_p_stPrtSrc->xNbFramesNoGeneration;
PRT_M_vSetNbFramesCrenelParticlesSource( m_pri_p_stPrtSrc, (ACP_tdxIndex)_lValue, xNbGeneration );
fn_vNotifySave();
}
*/
long CPA_PartGen_Source::m_pub_fn_lGetNbNoGeneration()
{
return (long) m_pri_p_stPrtSrc->xNbFramesNoGeneration;
}
/*
void CPA_PartGen_Source::m_pub_fn_vSetNbGeneration( long _lValue )
{
ACP_tdxIndex xNbNoGeneration = m_pri_p_stPrtSrc->xNbFramesNoGeneration;
PRT_M_vSetNbFramesCrenelParticlesSource( m_pri_p_stPrtSrc, xNbNoGeneration, (ACP_tdxIndex)_lValue );
fn_vNotifySave();
}
*/
long CPA_PartGen_Source::m_pub_fn_lGetNbGeneration()
{
return (long)(m_pri_p_stPrtSrc->xNbFramesTotal - m_pri_p_stPrtSrc->xNbFramesNoGeneration);
}
///////////////////////////////////////////////////////
// Nb Particles to Generate Mode and parameters
void CPA_PartGen_Source::m_pub_fn_vSetNbGenerateMode( short _wIndex )
{
PRT_M_vSetNbParticlesToGenerateModeParticlesSource( m_pri_p_stPrtSrc, (unsigned char)_wIndex );
fn_vNotifySave();
}
long CPA_PartGen_Source::m_pub_fn_lGetNbGenerateMode()
{
return (long) m_pri_p_stPrtSrc->ucNbParticlesToGenerateMode;
}
/*void CPA_PartGen_Source::m_pub_fn_vSetNbToGenerate( long _lValue )
{
PRT_M_vSetNbParticlesToGenerateParticlesSource( m_pri_p_stPrtSrc, (ACP_tdxIndex)_lValue );
fn_vNotifySave();
}*/
long CPA_PartGen_Source::m_pub_fn_lGetNbToGenerate()
{
return (long)(m_pri_p_stPrtSrc->xNbParticlesToGenerate);
}
/*void CPA_PartGen_Source::m_pub_fn_vSetNbMax( long _lValue )
{
ACP_tdxIndex xMin = m_pri_p_stPrtSrc->xNbMin;
PRT_M_vSetNbMinMaxParticlesSource( m_pri_p_stPrtSrc, xMin, (ACP_tdxIndex)_lValue );
fn_vNotifySave();
}*/
long CPA_PartGen_Source::m_pub_fn_lGetNbMax()
{
return (long)(m_pri_p_stPrtSrc->xNbMax);
}
/*void CPA_PartGen_Source::m_pub_fn_vSetNbMin( long _lValue )
{
ACP_tdxIndex xMax = m_pri_p_stPrtSrc->xNbMax;
PRT_M_vSetNbMinMaxParticlesSource( m_pri_p_stPrtSrc, (ACP_tdxIndex)_lValue, xMax );
fn_vNotifySave();
}*/
long CPA_PartGen_Source::m_pub_fn_lGetNbMin()
{
return (long)(m_pri_p_stPrtSrc->xNbMin);
}
/////////////////////////////////////////////////////
// Geometry Mode and parameters
void CPA_PartGen_Source::m_pub_fn_vSetGeometryMode( short _wIndex )
{
PRT_M_vSetGeometryModeParticlesSource( m_pri_p_stPrtSrc, (unsigned char)_wIndex );
fn_vNotifySave();
}
long CPA_PartGen_Source::m_pub_fn_lGetGeometryMode()
{
return (long)m_pri_p_stPrtSrc->ucGeometryMode;
}
/*void CPA_PartGen_Source::m_pub_fn_vSetSrcPt1( double _dX, double _dY, double _dZ )
{
MTH3D_tdstVector stVector;
MTH3D_M_vSetVectorElements( &stVector, MTH_M_xDoubleToReal(_dX), MTH_M_xDoubleToReal(_dY), MTH_M_xDoubleToReal(_dZ) );
PRT_fn_vSetQuadParticlesSource
(
m_pri_p_stPrtSrc,
&stVector,
&(m_pri_p_stPrtSrc->stVertex2),
&(m_pri_p_stPrtSrc->stVertex3)
);
fn_vNotifySave();
}*/
double CPA_PartGen_Source::m_pub_fn_dGetSrcPt1X()
{
return MTH_M_xRealToDouble( MTH3D_M_xGetXofVector( &((m_pri_p_stPrtSrc)->stVertex1 )) );
}
double CPA_PartGen_Source::m_pub_fn_dGetSrcPt1Y()
{
return MTH_M_xRealToDouble( MTH3D_M_xGetYofVector( &((m_pri_p_stPrtSrc)->stVertex1 )) );
}
double CPA_PartGen_Source::m_pub_fn_dGetSrcPt1Z()
{
return MTH_M_xRealToDouble( MTH3D_M_xGetZofVector( &((m_pri_p_stPrtSrc)->stVertex1 )) );
}
/*void CPA_PartGen_Source::m_pub_fn_vSetSrcPt2( double _dX, double _dY, double _dZ )
{
MTH3D_tdstVector stVector;
MTH3D_M_vSetVectorElements( &stVector, MTH_M_xDoubleToReal(_dX), MTH_M_xDoubleToReal(_dY), MTH_M_xDoubleToReal(_dZ) );
PRT_fn_vSetQuadParticlesSource
(
m_pri_p_stPrtSrc,
&(m_pri_p_stPrtSrc->stVertex1),
&stVector,
&(m_pri_p_stPrtSrc->stVertex3)
);
fn_vNotifySave();
}*/
double CPA_PartGen_Source::m_pub_fn_dGetSrcPt2X()
{
return MTH_M_xRealToDouble( MTH3D_M_xGetXofVector( &((m_pri_p_stPrtSrc)->stVertex2 )) );
}
double CPA_PartGen_Source::m_pub_fn_dGetSrcPt2Y()
{
return MTH_M_xRealToDouble( MTH3D_M_xGetYofVector( &((m_pri_p_stPrtSrc)->stVertex2 )) );
}
double CPA_PartGen_Source::m_pub_fn_dGetSrcPt2Z()
{
return MTH_M_xRealToDouble( MTH3D_M_xGetZofVector( &((m_pri_p_stPrtSrc)->stVertex2 )) );
}
/*void CPA_PartGen_Source::m_pub_fn_vSetSrcPt3( double _dX, double _dY, double _dZ )
{
MTH3D_tdstVector stVector;
MTH3D_M_vSetVectorElements( &stVector, MTH_M_xDoubleToReal(_dX), MTH_M_xDoubleToReal(_dY), MTH_M_xDoubleToReal(_dZ) );
PRT_fn_vSetQuadParticlesSource
(
m_pri_p_stPrtSrc,
&(m_pri_p_stPrtSrc->stVertex1),
&(m_pri_p_stPrtSrc->stVertex2),
&stVector
);
fn_vNotifySave();
}*/
double CPA_PartGen_Source::m_pub_fn_dGetSrcPt3X()
{
return MTH_M_xRealToDouble( MTH3D_M_xGetXofVector( &((m_pri_p_stPrtSrc)->stVertex3 )) );
}
double CPA_PartGen_Source::m_pub_fn_dGetSrcPt3Y()
{
return MTH_M_xRealToDouble( MTH3D_M_xGetYofVector( &((m_pri_p_stPrtSrc)->stVertex3 )) );
}
double CPA_PartGen_Source::m_pub_fn_dGetSrcPt3Z()
{
return MTH_M_xRealToDouble( MTH3D_M_xGetZofVector( &((m_pri_p_stPrtSrc)->stVertex3 )) );
}
/////////////////////////////////////////////////
// Link Mode
void CPA_PartGen_Source::m_pub_fn_vSetLinkMode( short _wIndex )
{
PRT_M_vSetLinkModeParticlesSource( m_pri_p_stPrtSrc, (unsigned char)_wIndex );
fn_vNotifySave();
}
long CPA_PartGen_Source::m_pub_fn_lGetLinkMode()
{
return (long)m_pri_p_stPrtSrc->ucLinkMode;
}
//////////////////////////////////////////////
// Speed and Range
void CPA_PartGen_Source::m_pub_fn_vSetSpeed( double _dSpeed )
{
PRT_M_vSetSpeedParticlesSource( m_pri_p_stPrtSrc, MTH_M_xDoubleToReal(_dSpeed) );
fn_vNotifySave();
}
double CPA_PartGen_Source::m_pub_fn_dGetSpeed()
{
return MTH_M_xRealToDouble( m_pri_p_stPrtSrc->xSpeed );
}
void CPA_PartGen_Source::m_pub_fn_vSetSpeedRange( double _dSpeedRange )
{
PRT_M_vSetSpeedRangeParticlesSource( m_pri_p_stPrtSrc, MTH_M_xDoubleToReal(_dSpeedRange) );
fn_vNotifySave();
}
double CPA_PartGen_Source::m_pub_fn_dGetSpeedRange()
{
return MTH_M_xRealToDouble( m_pri_p_stPrtSrc->xSpeedRange );
}
/////////////////////////////////////////////////
// Point, Segment and Sprite
/*
long CPA_PartGen_Source::m_pub_fn_lGetParticlesType()
{
return (long)m_pri_p_stSystem->xParticlesType;
}
void CPA_PartGen_Source::m_pub_fn_vSetObjectPoint( GMT_tdxHandleToGameMaterial _hGameMaterial )
{
PRT_fn_vCreatePointParticles( m_pri_p_stSystem, _hGameMaterial );
}
GMT_tdxHandleToGameMaterial CPA_PartGen_Source::m_pub_fn_hGetPointGameMaterial()
{
return GEO_xGetGameMaterialOfElementPoints(m_pri_p_stSystem->hParticlesSystemObject,0);
}
void CPA_PartGen_Source::m_pub_fn_vSetObjectSegment( GMT_tdxHandleToGameMaterial _hGameMaterial )
{
PRT_fn_vCreateSegmentParticles( m_pri_p_stSystem, _hGameMaterial );
//fn_vNotifySave();
}
GMT_tdxHandleToGameMaterial CPA_PartGen_Source::m_pub_fn_hGetSegmentGameMaterial()
{
GMT_tdxHandleToGameMaterial hGameMaterial;
GEO_xGetGameMaterialOfElementLines(m_pri_p_stSystem->hParticlesSystemObject,0, 0, &hGameMaterial);
return hGameMaterial;
}
void CPA_PartGen_Source::m_pub_fn_vSetObjectSprite( ACP_tdxHandleOfSprite _hSprite )
{
PRT_fn_vCreateSpriteParticles( m_pri_p_stSystem, _hSprite );
//fn_vNotifySave();
}
ACP_tdxHandleOfSprite CPA_PartGen_Source::m_pub_fn_hGetSprite()
{
ACP_tdxHandleOfSprite hSprite;
GEO_vGetHandleOfIndexedSprite(m_pri_p_stSystem->hParticlesSystemObject, 0, 0, &hSprite );
return hSprite;
}
*/
/*
void CPA_PartGen_Source::m_pri_fn_vSetInternalParticle()
{
ACP_tdxIndex xType = m_pri_p_stSystem->xParticlesType;
switch( xType )
{
case PRT_C_xPointParticles:
m_pri_hGameMaterial = GEO_xGetGameMaterialOfElementPoints(m_pri_p_stSystem->hParticlesSystemObject,0);
break;
case PRT_C_xSegmentParticles:
GEO_xGetGameMaterialOfElementLines(m_pri_p_stSystem->hParticlesSystemObject,0, 0, &m_pri_hGameMaterial);
break;
case PRT_C_xSpriteParticles:
GEO_vGetHandleOfIndexedSprite(m_pri_p_stSystem->hParticlesSystemObject, 0, 0, &m_pri_hSprite );
break;
}
}
*/
//****************************************************
// Gets name of the associated object using link table
/*CString CPA_PartGen_Source::m_pub_fn_csGetObjectName()
{
CString csObjectName = "";
SCR_tdst_Link_Table *p_stLinkTable = NULL;
SCR_tdst_Link_Value *p_stValue = NULL;
unsigned long ulValue = 0;
long lIndex = m_pub_fn_lGetParticlesType();
switch( lIndex )
{
case PRT_C_xPointParticles:
p_stLinkTable = GMT_fn_p_stGetLinkTable();
ulValue = (unsigned long)m_pub_fn_hGetPointGameMaterial();
break;
case PRT_C_xSegmentParticles:
p_stLinkTable = GMT_fn_p_stGetLinkTable();
ulValue = (unsigned long)m_pub_fn_hGetSegmentGameMaterial();
break;
case PRT_C_xSpriteParticles:
p_stLinkTable = GLI_p_stGetLinkTableOfSprite();
ulValue = (unsigned long)m_pub_fn_hGetSprite();
break;
}
//*** finds the entry *****
if( p_stLinkTable != NULL )
p_stValue = SCR_fnp_st_Link_SearchValue( p_stLinkTable, ulValue );
//*** gets the name of the entry ******************************************************
if( p_stValue != NULL && SCR_M_e_Link_GetState(p_stValue) == SCR_ELS_Link_Initialized )
{
csObjectName = SCR_M_p_sz_Link_GetKey(p_stValue);
char a_256cFileName[256];
char a_256cActionName[256];
char a_256cName[256];
SCR_fn_v_RdL0_SplitSectionName((char *)LPCTSTR(csObjectName), a_256cFileName, a_256cActionName, a_256cName);
csObjectName = a_256cName;
}
return csObjectName;
}
*/
/////////////////////////////////////////////////
// Nb particles
/*long CPA_PartGen_Source::m_pub_fn_lGetNbParticles()
{
return (long)m_pri_p_stSystem->xNbParticles;
}
*/
///////////////////////////////////////////////////
// CallBack and Function for save
void CPA_PartGen_Source::m_s_fn_vCallBackSaveSource( SCR_tdst_File_Description *_p_stFile, char *_p_szSectionName, void *_p_vData, SCR_tde_Ntfy_Action _eAction )
{
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"Saving a generator",
"CPA_PartGen_Source::m_s_fn_vCallBackSaveSystem",
E_ERROR_GRAVITY_FATAL,
"trying to save a NULL system"
);
CPA_PartGen_Source *p_oPrtSrc = (CPA_PartGen_Source*) _p_vData;
CString csHeaderName = C_SectionParticleSource;
switch( _eAction )
{
case SCR_EA_Ntfy_AddSection:
case SCR_EA_Ntfy_AddOrModifySection:
case SCR_EA_Ntfy_AddOrRebuildSection:
case SCR_EA_Ntfy_RebuildSection:
case SCR_EA_Ntfy_ModifySection:
csHeaderName += ":";
csHeaderName += p_oPrtSrc->GetName();
SCR_M_SvL0_SaveBeginSection( _p_stFile, M_MAKECHAR(csHeaderName), SCR_CC_C_Cfg_EOL );
p_oPrtSrc->m_pri_fn_vSaveSource( _p_stFile );
SCR_M_SvL0_SaveEndSection( _p_stFile, SCR_CC_C_Cfg_EOL );
p_oPrtSrc->fn_vSectionSaved();
break;
case SCR_EA_Ntfy_DeleteIfExists:
case SCR_EA_Ntfy_DeleteSection:
p_oPrtSrc->fn_vSectionDeleted();
break;
}
}
void CPA_PartGen_Source::m_pri_fn_vSaveSource( SCR_tdst_File_Description *_p_stFile )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lIndex;
CTL_Editor_EnumElement *p_clEnumElement;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
// generation mode and its optional parameters
lIndex = m_pub_fn_lGetGenerationMode();
p_clEnumElement = m_pub_fn_p_clGetDocument()->m_pub_fn_p_clGetEnumDescriptorByName( "Source_GenerationMode" )->m_fn_pclGetElementFromEnumIndex( lIndex );
SCR_M_SvL0_SaveEntry( _p_stFile, C_EntryPrtSrcGenerationMode, SCR_CC_C_Cfg_NoChar );
SCR_fn_v_SvL0_SaveParameters_MP( _p_stFile, SCR_EF_SvL0_Scanf, 1, M_MAKECHAR(p_clEnumElement->m_pub_fn_csGetAdditionalString()) );
switch( lIndex )
{
case PRT_C_ucProbabilistGeneration:
SCR_M_SvL0_SaveEntry( _p_stFile, C_EntryPrtSrcGenerationProbability, SCR_CC_C_Cfg_NoChar );
SCR_fn_v_SvL0_SaveParameters_MP( _p_stFile, SCR_EF_SvL0_Scanf, 2, "%.3f", m_pub_fn_dGetGenerationProba() );
break;
case PRT_C_ucCrenelGeneration:
SCR_M_SvL0_SaveEntry( _p_stFile, C_EntryPrtSrcCrenelGeneration, SCR_CC_C_Cfg_NoChar );
SCR_fn_v_SvL0_SaveParameters_MP( _p_stFile, SCR_EF_SvL0_Scanf, 3, "%d,%d", m_pub_fn_lGetNbNoGeneration(), m_pub_fn_lGetNbGeneration() );
break;
}
// nb particles to generate mode
lIndex = m_pub_fn_lGetNbGenerateMode();
p_clEnumElement = m_pub_fn_p_clGetDocument()->m_pub_fn_p_clGetEnumDescriptorByName( "Source_NbParticlesMode" )->m_fn_pclGetElementFromEnumIndex( lIndex );
SCR_M_SvL0_SaveEntry( _p_stFile, C_EntryPrtSrcNbParticlesToGenerateMode, SCR_CC_C_Cfg_NoChar );
SCR_fn_v_SvL0_SaveParameters_MP( _p_stFile, SCR_EF_SvL0_Scanf, 1, M_MAKECHAR(p_clEnumElement->m_pub_fn_csGetAdditionalString()) );
switch( lIndex )
{
case PRT_C_ucConstantNb:
SCR_M_SvL0_SaveEntry( _p_stFile, C_EntryPrtSrcNbParticlesToGenerate, SCR_CC_C_Cfg_NoChar );
SCR_fn_v_SvL0_SaveParameters_MP( _p_stFile, SCR_EF_SvL0_Scanf, 2, "%d", m_pub_fn_lGetNbToGenerate() );
break;
case PRT_C_ucProbabilistNb:
SCR_M_SvL0_SaveEntry( _p_stFile, C_EntryPrtSrcNbMinMax, SCR_CC_C_Cfg_NoChar );
SCR_fn_v_SvL0_SaveParameters_MP( _p_stFile, SCR_EF_SvL0_Scanf, 3, "%d,%d", m_pub_fn_lGetNbMin(), m_pub_fn_lGetNbMax() );
break;
}
// generation source geometry mode
lIndex = m_pub_fn_lGetGeometryMode();
p_clEnumElement = m_pub_fn_p_clGetDocument()->m_pub_fn_p_clGetEnumDescriptorByName( "Source_GeometryMode" )->m_fn_pclGetElementFromEnumIndex( lIndex );
SCR_M_SvL0_SaveEntry( _p_stFile, C_EntryPrtSrcGeometryMode, SCR_CC_C_Cfg_NoChar );
SCR_fn_v_SvL0_SaveParameters_MP( _p_stFile, SCR_EF_SvL0_Scanf, 1, M_MAKECHAR(p_clEnumElement->m_pub_fn_csGetAdditionalString()) );
switch( lIndex )
{
case PRT_C_ucQuad:
SCR_M_SvL0_SaveEntry( _p_stFile, C_EntryPrtSrcQuad, SCR_CC_C_Cfg_NoChar );
SCR_fn_v_SvL0_SaveParameters_MP
(
_p_stFile, SCR_EF_SvL0_Scanf, 10, "%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f",
m_pub_fn_dGetSrcPt1X(), m_pub_fn_dGetSrcPt1Y(), m_pub_fn_dGetSrcPt1Z(),
m_pub_fn_dGetSrcPt2X(), m_pub_fn_dGetSrcPt2Y(), m_pub_fn_dGetSrcPt2Z(),
m_pub_fn_dGetSrcPt3X(), m_pub_fn_dGetSrcPt3Y(), m_pub_fn_dGetSrcPt3Z()
);
break;
case PRT_C_ucPoint:
SCR_M_SvL0_SaveEntry( _p_stFile, C_EntryPrtSrcPoint, SCR_CC_C_Cfg_NoChar );
SCR_fn_v_SvL0_SaveParameters_MP
(
_p_stFile, SCR_EF_SvL0_Scanf, 4, "%.3f,%.3f,%.3f",
m_pub_fn_dGetSrcPt1X(), m_pub_fn_dGetSrcPt1Y(), m_pub_fn_dGetSrcPt1Z()
);
break;
}
// link mode
lIndex = m_pub_fn_lGetLinkMode();
p_clEnumElement = m_pub_fn_p_clGetDocument()->m_pub_fn_p_clGetEnumDescriptorByName( "Source_LinkMode" )->m_fn_pclGetElementFromEnumIndex( lIndex );
SCR_M_SvL0_SaveEntry( _p_stFile, C_EntryPrtSrcLinkMode, SCR_CC_C_Cfg_NoChar );
SCR_fn_v_SvL0_SaveParameters_MP( _p_stFile, SCR_EF_SvL0_Scanf, 1, M_MAKECHAR(p_clEnumElement->m_pub_fn_csGetAdditionalString()) );
// speed and speed range
SCR_M_SvL0_SaveEntry( _p_stFile, C_EntryPrtSrcSpeedAndRange, SCR_CC_C_Cfg_NoChar );
SCR_fn_v_SvL0_SaveParameters_MP( _p_stFile, SCR_EF_SvL0_Scanf, 3, "%.3f,%.3f", m_pub_fn_dGetSpeed(), m_pub_fn_dGetSpeedRange() );
// life mode
lIndex = (long) m_pri_p_stPrtSrc->ucLifeMode;
switch (m_pri_p_stPrtSrc->ucLifeMode)
{
case PRT_C_ucNoLifeTime:
SCR_M_SvL0_SaveEntry( _p_stFile, C_EntryPrtSrcNoLifeTime, SCR_CC_C_Cfg_EOL );
break;
case PRT_C_ucConstantLifeTime:
SCR_M_SvL0_SaveEntry( _p_stFile, C_EntryPrtSrcConstantLifeTime, SCR_CC_C_Cfg_NoChar );
SCR_fn_v_SvL0_SaveParameters_MP( _p_stFile, SCR_EF_SvL0_Scanf, 2, "%.3f", m_pri_p_stPrtSrc->xMinTime );
break;
case PRT_C_ucProbabilistLifeTime:
SCR_M_SvL0_SaveEntry( _p_stFile, C_EntryPrtSrcProbabilistLifeTime, SCR_CC_C_Cfg_NoChar );
SCR_fn_v_SvL0_SaveParameters_MP( _p_stFile, SCR_EF_SvL0_Scanf, 3, "%.3f, %.3f", m_pri_p_stPrtSrc->xMinTime, m_pri_p_stPrtSrc->xMaxTime );
break;
}
}
void CPA_PartGen_Source::m_pri_fn_vFillDataList()
{
CTL_Editor_Data *p_clData = NULL;
CTL_Editor_EnumDescriptor *p_clEnumDescriptor = NULL;
//*** Generation Mode ***********************
p_clEnumDescriptor = m_pub_fn_p_clGetDocument()->m_pub_fn_p_clGetEnumDescriptorByName( "Source_GenerationMode" );
p_clData = m_pub_clDataList.m_fn_pclAddEnumData( p_clEnumDescriptor, "Generation Mode" );
p_clData->m_fn_vSetMotorDataPtr( (void*) &m_pri_p_stPrtSrc->ucGenerationMode );
p_clData->m_pub_fn_vSetDataChangedSpecialCallBackFunction( g_fn_vCallBackDataChangedSpecialDisplayGenerator );
p_clData->m_pub_fn_pclAddOwnerData( (void*) this, "EditedSource" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( fn_vCBPrtSrcDataChanged );
//****** Probability *****************************
p_clData = m_pub_clDataList.m_fn_pclAddDecimalData( sizeof(MTH_tdxReal), "Probability" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_p_stPrtSrc->xGenerationProbability) );
p_clData->m_pub_fn_pclAddOwnerData( (void*)&(m_pri_p_stPrtSrc->ucGenerationMode), "GenerationMode" );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedSource" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( fn_vCBPrtSrcDataChanged );
//****** Nb Frames No generation ********************
p_clData = m_pub_clDataList.m_fn_pclAddIntegerData( sizeof(ACP_tdxIndex), TPG_UNSIGNED, "Nb Frames No Generation" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_p_stPrtSrc->xNbFramesNoGeneration) );
p_clData->m_pub_fn_pclAddOwnerData( (void*) m_pri_p_stPrtSrc, "PrtSrc" );
p_clData->m_pub_fn_pclAddOwnerData( (void*) &(m_pri_p_stPrtSrc->ucGenerationMode), "GenerationMode" );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedSource" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( fn_vCBPrtSrcDataChanged );
//****** Nb Frames generation *****************
p_clData = m_pub_clDataList.m_fn_pclAddIntegerData( sizeof(ACP_tdxIndex), TPG_UNSIGNED, "Nb Frames Generation" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_p_stPrtSrc->xNbFramesTotal) );
p_clData->m_pub_fn_pclAddOwnerData( (void*) &m_pri_p_stPrtSrc->ucGenerationMode, "GenerationMode" );
p_clData->m_pub_fn_pclAddOwnerData( (void*) &m_pri_p_stPrtSrc->xNbFramesNoGeneration, "NbFramesNoGeneration" );
p_clData->m_pub_fn_pclAddOwnerData( (void*) m_pri_p_stPrtSrc, "PrtSrc" );
p_clData->m_pub_fn_pclAddOwnerData( (void*) this, "EditedSource" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( fn_vCBPrtSrcDataChanged );
p_clData->m_pub_fn_vSetModificationFunctionWhenRead( g_fn_vModificationReadSourceNbFramesGeneration );
p_clData->m_pub_fn_vSetModificationFunctionWhenWrite( g_fn_vModificationWriteSourceNbFramesGeneration );
//*** Nb particles to generate mode ********************
p_clEnumDescriptor = m_pub_fn_p_clGetDocument()->m_pub_fn_p_clGetEnumDescriptorByName( "Source_NbParticlesMode" );
p_clData = m_pub_clDataList.m_fn_pclAddEnumData( p_clEnumDescriptor, "Nb Particles to Generate Mode" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_p_stPrtSrc->ucNbParticlesToGenerateMode) );
p_clData->m_pub_fn_vSetDataChangedSpecialCallBackFunction( g_fn_vCallBackDataChangedSpecialDisplayGenerator );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedSource" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( fn_vCBPrtSrcDataChanged );
//****** Constant ********************************
p_clData = m_pub_clDataList.m_fn_pclAddIntegerData( sizeof(ACP_tdxIndex), TPG_UNSIGNED, "Nb Particles" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_p_stPrtSrc->xNbParticlesToGenerate) );
p_clData->m_pub_fn_pclAddOwnerData( (void*)&(m_pri_p_stPrtSrc->ucNbParticlesToGenerateMode), "NbParticlesMode" );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedSource" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( fn_vCBPrtSrcDataChanged );
//****** Probabilist *****************************
p_clData = m_pub_clDataList.m_fn_pclAddIntegerData( sizeof(ACP_tdxIndex), TPG_UNSIGNED, "Nb Particles min" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_p_stPrtSrc->xNbMin) );
p_clData->m_pub_fn_pclAddOwnerData( (void*)&(m_pri_p_stPrtSrc->ucNbParticlesToGenerateMode), "NbParticlesMode" );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedSource" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( fn_vCBPrtSrcDataChanged );
p_clData = m_pub_clDataList.m_fn_pclAddIntegerData( sizeof(ACP_tdxIndex), TPG_UNSIGNED, "Nb Particles max" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_p_stPrtSrc->xNbMax) );
p_clData->m_pub_fn_pclAddOwnerData( (void*)&(m_pri_p_stPrtSrc->ucNbParticlesToGenerateMode), "NbParticlesMode" );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedSource" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( fn_vCBPrtSrcDataChanged );
//*** Geometry mode ************************************
p_clEnumDescriptor = m_pub_fn_p_clGetDocument()->m_pub_fn_p_clGetEnumDescriptorByName( "Source_GeometryMode" );
p_clData = m_pub_clDataList.m_fn_pclAddEnumData( p_clEnumDescriptor, "Geometry Mode" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_p_stPrtSrc->ucGeometryMode) );
p_clData->m_pub_fn_vSetDataChangedSpecialCallBackFunction( g_fn_vCallBackDataChangedSpecialDisplayGenerator );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedSource" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( fn_vCBPrtSrcDataChanged );
//****** Point **********************************
p_clData = m_pub_clDataList.m_fn_pclAddVectorData( sizeof(MTH_tdxReal), "Point 1" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_p_stPrtSrc->stVertex1) );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedSource" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( fn_vCBPrtSrcDataChanged );
//****** Quad ***********************************
p_clData = m_pub_clDataList.m_fn_pclAddVectorData( sizeof(MTH_tdxReal), "Point 2" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_p_stPrtSrc->stVertex2) );
p_clData->m_pub_fn_pclAddOwnerData( (void*)&(m_pri_p_stPrtSrc->ucGeometryMode), "GeometryMode" );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedSource" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( fn_vCBPrtSrcDataChanged );
p_clData = m_pub_clDataList.m_fn_pclAddVectorData( sizeof(MTH_tdxReal), "Point 3" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_p_stPrtSrc->stVertex3) );
p_clData->m_pub_fn_pclAddOwnerData( (void*)&(m_pri_p_stPrtSrc->ucGeometryMode), "GeometryMode" );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedSource" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( fn_vCBPrtSrcDataChanged );
//*** Link Mode *********************************
p_clEnumDescriptor = m_pub_fn_p_clGetDocument()->m_pub_fn_p_clGetEnumDescriptorByName( "Source_LinkMode" );
p_clData = m_pub_clDataList.m_fn_pclAddEnumData( p_clEnumDescriptor, "Link Mode" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_p_stPrtSrc->ucLinkMode) );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedSource" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( fn_vCBPrtSrcDataChanged );
//*** Speed and Range ****************************
p_clData = m_pub_clDataList.m_fn_pclAddDecimalData( sizeof(MTH_tdxReal), "Speed" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_p_stPrtSrc->xSpeed) );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedSource" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( fn_vCBPrtSrcDataChanged );
p_clData = m_pub_clDataList.m_fn_pclAddDecimalData( sizeof(MTH_tdxReal), "Speed Range" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_p_stPrtSrc->xSpeedRange) );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedSource" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( fn_vCBPrtSrcDataChanged );
//*** Life Mode
p_clEnumDescriptor = m_pub_fn_p_clGetDocument()->m_pub_fn_p_clGetEnumDescriptorByName( "Source_LifeMode" );
p_clData = m_pub_clDataList.m_fn_pclAddEnumData( p_clEnumDescriptor, "Life Mode" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_p_stPrtSrc->ucLifeMode) );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedSource" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( fn_vCBPrtSrcDataChanged );
p_clData->m_pub_fn_vSetDataChangedSpecialCallBackFunction( g_fn_vCallBackDataChangedSpecialDisplayGenerator );
//*** data for constant life time
p_clData = m_pub_clDataList.m_fn_pclAddDecimalData( sizeof(MTH_tdxReal), "LifeTime" );
p_clData->m_fn_vSetMotorDataPtr ( (void*) &m_pri_p_stPrtSrc->xMinTime );
p_clData->m_pub_fn_pclAddOwnerData ( (void*) &m_pri_p_stPrtSrc->ucLifeMode, "LifeMode" );
p_clData->m_pub_fn_pclAddOwnerData ( (void*) this, "EditedSource" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( fn_vCBPrtSrcDataChanged );
//*** data for probabilist life time
p_clData = m_pub_clDataList.m_fn_pclAddDecimalData( sizeof(MTH_tdxReal), "Min Life Time" );
p_clData->m_fn_vSetMotorDataPtr ( (void*) &m_pri_p_stPrtSrc->xMinTime );
p_clData->m_pub_fn_pclAddOwnerData ( (void*) &m_pri_p_stPrtSrc->ucLifeMode, "LifeMode" );
p_clData->m_pub_fn_pclAddOwnerData ( (void*) this, "EditedSource" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( fn_vCBPrtSrcDataChanged );
p_clData = m_pub_clDataList.m_fn_pclAddDecimalData( sizeof(MTH_tdxReal), "Max Life Time" );
p_clData->m_fn_vSetMotorDataPtr ( (void*) &m_pri_p_stPrtSrc->xMaxTime );
p_clData->m_pub_fn_pclAddOwnerData ( (void*) &m_pri_p_stPrtSrc->ucLifeMode, "LifeMode" );
p_clData->m_pub_fn_pclAddOwnerData ( (void*) this, "EditedSource" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( fn_vCBPrtSrcDataChanged );
}
CPA_PartGen_MyDocument * CPA_PartGen_Source::m_pub_fn_p_clGetDocument()
{
return g_pclInterface->m_pub_fn_p_clGetDocument();
}

View File

@@ -0,0 +1,397 @@
#include "StdAfx.h"
#include "TPG_OSys.hpp"
#include "_Minterf.hpp"
#include "TPG_Strg.hpp"
#include "TPG_ClBk.hpp"
#include "PRT.h"
#include "GAM.h"
#include "MTH.h"
#include "ErO.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//////////////////////////////////////
// Constructor and Destructor
//////////////////////////////////////
CPA_PartGen_System::CPA_PartGen_System(CString _csName, long _lNbParticles ) : CPA_SaveObject( g_pclInterface, g_C_csPartGenSystemName, E_ss_Responsible )
{
SetSectionData( this );
SetCallBackSave( m_s_fn_vCallBackSaveSystem );
SetDataPath( C_szEffectPath );
if ( fn_eRename(_csName) != E_mc_None )
SetDefaultValidName();
fn_vUpdateSectionName();
SetExistingSection( FALSE );
PRT_tdstParticlesSystem* p_stSystem;
PRT_fn_vCreateParticlesSystem( &p_stSystem, (ACP_tdxIndex)_lNbParticles );
PRT_fn_vInitParticlesSystem( p_stSystem );
fn_vUpdateData( (void*)p_stSystem );
m_pri_p_stSystem = p_stSystem;
m_pri_hGameMaterial = NULL;
m_pri_hSprite = NULL;
m_pri_fn_vFillDataList();
}
CPA_PartGen_System::CPA_PartGen_System(CString _csName, PRT_tdstParticlesSystem* _p_stSystem, BOOL _bIsLoaded )
: CPA_SaveObject( g_pclInterface, g_C_csPartGenSystemName, E_ss_Responsible )
{
SetSectionData( this );
SetCallBackSave( m_s_fn_vCallBackSaveSystem );
SetDataPath( C_szEffectPath );
if ( fn_eRename(_csName) != E_mc_None )
SetDefaultValidName();
fn_vUpdateSectionName();
SetExistingSection( TRUE );
SetAvailable( _bIsLoaded );
fn_vUpdateData( (void*)_p_stSystem );
m_pri_p_stSystem = _p_stSystem;
m_pri_hGameMaterial = NULL;
m_pri_hSprite = NULL;
if( _bIsLoaded )
{
m_pri_fn_vSetInternalParticle();
m_pri_fn_vFillDataList();
}
}
CPA_PartGen_System::~CPA_PartGen_System()
{
fn_vNotifyUnSave();
}
void CPA_PartGen_System::m_pub_fn_vSetSystem( PRT_tdstParticlesSystem *_p_stSystem )
{
fn_vUpdateData( (void*)_p_stSystem );
m_pri_p_stSystem = _p_stSystem;
SetAvailable( TRUE );
m_pri_fn_vSetInternalParticle();
m_pri_fn_vFillDataList();
}
////////////////////////////////////
// Virtual functions
long CPA_PartGen_System::GetDataType( void )
{
return( 0 );
}
void* CPA_PartGen_System::GetData( void )
{
return (void*)m_pri_p_stSystem;
}
CString CPA_PartGen_System::fn_csComputeReferencedSectionName(const CString _csNewName)
{
CString csResult = "Systems.prt^";
csResult += C_SectionPrtSysDescription;
csResult += ":";
return( csResult + _csNewName );
}
//*************************************************
// Load if necessary
BOOL CPA_PartGen_System::m_pub_fn_vLoadIfUnloaded()
{
if ( !fn_bIsAvailable() )
{
CString csSectionName = GetReferencedSectionName();
SCR_tdst_Cxt_Values *p_stValues;
p_stValues = SCR_fnp_st_RdL0_AnalyseSection((char *)LPCTSTR(csSectionName), SCR_CDF_uw_Anl_Normal);
PRT_tdstParticlesSystem *p_stSys = (PRT_tdstParticlesSystem*)p_stValues->a_ulValues[0];
fn_vUpdateData( (void*)p_stSys );
m_pri_p_stSystem = p_stSys;
SetAvailable(TRUE);
m_pri_fn_vSetInternalParticle();
m_pri_fn_vFillDataList();
return TRUE;
}
else return FALSE;
}
/////////////////////////////////////////////////
// Point, Segment and Sprite
long CPA_PartGen_System::m_pub_fn_lGetParticlesType()
{
return (long)m_pri_p_stSystem->xParticlesType;
}
void CPA_PartGen_System::m_pub_fn_vSetObjectPoint( GMT_tdxHandleToGameMaterial _hGameMaterial )
{
PRT_fn_vCreatePointParticles( m_pri_p_stSystem, _hGameMaterial );
}
GMT_tdxHandleToGameMaterial CPA_PartGen_System::m_pub_fn_hGetPointGameMaterial()
{
return GEO_xGetGameMaterialOfElementPoints(m_pri_p_stSystem->hParticlesSystemObject,0);
}
void CPA_PartGen_System::m_pub_fn_vSetObjectSegment( GMT_tdxHandleToGameMaterial _hGameMaterial )
{
PRT_fn_vCreateSegmentParticles( m_pri_p_stSystem, _hGameMaterial );
}
GMT_tdxHandleToGameMaterial CPA_PartGen_System::m_pub_fn_hGetSegmentGameMaterial()
{
GMT_tdxHandleToGameMaterial hGameMaterial;
GEO_xGetGameMaterialOfElementLines(m_pri_p_stSystem->hParticlesSystemObject,0, 0, &hGameMaterial);
return hGameMaterial;
}
void CPA_PartGen_System::m_pub_fn_vSetObjectSprite( ACP_tdxHandleOfSprite _hSprite )
{
PRT_fn_vCreateSpriteParticles( m_pri_p_stSystem, _hSprite );
}
ACP_tdxHandleOfSprite CPA_PartGen_System::m_pub_fn_hGetSprite()
{
ACP_tdxHandleOfSprite hSprite;
GEO_vGetHandleOfIndexedSprite(m_pri_p_stSystem->hParticlesSystemObject, 0, 0, &hSprite );
return hSprite;
}
void CPA_PartGen_System::m_pri_fn_vSetInternalParticle()
{
ACP_tdxIndex xType = m_pri_p_stSystem->xParticlesType;
switch( xType )
{
case PRT_C_xPointParticles:
m_pri_hGameMaterial = GEO_xGetGameMaterialOfElementPoints(m_pri_p_stSystem->hParticlesSystemObject,0);
break;
case PRT_C_xSegmentParticles:
GEO_xGetGameMaterialOfElementLines(m_pri_p_stSystem->hParticlesSystemObject,0, 0, &m_pri_hGameMaterial);
break;
case PRT_C_xSpriteParticles:
GEO_vGetHandleOfIndexedSprite(m_pri_p_stSystem->hParticlesSystemObject, 0, 0, &m_pri_hSprite );
break;
}
}
//****************************************************
// Gets name of the associated object using link table
CString CPA_PartGen_System::m_pub_fn_csGetObjectName()
{
CString csObjectName = "";
SCR_tdst_Link_Table *p_stLinkTable = NULL;
SCR_tdst_Link_Value *p_stValue = NULL;
unsigned long ulValue = 0;
long lIndex = m_pub_fn_lGetParticlesType();
switch( lIndex )
{
case PRT_C_xPointParticles:
p_stLinkTable = GMT_fn_p_stGetLinkTable();
ulValue = (unsigned long)m_pub_fn_hGetPointGameMaterial();
break;
case PRT_C_xSegmentParticles:
p_stLinkTable = GMT_fn_p_stGetLinkTable();
ulValue = (unsigned long)m_pub_fn_hGetSegmentGameMaterial();
break;
case PRT_C_xSpriteParticles:
p_stLinkTable = GLI_p_stGetLinkTableOfSprite();
ulValue = (unsigned long)m_pub_fn_hGetSprite();
break;
}
//*** finds the entry *****
if( p_stLinkTable != NULL )
p_stValue = SCR_fnp_st_Link_SearchValue( p_stLinkTable, ulValue );
//*** gets the name of the entry ******************************************************
if( p_stValue != NULL && SCR_M_e_Link_GetState(p_stValue) == SCR_ELS_Link_Initialized )
{
csObjectName = SCR_M_p_sz_Link_GetKey(p_stValue);
char a_256cFileName[256];
char a_256cActionName[256];
char a_256cName[256];
SCR_fn_v_RdL0_SplitSectionName((char *)LPCTSTR(csObjectName), a_256cFileName, a_256cActionName, a_256cName);
csObjectName = a_256cName;
}
return csObjectName;
}
/////////////////////////////////////////////////
// Nb particles
long CPA_PartGen_System::m_pub_fn_lGetNbParticles()
{
return (long)m_pri_p_stSystem->xNbParticles;
}
///////////////////////////////////////////////////
// CallBack and Function for save
void CPA_PartGen_System::m_s_fn_vCallBackSaveSystem
(
SCR_tdst_File_Description *_p_stFile,
char *_p_szSectionName,
void *_p_vData,
SCR_tde_Ntfy_Action _eAction
)
{
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"Saving a generator",
"CPA_PartGen_System::m_s_fn_vCallBackSaveSystem",
E_ERROR_GRAVITY_FATAL,
"trying to save a NULL system"
);
CPA_PartGen_System *p_clSys = (CPA_PartGen_System*)_p_vData;
CString csHeaderName = C_SectionPrtSysDescription;
switch( _eAction )
{
case SCR_EA_Ntfy_AddSection:
case SCR_EA_Ntfy_AddOrModifySection:
case SCR_EA_Ntfy_AddOrRebuildSection:
case SCR_EA_Ntfy_RebuildSection:
case SCR_EA_Ntfy_ModifySection:
csHeaderName += ":";
csHeaderName += p_clSys->GetName();
SCR_M_SvL0_SaveBeginSection( _p_stFile, M_MAKECHAR(csHeaderName), SCR_CC_C_Cfg_NoChar );
SCR_fn_v_SvL0_SaveParameters_MP( _p_stFile, SCR_EF_SvL0_Scanf, 2, "%d", p_clSys->m_pub_fn_lGetNbParticles() );
p_clSys->m_pri_fn_vSaveSystem( _p_stFile );
SCR_M_SvL0_SaveEndSection( _p_stFile, SCR_CC_C_Cfg_EOL );
p_clSys->fn_vSectionSaved();
break;
case SCR_EA_Ntfy_DeleteIfExists:
case SCR_EA_Ntfy_DeleteSection:
p_clSys->fn_vSectionDeleted();
break;
}
}
void CPA_PartGen_System::m_pri_fn_vSaveSystem( SCR_tdst_File_Description *_p_stFile )
{
SCR_tdst_Link_Value *p_stLinkValue = NULL;
unsigned long ulValue = 0;
SCR_tdst_Link_Table *p_stLinkTable = NULL;
CString csEntryName = "";
long lIndex = m_pub_fn_lGetParticlesType();
switch( lIndex )
{
//*** Point particles *****
case PRT_C_xPointParticles:
p_stLinkTable = GMT_fn_p_stGetLinkTable();
ulValue = (unsigned long)m_pub_fn_hGetPointGameMaterial();
csEntryName = C_EntryPrtSysCreatePoint;
break;
//*** Segment particles *****
case PRT_C_xSegmentParticles:
p_stLinkTable = GMT_fn_p_stGetLinkTable();
ulValue = (unsigned long)m_pub_fn_hGetSegmentGameMaterial();
csEntryName = C_EntryPrtSysCreateSegment;
break;
//*** Sprite particles *****
case PRT_C_xSpriteParticles:
p_stLinkTable = GLI_p_stGetLinkTableOfSprite();
ulValue = (unsigned long)m_pub_fn_hGetSprite();
csEntryName = C_EntryPrtSysCreateSprite;
break;
}
if( p_stLinkTable != NULL )
{
p_stLinkValue = SCR_fnp_st_Link_SearchValue( p_stLinkTable, ulValue );
if ( p_stLinkValue != NULL )
{
SCR_M_SvL0_SaveEntry( _p_stFile, M_MAKECHAR(csEntryName), SCR_CC_C_Cfg_NoChar );
CString csKey = SCR_M_p_sz_Link_GetKey(p_stLinkValue);
long lOffset = SCR_M_ul_Link_GetAdditionalLong(p_stLinkValue, 1);
if ( lOffset > 0 )
csKey = csKey.Right(csKey.GetLength() - lOffset);
SCR_fn_v_SvL0_SaveParameters_MP(_p_stFile, SCR_EF_SvL0_Scanf, 1, M_MAKECHAR(csKey));
}
}
}
void CPA_PartGen_System::m_pri_fn_vFillDataList()
{
CTL_Editor_Data *p_clData = NULL;
CTL_Editor_EnumDescriptor *p_clEnumDescriptor = NULL;
//*** Nb Particles *******************************
p_clData = m_pub_clDataList.m_fn_pclAddIntegerData( sizeof(ACP_tdxIndex), TPG_UNSIGNED, "Nb Particles" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_p_stSystem->xNbParticles) );
//*** Objects Type **************************
p_clEnumDescriptor = m_pub_fn_p_clGetDocument()->m_pub_fn_p_clGetEnumDescriptorByName( "System_ObjectsType" );
p_clData = m_pub_clDataList.m_fn_pclAddEnumData( p_clEnumDescriptor, "Particles Type" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&(m_pri_p_stSystem->xParticlesType) );
p_clData->m_pub_fn_vSetDataChangedSpecialCallBackFunction( g_fn_vCallBackDataChangedSpecialDisplayGenerator );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedSystem" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( g_fn_vCallBackDataChangedSystem );
//*** Objects Game Material *****************
p_clEnumDescriptor = m_pub_fn_p_clGetDocument()->m_pub_fn_p_clGetEnumDescriptorByName( "System_ObjectsGameMaterials" );
p_clData = m_pub_clDataList.m_fn_pclAddEnumData( p_clEnumDescriptor, "Game Material" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&m_pri_hGameMaterial );
p_clData->m_pub_fn_pclAddOwnerData( (void*)&(m_pri_p_stSystem->xParticlesType), "ObjectsType" );
p_clData->m_pub_fn_vSetModificationFunctionWhenWrite( g_fn_vModificationWriteSystemObjects );
//p_clData->m_pub_fn_vSetModificationFunctionWhenRead( g_fn_vModificationReadSystemGameMaterials );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedSystem" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( g_fn_vCallBackDataChangedSystem );
p_clData->m_pub_fn_vSetDataMustBeRead_CallBack( g_fn_bCallBackMustBeReadWrittenSystemGameMaterial );
p_clData->m_pub_fn_vSetDataMustBeWritten_CallBack( g_fn_bCallBackMustBeReadWrittenSystemGameMaterial );
//*** Objects Sprites ***********************
p_clEnumDescriptor = m_pub_fn_p_clGetDocument()->m_pub_fn_p_clGetEnumDescriptorByName( "System_Sprites" );
p_clData = m_pub_clDataList.m_fn_pclAddEnumData( p_clEnumDescriptor, "Sprites" );
p_clData->m_fn_vSetMotorDataPtr( (void*)&m_pri_hSprite );
p_clData->m_pub_fn_pclAddOwnerData( (void*)&(m_pri_p_stSystem->xParticlesType), "ObjectsType" );
p_clData->m_pub_fn_vSetModificationFunctionWhenWrite( g_fn_vModificationWriteSystemObjects );
p_clData->m_pub_fn_pclAddOwnerData( (void*)this, "EditedSystem" );
p_clData->m_pub_fn_vSetDataChangedCallBackFunction( g_fn_vCallBackDataChangedSystem );
p_clData->m_pub_fn_vSetDataMustBeRead_CallBack( g_fn_bCallBackMustBeReadWrittenSystemSprite );
p_clData->m_pub_fn_vSetDataMustBeWritten_CallBack( g_fn_bCallBackMustBeReadWrittenSystemSprite );
}
CPA_PartGen_MyDocument * CPA_PartGen_System::m_pub_fn_p_clGetDocument()
{
return g_pclInterface->m_pub_fn_p_clGetDocument();
}

View File

@@ -0,0 +1,40 @@
#include "StdAfx.h"
#include "TPG_Spri.hpp"
#include "SCR.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//***********************************************************************
TPG_Sprite::TPG_Sprite( CString _csName, ACP_tdxHandleOfSprite _hSprite )
{
m_pri_csName = _csName;
m_pri_hSprite = _hSprite;
}
TPG_Sprite::~TPG_Sprite()
{
}
ACP_tdxHandleOfSprite TPG_Sprite::m_pub_fn_hGetSprite()
{
return m_pri_hSprite;
}
void TPG_Sprite::m_pub_fn_vLoadSprite()
{
CString csSectionName = "Sprites.prt^Sprite:" + m_pri_csName;
SCR_tdst_Cxt_Values *p_stValues;
p_stValues = SCR_fnp_st_RdL0_AnalyseSection((char *)LPCTSTR(csSectionName), SCR_CDF_uw_Anl_Normal);
m_pri_hSprite = (ACP_tdxHandleOfSprite)SCR_M_ul_RdL0_ExtractLongValue( p_stValues, 0 );
}

View File

@@ -0,0 +1,691 @@
// TPG_View.cpp : implementation file
//
#include "stdafx.h"
#include "x:\cpa\main\inc\_EditID.h"
#include "TUT.h"
#include "TPG_View.hpp"
#include "TPGMyDoc.hpp"
#include "TPG_OGen.hpp"
#include "TPG_OEnv.hpp"
#include "TPG_OSys.hpp"
#include "_Minterf.hpp"
#include "TPG_Strg.hpp"
#include "ErO.h"
#include "SCR.h"
#include "WAW.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// TPG_View
IMPLEMENT_DYNCREATE(TPG_View, CTL_Editor_BaseFormView)
TPG_View::TPG_View() : CTL_Editor_BaseFormView(TPG_View::IDD)
{
//{{AFX_DATA_INIT(TPG_View)
//}}AFX_DATA_INIT
}
TPG_View::~TPG_View()
{
}
void TPG_View::DoDataExchange(CDataExchange* pDX)
{
CTL_Editor_BaseFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(TPG_View)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(TPG_View, CTL_Editor_BaseFormView)
//{{AFX_MSG_MAP(TPG_View)
ON_BN_CLICKED(IDC_BUTTON_DELETE, OnButtonDelete)
ON_BN_CLICKED(IDC_BUTTON_NEW, OnButtonNew)
ON_BN_CLICKED(IDC_BUTTON_DELETEENV, OnButtonDeleteenv)
ON_BN_CLICKED(IDC_BUTTON_DELETESYSTEM, OnButtonDeletesystem)
ON_BN_CLICKED(IDC_BUTTON_NEWENV, OnButtonNewenv)
ON_BN_CLICKED(IDC_BUTTON_NEWSYSTEM, OnButtonNewsystem)
ON_BN_CLICKED(IDC_BUTTON_RENAMEENV, OnButtonRenameenv)
ON_BN_CLICKED(IDC_BUTTON_RENAMESYSTEM, OnButtonRenamesystem)
ON_WM_LBUTTONDBLCLK()
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// TPG_View diagnostics
#ifdef _DEBUG
void TPG_View::AssertValid() const
{
CTL_Editor_BaseFormView::AssertValid();
}
void TPG_View::Dump(CDumpContext& dc) const
{
CTL_Editor_BaseFormView::Dump(dc);
}
#endif //_DEBUG
//////////////////////////////////////////////////////////////////////////////
// Functions to get the document associated to the View
CPA_PartGen_MyDocument* TPG_View::m_pub_fn_p_clGetDocument()
{
return g_pclInterface->m_pub_fn_p_clGetDocument();
}
/////////////////////////////////////////////////////////////////////////////
// TPG_View message handlers
//////////////////////////////
// Generator control
// Creation Control
void TPG_View::OnButtonNew()
{
CPA_Dialog_GeneratorNewName Dialog( this );
if ( Dialog.DoModal() == IDOK )
{
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"Creating a new generator",
"TPG_View::OnButtonNew",
E_ERROR_GRAVITY_FATAL,
"new generator is not allocated"
);
CPA_PartGen_Generator *p_clGenerator = new CPA_PartGen_Generator( Dialog.m_csNewGeneratorName );
ERROR_ASSERT( p_clGenerator != NULL );
m_pub_fn_p_clGetDocument()->m_pub_p_clDialogList->fn_vUpdateSelection(E_lrm_ReinitList);
}
}
void TPG_View::OnButtonDelete()
{
CString csText = "You are going to delete the generator '";
csText += m_pub_fn_p_clGetDocument()->m_pub_p_clCurrentGenerator->GetName();
csText += "'\nDo you want to continue ?";
CPA_Dialog_Warning Dialog( this, csText );
if ( Dialog.DoModal() == IDOK )
{
m_pub_fn_p_clGetDocument()->m_pub_fn_vDeleteGenerator();
m_pub_fn_p_clGetDocument()->m_pub_p_clDialogList->fn_vUpdateSelection(E_lrm_ReinitList);
}
}
///////////////////////////////:
// Environment controls
void TPG_View::OnButtonNewenv()
{
CPA_Dialog_GeneratorNewName Dialog( this );
if ( Dialog.DoModal() == IDOK )
{
CPA_PartGen_Environment *p_clEnv = new CPA_PartGen_Environment( Dialog.m_csNewGeneratorName);
ERROR_ASSERT( p_clEnv != NULL );
m_pub_fn_p_clGetDocument()->m_pub_p_clDialogList->fn_vUpdateSelection(E_lrm_ReinitList);
m_pub_fn_p_clGetDocument()->m_pub_fn_vUpdateChangingEnumDescriptors();
/*CComboBox *p_clCombo = (CComboBox*)GetDlgItem( IDC_COMBO_ENV );
short wIndex = p_clCombo->AddString( p_clEnv->GetName() );
p_clCombo->SetItemDataPtr( wIndex, (void*)p_clEnv );*/
}
}
void TPG_View::OnButtonDeleteenv()
{
CString csText = "You are going to delete the environment '";
csText += m_pub_fn_p_clGetDocument()->m_pub_p_clCurrentEnv->GetName();
csText += "'\nDo you want to continue ?";
CPA_Dialog_Warning Dialog( this, csText );
if ( Dialog.DoModal() == IDOK )
{
m_pub_fn_p_clGetDocument()->m_pub_fn_vDeleteEnv();
m_pub_fn_p_clGetDocument()->m_pub_p_clDialogList->fn_vUpdateSelection(E_lrm_ReinitList);
}
}
/*
void Parcours( WAW_DataList &List )
{
POSITION pos = List.GetHeadPosition();
while( pos != NULL )
{
WAW_Data * pclData = List.GetNext( pos );
}
}
*/
void TPG_View::OnButtonRenameenv()
{
//*** Test de WAW
/*
WAW_DataList List( "TPG Test" );
List.m_pub_fn_vGetVisible();
Parcours( List );
*/
}
//////////////////////////////////
// System Controls
void TPG_View::OnButtonNewsystem()
{
CPA_Dialog_SystemNewName Dialog( this );
if ( Dialog.DoModal() == IDOK )
{
CPA_PartGen_System *p_clSystem = new CPA_PartGen_System( Dialog.m_csNewSystemName, Dialog.m_lNbParticles);
ERROR_ASSERT( p_clSystem != NULL );
m_pub_fn_p_clGetDocument()->m_pub_p_clDialogList->fn_vUpdateSelection(E_lrm_ReinitList);
m_pub_fn_p_clGetDocument()->m_pub_fn_vUpdateChangingEnumDescriptors();
/*CComboBox *p_clCombo = (CComboBox*)GetDlgItem( IDC_COMBO_SYSTEM );
short wIndex = p_clCombo->AddString( p_clSystem->GetName() );
p_clCombo->SetItemDataPtr( wIndex, (void*)p_clSystem );*/
}
}
void TPG_View::OnButtonDeletesystem()
{
CString csText = "You are going to delete the system '";
csText += m_pub_fn_p_clGetDocument()->m_pub_p_clCurrentSystem->GetName();
csText += "'\nDo you want to continue ?";
CPA_Dialog_Warning Dialog( this, csText );
if ( Dialog.DoModal() == IDOK )
{
m_pub_fn_p_clGetDocument()->m_pub_fn_vDeleteSystem();
m_pub_fn_p_clGetDocument()->m_pub_p_clDialogList->fn_vUpdateSelection(E_lrm_ReinitList);
}
}
/*
void TPG_g_fn_TestForWAW( WAW_tdeMessage _eMessage, void * _pvData )
{
int i = 0;
switch( _eMessage )
{
case WAW_eDeletedNode :
i = i;
break;
case WAW_eUpdateData :
i = i;
break;
}
}
*/
void TPG_View::OnButtonRenamesystem()
{
//*** Test de WAW
/*
WAW_hUserInfo hInfo = WAW_fn_hUserRegister( "TPG Test", TPG_g_fn_TestForWAW );
WAW_Data * pclData = NULL;
pclData = WAW_fn_pclAddNode( hInfo, NULL, "System" );
pclData = WAW_fn_pclAddData( hInfo, pclData, "Bidon", "1.500" );
WAW_fn_pclAddData( hInfo, pclData, "Truc", "0", TPG_g_fn_TestForWAW );
WAW_fn_pclAddData( hInfo, pclData, "Machin", "Hello" );
WAW_fn_pclAddData( hInfo, NULL, "Truc", "0" );
*/
}
///////////////////////////////////////
// Fuctions to show and update editors
///////////////////////////////////////
void TPG_View::OnInitialUpdate()
{
CTL_Editor_BaseFormView::OnInitialUpdate();
g_pclInterface->m_pub_p_clView = this;
//*** register controls for TUT
TUT_M_vGetTutDll();
TUT_M_vRegisterControl(m_hWnd, "TPG_MainWindow",TUT_e_Window);
//****** register buttons
TUT_M_vRegisterControlID(IDC_BUTTON_NEW, "TPG_CreateNewGenerator",TUT_e_Button);
TUT_M_vRegisterControlID(IDC_BUTTON_RENAME, "TPG_CopyEditedGenerator",TUT_e_Button);
TUT_M_vRegisterControlID(IDC_BUTTON_DELETE, "TPG_DeleteEditedGenerator",TUT_e_Button);
//ANNECY VL PRT 20/03/98{
TUT_M_vRegisterControlID(IDC_BUTTON_NEWPRTSRC, "TPG_CreateNewSource",TUT_e_Button);
TUT_M_vRegisterControlID(IDC_BUTTON_RENAMEPRTSRC, "TPG_CopyEditedSource",TUT_e_Button);
TUT_M_vRegisterControlID(IDC_BUTTON_DELETEPRTSRC, "TPG_DeleteEditedSourec",TUT_e_Button);
//ENDANNECY VL}
TUT_M_vRegisterControlID(IDC_BUTTON_NEWSYSTEM, "TPG_CreateNewSystem",TUT_e_Button);
TUT_M_vRegisterControlID(IDC_BUTTON_RENAMESYSTEM, "TPG_CopyEditedSystem",TUT_e_Button);
TUT_M_vRegisterControlID(IDC_BUTTON_DELETESYSTEM, "TPG_DeleteEditedSystem",TUT_e_Button);
TUT_M_vRegisterControlID(IDC_BUTTON_NEWENV, "TPG_CreateNewEnvironment",TUT_e_Button);
TUT_M_vRegisterControlID(IDC_BUTTON_RENAMEENV, "TPG_CopyEditedEnvironment",TUT_e_Button);
TUT_M_vRegisterControlID(IDC_BUTTON_DELETEENV, "TPG_DeleteEditedEnvironment",TUT_e_Button);
m_pub_fn_p_clGetDocument()->m_pub_fn_vDisplayCurrentGenerator();
}
void TPG_View::m_pub_fn_vDisplayGeneratorInZone( CPA_PartGen_Generator *_p_clGenerator, CPoint *_p_clTopLeft, CPoint * _p_clTopRight )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
CWnd *p_clWnd = NULL;
CRect *p_clRect = new CRect( *_p_clTopLeft, *_p_clTopRight );
int iButtonWidth = (int) (p_clRect->Width() / 3);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
p_clRect->InflateRect( 0, 10 );
p_clRect->OffsetRect( 0, 10 );
p_clWnd = GetDlgItem( IDC_STATIC_GENERATORNAME );
p_clWnd->SetWindowText( (_p_clGenerator != NULL) ? _p_clGenerator->GetName() : "<No Generator>" );
p_clWnd->MoveWindow( p_clRect );
p_clWnd->ShowWindow( TRUE );
p_clRect->DeflateRect( iButtonWidth, 0 );
p_clRect->OffsetRect( -iButtonWidth, 25 );
p_clWnd = GetDlgItem( IDC_BUTTON_NEW );
p_clWnd->MoveWindow( p_clRect );
p_clWnd->ShowWindow( TRUE );
p_clRect->OffsetRect( iButtonWidth, 0 );
p_clWnd = GetDlgItem( IDC_BUTTON_RENAME );
p_clWnd->MoveWindow( p_clRect );
p_clWnd->EnableWindow( FALSE );
p_clWnd->ShowWindow( TRUE );
p_clRect->OffsetRect( iButtonWidth, 0 );
p_clWnd = GetDlgItem( IDC_BUTTON_DELETE );
p_clWnd->MoveWindow( p_clRect );
p_clWnd->EnableWindow( _p_clGenerator != NULL );
p_clWnd->ShowWindow( TRUE );
_p_clTopLeft->y+=50;
_p_clTopRight->y+=50;
delete p_clRect;
}
void TPG_View::m_pub_fn_vDisplaySourceInZone( CPA_PartGen_Source *_p_oPrtSrc, CPoint *_p_clTopLeft, CPoint * _p_clTopRight )
{
CWnd * p_clWnd = NULL;
CRect * p_clRect = new CRect( *_p_clTopLeft, *_p_clTopRight );
int iButtonWidth = (int)(p_clRect->Width() / 3);
p_clRect->InflateRect( 0, 10 );
p_clRect->OffsetRect( 0, 10 );
p_clWnd = GetDlgItem( IDC_STATIC_PRTSRCNAME );
p_clWnd->SetWindowText( ( _p_oPrtSrc != NULL ) ? _p_oPrtSrc->GetName() : "<No Source>" );
p_clWnd->MoveWindow( p_clRect );
p_clWnd->ShowWindow( TRUE );
p_clRect->DeflateRect( iButtonWidth, 0 );
p_clRect->OffsetRect( -iButtonWidth, 25 );
p_clWnd = GetDlgItem( IDC_BUTTON_NEWPRTSRC );
p_clWnd->MoveWindow( p_clRect );
p_clWnd->ShowWindow( TRUE );
p_clRect->OffsetRect( iButtonWidth, 0 );
p_clWnd = GetDlgItem( IDC_BUTTON_RENAMEPRTSRC );
p_clWnd->MoveWindow( p_clRect );
p_clWnd->EnableWindow( FALSE );
p_clWnd->ShowWindow( TRUE );
p_clRect->OffsetRect( iButtonWidth, 0 );
p_clWnd = GetDlgItem( IDC_BUTTON_DELETEPRTSRC );
p_clWnd->MoveWindow( p_clRect );
p_clWnd->EnableWindow( _p_oPrtSrc != NULL );
p_clWnd->ShowWindow( TRUE );
_p_clTopLeft->y+=50;
_p_clTopRight->y+=50;
delete p_clRect;
}
void TPG_View::m_pub_fn_vDisplaySystemInZone( CPA_PartGen_System *_p_clSystem, CPoint *_p_clTopLeft, CPoint * _p_clTopRight )
{
CWnd * p_clWnd = NULL;
CRect * p_clRect = new CRect( *_p_clTopLeft, *_p_clTopRight );
int iButtonWidth = (int)(p_clRect->Width() / 3);
p_clRect->InflateRect( 0, 10 );
p_clRect->OffsetRect( 0, 10 );
p_clWnd = GetDlgItem( IDC_STATIC_SYSNAME );
p_clWnd->SetWindowText( ( _p_clSystem != NULL ) ? _p_clSystem->GetName() : "<No System>" );
p_clWnd->MoveWindow( p_clRect );
p_clWnd->ShowWindow( TRUE );
p_clRect->DeflateRect( iButtonWidth, 0 );
p_clRect->OffsetRect( -iButtonWidth, 25 );
p_clWnd = GetDlgItem( IDC_BUTTON_NEWSYSTEM );
p_clWnd->MoveWindow( p_clRect );
p_clWnd->ShowWindow( TRUE );
p_clRect->OffsetRect( iButtonWidth, 0 );
p_clWnd = GetDlgItem( IDC_BUTTON_RENAMESYSTEM );
p_clWnd->MoveWindow( p_clRect );
p_clWnd->EnableWindow( FALSE );
p_clWnd->ShowWindow( TRUE );
p_clRect->OffsetRect( iButtonWidth, 0 );
p_clWnd = GetDlgItem( IDC_BUTTON_DELETESYSTEM );
p_clWnd->MoveWindow( p_clRect );
p_clWnd->EnableWindow( _p_clSystem != NULL );
p_clWnd->ShowWindow( TRUE );
_p_clTopLeft->y+=50;
_p_clTopRight->y+=50;
delete p_clRect;
}
void TPG_View::m_pub_fn_vDisplayEnvInZone( CPA_PartGen_Environment *_p_clEnv, CPoint *_p_clTopLeft, CPoint * _p_clTopRight )
{
CWnd * p_clWnd = NULL;
CRect * p_clRect = new CRect( *_p_clTopLeft, *_p_clTopRight );
int iButtonWidth = (int)(p_clRect->Width() / 3);
p_clRect->InflateRect( 0, 10 );
p_clRect->OffsetRect( 0, 10 );
p_clWnd = GetDlgItem( IDC_STATIC_ENVNAME );
p_clWnd->SetWindowText( ( _p_clEnv != NULL ) ? _p_clEnv->GetName() : "<No Environment>" );
p_clWnd->MoveWindow( p_clRect );
p_clWnd->ShowWindow( TRUE );
p_clRect->DeflateRect( iButtonWidth, 0 );
p_clRect->OffsetRect( -iButtonWidth, 25 );
p_clWnd = GetDlgItem( IDC_BUTTON_NEWENV );
p_clWnd->MoveWindow( p_clRect );
p_clWnd->ShowWindow( TRUE );
p_clRect->OffsetRect( iButtonWidth, 0 );
p_clWnd = GetDlgItem( IDC_BUTTON_RENAMEENV );
p_clWnd->MoveWindow( p_clRect );
p_clWnd->EnableWindow( FALSE );
p_clWnd->ShowWindow( TRUE );
p_clRect->OffsetRect( iButtonWidth, 0 );
p_clWnd = GetDlgItem( IDC_BUTTON_DELETEENV );
p_clWnd->MoveWindow( p_clRect );
p_clWnd->EnableWindow( _p_clEnv != NULL );
p_clWnd->ShowWindow( TRUE );
_p_clTopLeft->y+=50;
_p_clTopRight->y+=50;
delete p_clRect;
}
void TPG_View::OnLButtonDblClk(UINT nFlags, CPoint point)
{
CRect clClientRect;
GetDlgItem( IDC_STATIC_GENERATORNAME )->GetWindowRect( &clClientRect );
ScreenToClient( &clClientRect );
if( clClientRect.PtInRect( point ) )
m_pub_fn_p_clGetDocument()->m_pub_p_clDialogList->SetCurrentType( g_C_csPartGenGeneratorName );
GetDlgItem( IDC_STATIC_SYSNAME )->GetWindowRect( &clClientRect );
ScreenToClient( &clClientRect );
if( clClientRect.PtInRect( point ) )
m_pub_fn_p_clGetDocument()->m_pub_p_clDialogList->SetCurrentType( g_C_csPartGenSystemName );
GetDlgItem( IDC_STATIC_ENVNAME )->GetWindowRect( &clClientRect );
ScreenToClient( &clClientRect );
if( clClientRect.PtInRect( point ) )
m_pub_fn_p_clGetDocument()->m_pub_p_clDialogList->SetCurrentType( g_C_csPartGenEnvName );
CTL_Editor_BaseFormView::OnLButtonDblClk(nFlags, point);
}
void TPG_View::OnSize(UINT nType, int cx, int cy)
{
CTL_Editor_BaseFormView::OnSize(nType, cx, cy);
m_pub_fn_p_clGetDocument()->m_pub_fn_vDisplayCurrentGenerator();
}
/////////////////////////////////////////////////////////////////////////////
// CPA_Dialog_GeneratorNewName dialog
CPA_Dialog_GeneratorNewName::CPA_Dialog_GeneratorNewName(CWnd* pParent /*=NULL*/)
: CDialog(CPA_Dialog_GeneratorNewName::IDD, pParent)
{
//{{AFX_DATA_INIT(CPA_Dialog_GeneratorNewName)
m_csNewGeneratorName = _T("");
//}}AFX_DATA_INIT
}
void CPA_Dialog_GeneratorNewName::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPA_Dialog_GeneratorNewName)
DDX_Text(pDX, IDC_EDIT_NEWGENERATORNAME, m_csNewGeneratorName);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPA_Dialog_GeneratorNewName, CDialog)
//{{AFX_MSG_MAP(CPA_Dialog_GeneratorNewName)
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL CPA_Dialog_GeneratorNewName::OnInitDialog()
{
CDialog::OnInitDialog();
//*** register controls for TUT
TUT_M_vGetTutDll();
//****** register window
TUT_M_vRegisterControl(m_hWnd, "TPG_DialogNewGeneratorOrEnvironmentNameWindow",TUT_e_Window);
//****** register controls
TUT_M_vRegisterControlID(IDC_EDIT_NEWGENERATORNAME, "TPG_GetNewGeneratorOrEnvironmentName",TUT_e_TextEdit);
TUT_M_vRegisterControlID(IDOK, "TPG_AcceptNewGeneratorOrEnvironmentName",TUT_e_Button);
TUT_M_vRegisterControlID(IDCANCEL, "TPG_CancelNewGeneratorOrEnvironmentName",TUT_e_Button);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CPA_Dialog_GeneratorNewName::OnDestroy()
{
CDialog::OnDestroy();
//*** unregister controls for TUT
TUT_M_vGetTutDll();
TUT_M_vUnregisterControl(m_hWnd);
TUT_M_vUnregisterControlID(IDC_EDIT_NEWGENERATORNAME);
TUT_M_vUnregisterControlID(IDOK);
TUT_M_vUnregisterControlID(IDCANCEL);
}
/////////////////////////////////////////////////////////////////////////////
// CPA_Dialog_GeneratorNewName message handlers
/////////////////////////////////////////////////////////////////////////////
// CPA_Dialog_SystemNewName dialog
CPA_Dialog_SystemNewName::CPA_Dialog_SystemNewName(CWnd* pParent /*=NULL*/)
: CDialog(CPA_Dialog_SystemNewName::IDD, pParent)
{
//{{AFX_DATA_INIT(CPA_Dialog_SystemNewName)
m_csNewSystemName = _T("");
m_lNbParticles = 100;
//}}AFX_DATA_INIT
}
void CPA_Dialog_SystemNewName::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPA_Dialog_SystemNewName)
DDX_Text(pDX, IDC_EDIT_SYSTEMNEWNAME, m_csNewSystemName);
DDX_Text(pDX, IDC_EDIT_SYSDIALOGNBPARTICLES, m_lNbParticles);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPA_Dialog_SystemNewName, CDialog)
//{{AFX_MSG_MAP(CPA_Dialog_SystemNewName)
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPA_Dialog_SystemNewName message handlers
BOOL CPA_Dialog_SystemNewName::OnInitDialog()
{
CDialog::OnInitDialog();
//*** register controls for TUT
TUT_M_vGetTutDll();
//****** register window
TUT_M_vRegisterControl(m_hWnd, "TPG_DialogNewSystemNameWindow",TUT_e_Window);
//****** register controls
TUT_M_vRegisterControlID(IDC_EDIT_SYSTEMNEWNAME, "TPG_GetNewSystemName",TUT_e_TextEdit);
TUT_M_vRegisterControlID(IDOK, "TPG_AcceptNewSystemName",TUT_e_Button);
TUT_M_vRegisterControlID(IDCANCEL, "TPG_CancelNewSystemName",TUT_e_Button);
TUT_M_vRegisterControlID(IDC_EDIT_SYSDIALOGNBPARTICLES, "TPG_GetNewSystemNbParticles",TUT_e_TextEdit);
TUT_M_vRegisterControlID(IDC_SPIN_SYS, "TPG_SpinForNewSystemNbParticles", TUT_e_Spin);
((CSpinButtonCtrl*)GetDlgItem( IDC_SPIN_SYS ))->SetRange( 0, 500);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CPA_Dialog_SystemNewName::OnDestroy()
{
CDialog::OnDestroy();
//*** unregister controls for TUT
TUT_M_vGetTutDll();
TUT_M_vUnregisterControl(m_hWnd);
TUT_M_vUnregisterControlID(IDC_EDIT_SYSTEMNEWNAME);
TUT_M_vUnregisterControlID(IDOK);
TUT_M_vUnregisterControlID(IDCANCEL);
TUT_M_vUnregisterControlID(IDC_EDIT_SYSDIALOGNBPARTICLES);
TUT_M_vUnregisterControlID(IDC_SPIN_SYS);
}
/////////////////////////////////////////////////////////////////////////////
// CPA_Dialog_Warning dialog
CPA_Dialog_Warning::CPA_Dialog_Warning(CWnd* pParent, CString _csText /*=NULL*/)
: CDialog(CPA_Dialog_Warning::IDD, pParent)
{
//{{AFX_DATA_INIT(CPA_Dialog_Warning)
m_csWarningText = _csText;
//}}AFX_DATA_INIT
}
void CPA_Dialog_Warning::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPA_Dialog_Warning)
DDX_Text(pDX, IDC_STATIC_WARNING, m_csWarningText);
//}}AFX_DATA_MAP
}
BOOL CPA_Dialog_Warning::OnInitDialog()
{
CDialog::OnInitDialog();
//*** register controls for TUT
TUT_M_vGetTutDll();
//****** register window
TUT_M_vRegisterControl(m_hWnd, "TPG_WarningWhenObjectIsDeletedWindow",TUT_e_Window);
TUT_M_vRegisterControlID(IDOK, "TPG_AcceptObjectIsDeleted", TUT_e_Button);
TUT_M_vRegisterControlID(IDCANCEL, "TPG_CancelObjectIsDeleted", TUT_e_Button);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CPA_Dialog_Warning::OnDestroy()
{
CDialog::OnDestroy();
//*** unregister controls for TUT
TUT_M_vGetTutDll();
TUT_M_vUnregisterControl(m_hWnd);
TUT_M_vUnregisterControlID(IDOK);
TUT_M_vUnregisterControlID(IDCANCEL);
}
BEGIN_MESSAGE_MAP(CPA_Dialog_Warning, CDialog)
//{{AFX_MSG_MAP(CPA_Dialog_Warning)
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPA_Dialog_Warning message handlers

View File

@@ -0,0 +1,127 @@
//
// Common functions for Object DLL capabilities
// C. Beaudet
//
// Modified by David Reizer
//
#include "StdAfx.h"
#include "afxdllx.h"
#include "ACP_Base.h"
#include "ITF.h"
#include "MEC.h"
#define D_State_Define
#include "IncGAM.h"
#undef D_State_Define
#include "GLI.h"
#include "_Minterf.hpp"
#include "x:\cpa\main\inc\_EditID.h"
//------------------------------------------------------------------------
// Global vars
static CList<CPA_DLLBase*,CPA_DLLBase*> g_oListOfInstances; //private internal
static char *gs_p_szCPAVersion = C_szCPAVersion;
static AFX_EXTENSION_MODULE NEAR extensionDLL = { NULL, NULL };
#ifdef DLL_ONLY_ONE_INSTANCE
static CPA_PartGen_Interface *gs_p_oPartGenInterface = NULL;
#endif
//------------------------------------------------------------------------
// functions that are present in all DLL :
//------------------------------------------------------------------------
//========================================================================
// Get current CPA version
//========================================================================
extern "C" char __declspec(dllexport) *fn_p_szGetCPAVersion(void)
{
return gs_p_szCPAVersion;
}
//========================================================================
// Get type of this DLL
//========================================================================
extern "C" tdstDLLIdentity __declspec(dllexport) *fn_p_stGetDLLIdentity(void)
{
g_stPartGenDLLIdentity.eType = TOOL_DLL;
g_stPartGenDLLIdentity.csName = C_szDLLPartGenName;
g_stPartGenDLLIdentity.hModule = NULL;
g_stPartGenDLLIdentity.p_oListOfInstances = &g_oListOfInstances;
return &g_stPartGenDLLIdentity;
}
//========================================================================
// DLL init function
//========================================================================
extern "C" void __declspec(dllexport) fn_vInitDll(void)
{
new CDynLinkLibrary(extensionDLL);
}
//========================================================================
// DLL entry point
//========================================================================
extern "C" int __stdcall DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
if (!AfxInitExtensionModule(extensionDLL, hInstance))
return 0;
}
return 1;
}
//========================================================================
// Get the DLL
//========================================================================
extern "C" CPA_DLLBase __declspec(dllexport) *fn_p_oGetDLL(long lKey)
{
#ifdef DLL_ONLY_ONE_INSTANCE
switch(lKey)
{
case 0: // the game world
if (gs_p_oMYTOOLInterface == NULL)
{
gs_p_oPartGenInterface = new CPA_PartGen_Interface();
ERROR_ASSERT(gs_p_oPartGenInterface != NULL);
//*** DR ***//
g_pclInterface = gs_p_oPartGenInterface;
//*** End DR ***//
}
return gs_p_oPartGenInterface;
break;
default:
return NULL;
}
#else //DLL_ONLY_ONE_INSTANCE
switch(lKey)
{
case 0: // the game world
//*** DR ***//
g_pclInterface = new CPA_PartGen_Interface();
return g_pclInterface;
//*** End DR ***//
break;
default:
return NULL;
}
#endif //DLL_ONLY_ONE_INSTANCE
}
//------------------------------------------------------------------------
// functions that are present in this type of DLL only :
//------------------------------------------------------------------------
#undef DLL_ONLY_ONE_INSTANCE

View File

@@ -0,0 +1,511 @@
/*
=======================================================================================
Name : _Minterf.cpp
Author : David Reizer
Description : main functions for Particle Generato editor interface
=======================================================================================
Modification -> Author : Tahiti Bob Date :20/03/98
Description : adding some functionnalities
=======================================================================================
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "StdAfx.h"
#include "ACP_Base.h"
#include "ITF.h"
#include "x:\cpa\main\inc\_EditID.h"
#include "_Minterf.hpp"
#include "PGen_Res.h"
#include "TPG_Strg.hpp"
#include "ErO.h"
// infos
static CString g_csTPGName = C_szDLLPartGenName;
static CString g_csTPGAuthor = "D. Reizer";
static CString g_csTPGVersion = "V 2.0.2 18/03/98";
static CString g_csTPGFrenchHelpFile = "";
static CString g_csTPGEnglishHelpFile = "";
BOOL g_bTipFirstTime = TRUE;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
CPA_PartGen_Interface *g_pclInterface;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#define PartGen_C_MenuID_OpenID 31
#define PartGen_C_MenuID_CloseID 32
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
// the DLL global definition
tdstDLLIdentity g_stPartGenDLLIdentity;
//--------------------------------------------------------------------------------
// CONSTRUCTOR.
// You must put here all your DLL interface definitions.
//--------------------------------------------------------------------------------
CPA_PartGen_Interface::CPA_PartGen_Interface(void)
{
// ************************** private internal
m_p_stDLLIdentity = &g_stPartGenDLLIdentity;
m_stBaseDLLDefinition.bCanOutputIn3DView = FALSE;
m_stBaseDLLDefinition.bCanBeRefreshedByEngine = FALSE;
// Specific Init.
m_pclPartGenMainFrame = NULL;
m_csEditorVersion = "2.0.0 [" + CString(__DATE__) + "]";
SetEditorInfo(g_csTPGName, g_csTPGAuthor, g_csTPGVersion, g_csTPGFrenchHelpFile, g_csTPGEnglishHelpFile);
SetCurrent(FALSE);
//For errors
ERROR_g_fn_vAddAModuleDescriptor
(
g_c_csPartGenModuleNameForErrors,
m_csEditorVersion,
"David REIZER",
"01 48 18 53 74 (Montreuil)",
"dreizer@ubisoft.fr",
"Daniel PALIX",
"04 50 51 26 63 (Annecy)",
"dpalix@ubisoft.fr",
"Vincent Lhullier (Annecy)",
"04 50 52 90 84",
"vlhullier@ubisoft.fr"
);
m_pub_p_clView = NULL;
}
//**************************************************************************************
void CPA_PartGen_Interface::fn_vJustAfterRegistered(void)
{
CString a_csTypes[] =
{
g_C_csPartGenGeneratorName,
g_C_csPartGenSourceName,
g_C_csPartGenSystemName,
g_C_csPartGenEnvName
};
fn_vRegisterObjectsType(a_csTypes, 4);
}
//*****************************************
void CPA_PartGen_Interface::fn_vConstruct()
{
#ifndef __INACTIVE_INTERFACE__
/*
* Creates the main frame
*/
if ( m_pclPartGenMainFrame == NULL )
{
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"Creating the Main Frame",
"CPA_PartGen_Interface::fn_vConstruct",
E_ERROR_GRAVITY_FATAL,
"New main frame is not allocated"
);
m_pclPartGenMainFrame = new CPA_PartGen_MainFrame;
ERROR_ASSERT( m_pclPartGenMainFrame != NULL );
m_pclPartGenMainFrame->CreateBase( "",1,2,GetInterface()->GetMainWorld() );
m_pclPartGenMainFrame->mfn_vEnableCaption(FALSE);
m_pclPartGenMainFrame->m_iInitWidth = 350;
m_pclPartGenMainFrame->m_bKeepPos = TRUE;
m_pclPartGenMainFrame->m_stWinRight.cLinkSame = FRM_C_MoveLeft;
}
m_clDocument.m_pub_p_clDialogList->fn_vInitAllLists();
m_clDocument.m_pub_p_clDialogList->fn_vReinitDialog();
#endif
}
//***********************************************
void CPA_PartGen_Interface::fn_vLevelHasChanged()
{
/*
* get all loaded engine structure
*/
m_pub_fn_p_clGetDocument()->m_pub_fn_vSearchForLoadedSystems();
m_pub_fn_p_clGetDocument()->m_pub_fn_vSearchForLoadedEnvironments();
m_pub_fn_p_clGetDocument()->m_pub_fn_vSearchForLoadedGenerators();
m_pub_fn_p_clGetDocument()->m_pub_fn_vSearchForLoadedSources();
/*
* get all unloaded engine structure
*/
m_pub_fn_p_clGetDocument()->m_pub_fn_vSearchForUnLoadedGeneratorsAndSources();
m_pub_fn_p_clGetDocument()->m_pub_fn_vSearchForUnLoadedSystems();
m_pub_fn_p_clGetDocument()->m_pub_fn_vSearchForUnLoadedEnvironments();
m_pub_fn_p_clGetDocument()->m_pub_fn_vFillListOfSprites();
m_pub_fn_p_clGetDocument()->m_pub_fn_vUpdateChangingEnumDescriptors();
}
//*************************************************************************
BOOL CPA_PartGen_Interface::fn_bLoadBaseObject( CPA_BaseObject *p_oObject )
{
BOOL bValue;
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"Loading an object",
"CPA_PartGen_Interface::fn_bLoadBaseObject",
E_ERROR_GRAVITY_FATAL,
"Trying to load a NULL object"
);
ERROR_ASSERT( p_oObject != NULL );
/*
* Particle generator
*/
if( p_oObject->fn_bIsOfType(g_C_csPartGenGeneratorName) )
{
bValue = ( (CPA_PartGen_Generator*)p_oObject )->m_pub_fn_vLoadIfUnloaded();
if( bValue )
{
//Updates system and environment possibly loaded with the generator
m_pub_fn_p_clGetDocument()->m_pub_fn_vSearchForLoadedGenerators();
m_pub_fn_p_clGetDocument()->m_pub_fn_vSearchForLoadedSources();
m_pub_fn_p_clGetDocument()->m_pub_fn_vSearchForLoadedSystems();
m_pub_fn_p_clGetDocument()->m_pub_fn_vSearchForLoadedEnvironments();
( (CPA_PartGen_Generator*)p_oObject )->m_pub_fn_vSetGenInEnv();
}
m_clDocument.m_pub_fn_vUpdateChangingEnumDescriptors();
m_clDocument.m_pub_fn_vUpdateGenerator( (CPA_PartGen_Generator*) p_oObject );
return bValue;
}
/*
* Particle source
*/
else if( p_oObject->fn_bIsOfType(g_C_csPartGenSourceName) )
{
bValue = ( (CPA_PartGen_Source *) p_oObject )->m_pub_fn_vLoadIfUnloaded();
m_clDocument.m_pub_fn_vUpdateChangingEnumDescriptors();
m_clDocument.m_pub_fn_vUpdateSource( (CPA_PartGen_Source *) p_oObject );
return bValue;
}
/*
* Particle system
*/
else if( p_oObject->fn_bIsOfType(g_C_csPartGenSystemName) )
{
bValue = ( (CPA_PartGen_System*)p_oObject )->m_pub_fn_vLoadIfUnloaded();
m_clDocument.m_pub_fn_vUpdateChangingEnumDescriptors();
m_clDocument.m_pub_fn_vUpdateSystem( (CPA_PartGen_System*) p_oObject );
return bValue;
}
/*
* particle environment
*/
else if( p_oObject->fn_bIsOfType(g_C_csPartGenEnvName) )
{
bValue = ( (CPA_PartGen_Environment*)p_oObject )->m_pub_fn_vLoadIfUnloaded();
m_clDocument.m_pub_fn_vUpdateChangingEnumDescriptors();
m_clDocument.m_pub_fn_vUpdateEnv( (CPA_PartGen_Environment*) p_oObject );
return bValue;
}
return FALSE;
}
//**********************************************************************************
tdePermission CPA_PartGen_Interface::fn_eAcceptNewEditor(CPA_EditorBase *pNewEditor)
{
return C_Allow;
}
//**********************************************************************************
BOOL CPA_PartGen_Interface::fn_bCanActivateEditor(CPA_List<CPA_BaseObject> *pParams)
{
#ifdef __INACTIVE_INTERFACE__
return FALSE;
#endif
return TRUE;
}
//**************************************************************************************
void CPA_PartGen_Interface::fn_vOnActivateEditor(CPA_List<CPA_BaseObject> *pParams,BOOL bBackActivated)
{
m_fn_vShowEditor();
}
//**************************************************************************************
BOOL CPA_PartGen_Interface::fn_bCanCloseEditor(void)
{
return TRUE;
}
//**************************************************************************************
void CPA_PartGen_Interface::fn_vOnCloseEditor(void)
{
}
//**************************************************************************************
void CPA_PartGen_Interface::fn_vBeforeEngine(void)
{
m_fn_vHideEditor();
}
//**************************************************************************************
void CPA_PartGen_Interface::fn_vBeforeEditor(void)
{
if ( fn_bIsCurrentEditor() )
m_fn_vShowEditor();
}
//**************************************************************************************
void CPA_PartGen_Interface::fn_vHasLostFocus(void)
{
}
//**************************************************************************************
BOOL CPA_PartGen_Interface::fn_bHasGainedFocus(void)
{
m_pub_fn_p_clGetDocument()->m_pub_fn_vUpdateChangingEnumDescriptors();
// display Tip of the Day
GetInterface()->fn_vDisplayTipOfDay("Particle Generators", "TPG", g_bTipFirstTime);
g_bTipFirstTime = FALSE;
return TRUE;
}
//**************************************************************************************
//Begin Mircea Dunka 31 Aug 1998 - DialogBar interface
void CPA_PartGen_Interface::fn_vDefineDlgBarBtnIcon (tde_DlgBarCategory wCategory, tds_DlgBarBtn *_pDlgBarBtn)
{
if(wCategory == C_DlgBarCategoryEditor)
{
_pDlgBarBtn->hIcon = ::LoadIcon((HINSTANCE)(GetDLLIdentity()->hModule), MAKEINTRESOURCE(IDI_TPG_DLGBAR_ICON));
CString oCst;
oCst = C_szDLLPartGenName;
if( (M_GetMainApp()) && (M_GetMainApp()->mp_oAppKeyboard) )
{
oCst += " (";
oCst += M_GetMainApp()->mp_oAppKeyboard->mfn_oConvertIniStringToKeyString((const CString*)&CString("Activate Particle Editor"));
oCst += ")";
}
strcpy(_pDlgBarBtn->szToolTip, (char*)(LPCTSTR)oCst);
_pDlgBarBtn->uID = (UINT)this;
}
}
//end Mircea Dunka 31 Aug 1998
//**************************************************************************************
BOOL CPA_PartGen_Interface::fn_bDefineSubMenu(EDT_SubMenu *_p_oEDTSubMenu)
{
if ( _p_oEDTSubMenu->GetSubMenuType() == C_SubMenuEditor )
{
CString csMenuDescString;
CString csMenuAccelString = M_GetMainApp()->mp_oAppKeyboard->mfn_oConvertIniStringToKeyString((const CString*)&CString("Activate Particle Editor"));
csMenuDescString.Format("%s\t%s", C_szDLLPartGenName, csMenuAccelString);
if ( fn_bIsCurrentEditor() )
_p_oEDTSubMenu->AddAnEntry(this, M_MAKECHAR(csMenuDescString), PartGen_C_MenuID_CloseID, TRUE);
else
_p_oEDTSubMenu->AddAnEntry(this, M_MAKECHAR(csMenuDescString), PartGen_C_MenuID_OpenID, FALSE);
}
return TRUE;
}
//**************************************************************************************
void CPA_PartGen_Interface::_OnSubMenuCommand( EDT_SubMenu *_p_oEDTSubMenu, UINT uiMsgID)
{
switch (uiMsgID)
{
case PartGen_C_MenuID_OpenID:
if ( !fn_bIsCurrentEditor() )
GetMainWorld()->fn_bActivateEditor(this, NULL);
break;
case PartGen_C_MenuID_CloseID:
if ( fn_bIsCurrentEditor() )
GetMainWorld()->fn_bCloseEditor(this);
break;
}
}
//**************************************************************************************
BOOL CPA_PartGen_Interface::fn_bAcceptToSave()
{
BOOL bReturn = TRUE;
CPA_BaseObjectList * p_clList = GetMainWorld()->fn_p_oGetOriginalObjectList(C_szPartGenGeneratorName);
Position pos = p_clList->GetHeadPosition();
while( (pos != NULL) && bReturn )
{
CPA_PartGen_Generator * p_clGen = (CPA_PartGen_Generator*)p_clList->GetNext( pos );
if( p_clGen->fn_bIsAvailable() )
{
CString csMessage = "The generator " + p_clGen->GetName() + " does not have an associated system or environment : operation aborted";
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"Saving a Generator",
"CPA_PartGen_Interface::fn_bAcceptToSave",
E_ERROR_GRAVITY_WARNING,
csMessage
);
bReturn = ( (p_clGen->m_pub_fn_p_clGetSystem() != NULL) && (p_clGen->m_pub_fn_p_clGetEnv() != NULL) );
ERROR_ASSERT( bReturn );
}
}
p_clList = GetMainWorld()->fn_p_oGetOriginalObjectList(C_szPartGenSystemName);
pos = p_clList->GetHeadPosition();
while( (pos != NULL) && bReturn )
{
CPA_PartGen_System * p_clSys = (CPA_PartGen_System*)p_clList->GetNext( pos );
if( p_clSys->fn_bIsAvailable() )
{
CString csMessage = "System " + p_clSys->GetName() + " needs parameters : operation aborted";
ERROR_PREPARE_M
(
g_c_csPartGenModuleNameForErrors,
"Saving a System",
"CPA_PartGen_Interface::fn_bAcceptToSave",
E_ERROR_GRAVITY_WARNING,
csMessage
);
bReturn = ( (p_clSys->m_pub_fn_p_stGetSystem() != NULL) && ((p_clSys->m_pub_fn_hGetPriGameMaterial() != NULL ) || (p_clSys->m_pub_fn_hGetPriSprite() != NULL)) );
ERROR_ASSERT( bReturn );
}
}
return bReturn;
}
//************************
// for dialog list
//************************
//**************************************************************************************
void CPA_PartGen_Interface::GetListsForDialog(CPA_DialogList *pDialog)
{
pDialog->fn_vAddANewList( C_szPartGenGeneratorName, GetMainWorld()->fn_p_oGetOriginalObjectList(C_szPartGenGeneratorName) );
pDialog->fn_vAddANewList( C_szPartGenSourceName, GetMainWorld()->fn_p_oGetOriginalObjectList(C_szPartGenSourceName) );
pDialog->fn_vAddANewList( C_szPartGenSystemName, GetMainWorld()->fn_p_oGetOriginalObjectList(C_szPartGenSystemName) );
pDialog->fn_vAddANewList( C_szPartGenEnvName, GetMainWorld()->fn_p_oGetOriginalObjectList(C_szPartGenEnvName) );
}
//**************************************************************************************
void CPA_PartGen_Interface::fn_vInitDefaultParameters(CPA_DialogList *pDialog)
{
pDialog->SetDefaultButtonState(FALSE);
pDialog->SetDefaultTestName("<< No Filter >>");
pDialog->SetDefaultTypeName(C_szPartGenGeneratorName);
}
//****************************************************
BOOL CPA_PartGen_Interface::fn_bOnSelChangeListObjects(CPA_DialogList *pDialog, CString csTypeName, CPA_BaseObject *pSelectedObject, BOOL bUnselect)
{
if ( (! bUnselect) && pSelectedObject->fn_bIsAvailable() )
{
if ( csTypeName == g_C_csPartGenGeneratorName )
{
m_clDocument.m_pub_fn_vUpdateGenerator( (CPA_PartGen_Generator*)pSelectedObject );
}
else if ( csTypeName == g_C_csPartGenSourceName )
{
m_clDocument.m_pub_fn_vUpdateSource( (CPA_PartGen_Source *) pSelectedObject );
}
else if ( csTypeName == g_C_csPartGenSystemName )
{
m_clDocument.m_pub_fn_vUpdateSystem( (CPA_PartGen_System*)pSelectedObject );
}
else if ( csTypeName == g_C_csPartGenEnvName )
{
m_clDocument.m_pub_fn_vUpdateEnv( (CPA_PartGen_Environment*)pSelectedObject );
}
}
//ROMTEAM Bugs Correction (Cristian Stegaru 24/03/98)
//return TRUE;
return FALSE;
//ENDROMTEAM Bugs Correction (Cristian Stegaru)
}
//**************************************************************************************
CPA_BaseObject* CPA_PartGen_Interface::GetDialogSelection(CPA_DialogList *pDialog, CString csTypeName, tdeListDrawMode eDrawMode)
{
if ( csTypeName == g_C_csPartGenGeneratorName )
return m_clDocument.m_pub_p_clCurrentGenerator;
if ( csTypeName == g_C_csPartGenSourceName )
return m_clDocument.m_pub_p_clCurrentSource;
if ( csTypeName == g_C_csPartGenSystemName )
return m_clDocument.m_pub_p_clCurrentSystem;
if ( csTypeName == g_C_csPartGenEnvName )
return m_clDocument.m_pub_p_clCurrentEnv;
return NULL;
}
//**************************************************************************************
// Specific members
//***********************************************************************
void CPA_PartGen_Interface::m_fn_vShowEditor()
{
g_oFrameGest.mfn_vSetRefresh(FALSE);
if ( m_pclPartGenMainFrame != NULL )
g_oFrameGest.mfn_vActivateWindow(m_pclPartGenMainFrame);
g_oFrameGest.mfn_vSetRefresh(TRUE);
}
//***********************************************************************
void CPA_PartGen_Interface::m_fn_vHideEditor()
{
g_oFrameGest.mfn_vSetRefresh(FALSE);
if ( m_pclPartGenMainFrame != NULL )
g_oFrameGest.mfn_vDisactivateWindow(m_pclPartGenMainFrame);
g_oFrameGest.mfn_vSetRefresh(TRUE);
}
//***********************************************************************
CPA_PartGen_MyDocument *CPA_PartGen_Interface::m_pub_fn_p_clGetDocument()
{
return &m_clDocument;
}
//***************************************************************************
CPA_PartGen_Source *CPA_PartGen_Interface::m_pub_fn_p_clFindSourceWithEngine( PRT_tdstParticlesSource* _p_stPrtSrc )
{
return (CPA_PartGen_Source*)( GetMainWorld()->fn_p_oFindObjectWithEngine((void*)_p_stPrtSrc, C_szPartGenSourceName) );
}
//***************************************************************************
CPA_PartGen_System * CPA_PartGen_Interface::m_pub_fn_p_clFindSystemWithEngine( PRT_tdstParticlesSystem* _p_stSystem )
{
return (CPA_PartGen_System*)( GetMainWorld()->fn_p_oFindObjectWithEngine((void*)_p_stSystem, C_szPartGenSystemName) );
}
//**************************************************************************************
CPA_PartGen_Environment * CPA_PartGen_Interface::m_pub_fn_p_clFindEnvWithEngine( PRT_tdstParticlesEnvironment* _p_stEnv )
{
return (CPA_PartGen_Environment*)( GetMainWorld()->fn_p_oFindObjectWithEngine((void*)_p_stEnv, C_szPartGenEnvName) );
}
//**************************************************************************************
CPA_PartGen_Generator *CPA_PartGen_Interface::m_pub_fn_p_clFindPrtGenWithEngine( tdxHandleToParticleGenerator hPrtGen )
{
return (CPA_PartGen_Generator*)( GetMainWorld()->fn_p_oFindObjectWithEngine((void*)hPrtGen, C_szPartGenGeneratorName) );
}