203 lines
No EOL
7 KiB
C++
203 lines
No EOL
7 KiB
C++
#include "StdAfx.h"
|
||
#include "VectorProperty.h"
|
||
#include "ParticleEventProperty.h"
|
||
#include "CommandSet.h"
|
||
#include "ToolData.h"
|
||
#include <wx/msgdlg.h>
|
||
|
||
|
||
|
||
CParticleEventProperty::CParticleEventProperty( wxWindow* pParent, int id ) : IPropertyDelegate( pParent, id ),
|
||
m_iMyEventInfoID( -1 )
|
||
{
|
||
wxPGId CategoryID = m_pPropGrid->AppendCategory( wxT("Particle Event Property") );
|
||
m_pPropGrid->SetPropertyHelpString( CategoryID, wxT("Set Particle Event Property") );
|
||
|
||
m_aPGID[ PARTICLE_NAME ] = m_pPropGrid->Append( wxStringProperty( wxT("Name"), wxPG_LABEL, wxT("") ) );
|
||
|
||
m_aPGID[ IMPORT_FILE_PATH ] = m_pPropGrid->Append( wxFileProperty( wxT("Import File Name"), wxT("") ) );
|
||
m_pPropGrid->SetPropertyAttribute( m_aPGID[ IMPORT_FILE_PATH ], wxPG_FILE_WILDCARD, wxT("Particle Data File(*.ptc)|*.ptc") );
|
||
m_pPropGrid->SetPropertyAttribute( m_aPGID[ IMPORT_FILE_PATH ], wxPG_FILE_DIALOG_TITLE, wxT("Select Particle Data File") );
|
||
m_pPropGrid->SetPropertyAttribute( m_aPGID[ IMPORT_FILE_PATH ], wxPG_FILE_SHOW_FULL_PATH, 0 );
|
||
|
||
m_aPGID[ ID ] = m_pPropGrid->Append( wxUIntProperty( wxT("ID"), wxPG_LABEL, 0 ) );
|
||
m_aPGID[ POSITION ] = m_pPropGrid->Append( VectorProperty( wxT("Position"), wxPG_LABEL, EtVector3( 0.0f, 0.0f, 0.0f ) ) );
|
||
m_aPGID[ START_TIME ] = m_pPropGrid->Append( wxFloatProperty( wxT("Start Time"), wxPG_LABEL, 0 ) );
|
||
//m_aPGID[ SPEED ] = m_pPropGrid->Append( wxFloatProperty( wxT("Speed"), wxPG_LABEL, 0.0f ) );
|
||
m_aPGID[ TIME_LENGTH ] = m_pPropGrid->Append( wxFloatProperty( wxT("Time Length"), wxPG_LABEL, 0 ) );
|
||
|
||
m_pPropGrid->EnableProperty( m_aPGID[ ID ], false );
|
||
}
|
||
|
||
CParticleEventProperty::~CParticleEventProperty(void)
|
||
{
|
||
}
|
||
|
||
|
||
void CParticleEventProperty::Initialize( void )
|
||
{
|
||
|
||
}
|
||
|
||
|
||
void CParticleEventProperty::_UpdateProp( int iEventInfoID )
|
||
{
|
||
if( wxNOT_FOUND != iEventInfoID )
|
||
{
|
||
const ParticleEventInfo* pParticleEventInfo = static_cast<const ParticleEventInfo*>( TOOL_DATA.GetEventInfoByID(iEventInfoID) );
|
||
|
||
wxCSConv MBConv( wxFONTENCODING_CP949 );
|
||
wxChar caWBuf[ 256 ];
|
||
|
||
ZeroMemory( caWBuf, sizeof(caWBuf) );
|
||
MBConv.MB2WC( caWBuf, pParticleEventInfo->strEventName.c_str(), 256 );
|
||
m_pPropGrid->SetPropertyValueString( m_aPGID[ PARTICLE_NAME ], caWBuf );
|
||
|
||
ZeroMemory( caWBuf, sizeof(caWBuf) );
|
||
MBConv.MB2WC( caWBuf, pParticleEventInfo->strImportFilePath.c_str(), 256 );
|
||
m_pPropGrid->SetPropertyValueString( m_aPGID[ IMPORT_FILE_PATH ], caWBuf );
|
||
|
||
m_pPropGrid->SetPropertyValueLong( m_aPGID[ ID ], pParticleEventInfo->iID );
|
||
|
||
wxVariantData_EtVector3* pData = new wxVariantData_EtVector3(pParticleEventInfo->vPos);
|
||
wxVariant Value( pData, wxT("EtVector3") );
|
||
m_pPropGrid->SetPropertyValue( m_aPGID[ POSITION ], Value );
|
||
|
||
m_pPropGrid->SetPropertyValueDouble( m_aPGID[ START_TIME ], pParticleEventInfo->fStartTime );
|
||
//m_pPropGrid->SetPropertyValueDouble( m_aPGID[ SPEED ], pParticleEventInfo->fSpeed );
|
||
m_pPropGrid->SetPropertyValueDouble( m_aPGID[ TIME_LENGTH ], pParticleEventInfo->fTimeLength );
|
||
|
||
m_iMyEventInfoID = pParticleEventInfo->iID;
|
||
}
|
||
}
|
||
|
||
|
||
void CParticleEventProperty::OnShow( void )
|
||
{
|
||
int iSelectedObjectID = TOOL_DATA.GetSelectedObjectID();
|
||
if( wxNOT_FOUND != iSelectedObjectID )
|
||
{
|
||
_UpdateProp( iSelectedObjectID );
|
||
}
|
||
}
|
||
|
||
|
||
|
||
void CParticleEventProperty::_GetPropertyValue( EventInfo* pEventInfo )
|
||
{
|
||
ParticleEventInfo* pParticleEventInfo = static_cast<ParticleEventInfo*>(pEventInfo);
|
||
|
||
wxCSConv MBConv( wxFONTENCODING_CP949 );
|
||
char caBuf[ 256 ];
|
||
|
||
wxString strTemp = m_pPropGrid->GetPropertyValueAsString( m_aPGID[ PARTICLE_NAME ] );
|
||
ZeroMemory( caBuf, sizeof(caBuf) );
|
||
MBConv.WC2MB( caBuf, strTemp.c_str(), 256 );
|
||
pParticleEventInfo->strEventName.assign( caBuf );
|
||
|
||
strTemp = m_pPropGrid->GetPropertyValueAsString( m_aPGID[ IMPORT_FILE_PATH ] );
|
||
ZeroMemory( caBuf, sizeof(caBuf) );
|
||
MBConv.WC2MB( caBuf, strTemp.c_str(), 256 );
|
||
|
||
//pParticleEventInfo->fSpeed = (float)m_pPropGrid->GetPropertyValueAsDouble( m_aPGID[ SPEED ] );
|
||
|
||
// TODO: <20><><EFBFBD>Ӱ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ε<EFBFBD> <20>Ǿ<EFBFBD><C7BE>ٸ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ε<EFBFBD>
|
||
if( false == strTemp.IsEmpty() &&
|
||
pParticleEventInfo->strImportFilePath != caBuf )
|
||
{
|
||
// <20>н<EFBFBD><D0BD><EFBFBD> <20>߶<EFBFBD><DFB6><EFBFBD> <20><><EFBFBD><EFBFBD> <20≯<EFBFBD>.Ȯ<><C8AE><EFBFBD>ڵ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||
char caFileName[ MAX_PATH ];
|
||
char caFileExt[ 32 ];
|
||
_splitpath_s( caBuf, NULL, 0, NULL, 0, caFileName, MAX_PATH, caFileExt, 32 );
|
||
|
||
pParticleEventInfo->strImportFileName.assign( caFileName ).append( caFileExt );
|
||
pParticleEventInfo->strImportFilePath.assign( caBuf );
|
||
|
||
if( -1 != pParticleEventInfo->iParticleDataIndex )
|
||
EternityEngine::DeleteParticleData( pParticleEventInfo->iParticleDataIndex );
|
||
|
||
pParticleEventInfo->iParticleDataIndex = EternityEngine::LoadParticleData( pParticleEventInfo->strImportFileName.c_str() );
|
||
if( -1 == pParticleEventInfo->iParticleDataIndex )
|
||
{
|
||
wxString strMsg;
|
||
strMsg.Printf( wxT("Can't find %s in resource path."), strTemp.c_str() );
|
||
wxMessageBox( strMsg, wxT("Particle Data Load Failed!"), wxOK | wxCENTRE | wxICON_ERROR );
|
||
}
|
||
|
||
// <20>ð<EFBFBD> <20><><EFBFBD>̵<EFBFBD> <20><><EFBFBD><EFBFBD>.
|
||
EtBillboardEffectHandle hParticle = EternityEngine::CreateBillboardEffect( pParticleEventInfo->iParticleDataIndex, NULL );
|
||
EtBillboardEffectDataHandle hData = hParticle->GetBillboardEffectData();
|
||
|
||
// <20><>ƼŬ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ÿ<><C5B8><EFBFBD><EFBFBD> <20><> <20><>ƼŬ<C6BC><C5AC> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ÿ<><C5B8><EFBFBD>̹Ƿ<CCB9> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ְ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ᱹ <20><>ƼŬ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ÿ<><C5B8><EFBFBD><EFBFBD> <20><> <20>谡 <20>ȴ<EFBFBD>.
|
||
pParticleEventInfo->fTimeLength = (hData->GetMaxBillboardEffectLife()*2 / pParticleEventInfo->fSpeed);
|
||
m_pPropGrid->SetPropertyValueDouble( m_aPGID[ TIME_LENGTH ], pParticleEventInfo->fTimeLength );
|
||
hData->Release();
|
||
hParticle->Release();
|
||
}
|
||
else
|
||
pParticleEventInfo->fTimeLength = 0.0f;
|
||
|
||
pParticleEventInfo->strImportFilePath.assign( caBuf );
|
||
|
||
pParticleEventInfo->iID = m_pPropGrid->GetPropertyValueAsLong( m_aPGID[ ID ] );
|
||
|
||
wxVariant value = m_pPropGrid->GetPropertyValue( m_aPGID[ POSITION ] );
|
||
wxVariantData_EtVector3* pData = static_cast<wxVariantData_EtVector3*>(value.GetData());
|
||
const EtVector3 vPos = pData->GetValue();
|
||
pParticleEventInfo->vPos = vPos;
|
||
|
||
pParticleEventInfo->fStartTime = m_pPropGrid->GetPropertyValueAsDouble( m_aPGID[ START_TIME ] );
|
||
//pParticleEventInfo->fUnit = 10.0f;
|
||
}
|
||
|
||
|
||
|
||
void CParticleEventProperty::OnPropertyChanged( wxPropertyGridEvent& PGEvent )
|
||
{
|
||
const EventInfo* pParticleEvent = TOOL_DATA.GetEventInfoByID( m_iMyEventInfoID );
|
||
EventInfo* pNewParticleEvent = pParticleEvent->clone();
|
||
|
||
_GetPropertyValue( pNewParticleEvent );
|
||
|
||
CEventPropChange EventChange( &TOOL_DATA, pNewParticleEvent );
|
||
TOOL_DATA.RunCommand( &EventChange );
|
||
|
||
delete pNewParticleEvent;
|
||
}
|
||
|
||
|
||
void CParticleEventProperty::CommandPerformed( ICommand* pCommand )
|
||
{
|
||
// <20>ڽ<EFBFBD><DABD><EFBFBD> id <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||
const EventInfo* pMyEventInfo = TOOL_DATA.GetEventInfoByID( m_iMyEventInfoID );
|
||
if( NULL == pMyEventInfo )
|
||
{
|
||
m_pPropGrid->Show( false );
|
||
}
|
||
else
|
||
{
|
||
switch( pCommand->GetTypeID() )
|
||
{
|
||
case CMD_UPDATE_VIEW:
|
||
_UpdateProp( m_iMyEventInfoID );
|
||
break;
|
||
|
||
case CMD_EVENT_PROP_CHANGE:
|
||
_UpdateProp( m_iMyEventInfoID );
|
||
break;
|
||
|
||
// <20><><EFBFBD>Ͱ<EFBFBD> <20>߰<EFBFBD><DFB0><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ
|
||
case CMD_REGISTER_RES:
|
||
_UpdateProp( m_iMyEventInfoID );
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
// TODO: ȣ<><C8A3><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD> <20>κ<EFBFBD> <20>ݵ<EFBFBD><DDB5><EFBFBD> <20>ڵ<EFBFBD><DAB5>ؾ<EFBFBD><D8BE><EFBFBD>~ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>~
|
||
void CParticleEventProperty::ClearTempData( void )
|
||
{
|
||
m_iMyEventInfoID = -1;
|
||
} |