#include "StdAfx.h" #include "VectorProperty.h" #include "ParticleEventProperty.h" #include "CommandSet.h" #include "ToolData.h" #include 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( 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(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: »õ·Ó°Ô ÆÄÀÏÀÌ ·Îµù µÇ¾ú´Ù¸é ÆÄÀÏÀ» ½ÇÁ¦·Î ·Îµù if( false == strTemp.IsEmpty() && pParticleEventInfo->strImportFilePath != caBuf ) { // ÆÐ½º¸¦ Àß¶ó¼­ ÆÄÀÏ À̸§.È®ÀåÀÚµµ ÀúÀå 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 ); } // ½Ã°£ ±æÀ̵µ ¼ÂÆÃ. EtBillboardEffectHandle hParticle = EternityEngine::CreateBillboardEffect( pParticleEventInfo->iParticleDataIndex, NULL ); EtBillboardEffectDataHandle hData = hParticle->GetBillboardEffectData(); // ÆÄƼŬ ¶óÀÌÇÁ ŸÀÓÀº °¢ ÆÄƼŬÀÇ ¶óÀÌÇÁ ŸÀÓÀ̹ǷΠ¸¶Áö¸·¿¡ »ý¼ºµÈ ¾Ö°¡ »ç¶óÁö±â±îÁö´Â °á±¹ ÆÄƼŬ ¶óÀÌÇÁ ŸÀÓÀÇ µÎ ¹è°¡ µÈ´Ù. 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(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 ) { // ÀÚ½ÅÀÇ id °¡ »ç¶óÁö¸é ¼û±ä´Ù. 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; // ¾×ÅͰ¡ Ãß°¡µÈ °æ¿ì ¾×ÅÍ ¸®½ºÆ®¸¦ ¾÷µ¥ÀÌÆ® case CMD_REGISTER_RES: _UpdateProp( m_iMyEventInfoID ); break; } } } // TODO: È£ÃâÇØÁÖ´Â ºÎºÐ ¹Ýµå½Ã ÄÚµùÇØ¾ßÇÔ~ ¾ÆÁ÷ ¾øÀ½~ void CParticleEventProperty::ClearTempData( void ) { m_iMyEventInfoID = -1; }