const char* IPropertySet::GetSTRING(const void* pData, int nIndex) { assert(nIndex>=0 && nIndex<PropertyCount()); if(nIndex<0 || nIndex>=PropertyCount()) return NULL; IProperty* pInfo = GetProperty(nIndex); assert(pInfo->GetType()==PROPERTY_TYPE_STRING); if(pInfo->GetType()!=PROPERTY_TYPE_STRING) return NULL; return (const char*)pData + pInfo->GetOffset(); }
float IPropertySet::GetFLOAT(const void* pData, int nIndex) { assert(nIndex>=0 && nIndex<PropertyCount()); if(nIndex<0 || nIndex>=PropertyCount()) return -1; IProperty* pInfo = GetProperty(nIndex); assert(pInfo->GetType()==PROPERTY_TYPE_FLOAT); if(pInfo->GetType()!=PROPERTY_TYPE_FLOAT) return -1; return *((float*)((char*)pData + pInfo->GetOffset())); }
unsigned int IPropertySet::GetDWORD(const void* pData, int nIndex) { assert(nIndex>=0 && nIndex<PropertyCount()); if(nIndex<0 || nIndex>=PropertyCount()) return -1; IProperty* pInfo = GetProperty(nIndex); assert(pInfo->GetType()==PROPERTY_TYPE_DWORD); if(pInfo->GetType()!=PROPERTY_TYPE_DWORD) return -1; return *((unsigned int*)((char*)pData + pInfo->GetOffset())); }
bool IPropertySet::SetValue(void* pData, int nIndex, char Value) { assert(nIndex>=0 && nIndex<PropertyCount()); if(nIndex<0 || nIndex>=PropertyCount()) return false; IProperty* pInfo = GetProperty(nIndex); assert(pInfo->GetType()==PROPERTY_TYPE_CHAR); if(pInfo->GetType()!=PROPERTY_TYPE_CHAR) return false; *((char*)((char*)pData + pInfo->GetOffset())) = Value; return true; }
bool IPropertySet::SetValue(void* pData, int nIndex, const char* Value) { assert(nIndex>=0 && nIndex<PropertyCount()); if(nIndex<0 || nIndex>=PropertyCount()) return false; IProperty* pInfo = GetProperty(nIndex); assert(pInfo->GetType()==PROPERTY_TYPE_FLOAT); if(pInfo->GetType()!=PROPERTY_TYPE_FLOAT) return false; unsigned int len = strlen(Value); assert(len<=pInfo->GetSize()); if(len>pInfo->GetSize()) return false; memcpy((char*)pData+pInfo->GetOffset(), Value, len+1); return true; }
RESULT Animation::BindTo( IProperty& property ) { RESULT rval = S_OK; if (property.IsNull()) { SAFE_DELETE(m_pTargetProperty); m_isBoundToProperty = false; Stop(); goto Exit; } if (property.GetType() != m_propertyType) { RETAILMSG(ZONE_ERROR, "ERROR: Animation::BindTo( \"%s\", 0x%x ): target Property type 0x%x incorrect for this Animation", m_name.c_str(), (UINT32)&property, property.GetType()); rval = E_INVALID_OPERATION; goto Exit; } SAFE_DELETE(m_pTargetProperty); m_pTargetProperty = property.Clone(); m_isBoundToProperty = true; if (m_relativeToCurrentState) { // Save the target Property into our m_startingValue. // Keyframes will be interpolated, then added to m_startingValue to produce the final result. switch (m_keyFrameType) { case KEYFRAME_TYPE_UINT32: m_startingValue.SetIntValue( m_pTargetProperty->GetInteger() ); break; case KEYFRAME_TYPE_FLOAT: m_startingValue.SetFloatValue( m_pTargetProperty->GetFloat() ); break; case KEYFRAME_TYPE_VEC2: m_startingValue.SetVec2Value( m_pTargetProperty->GetVec2() ); break; case KEYFRAME_TYPE_VEC3: m_startingValue.SetVec3Value( m_pTargetProperty->GetVec3() ); break; case KEYFRAME_TYPE_VEC4: m_startingValue.SetVec4Value( m_pTargetProperty->GetVec4() ); break; case KEYFRAME_TYPE_COLOR: m_startingValue.SetColorValue( m_pTargetProperty->GetColor() ); break; default: DEBUGCHK(0); break; } } Exit: return rval; }
bool wxArrayPropertyEditor::OnEvent( wxPropertyGrid* propGrid, wxPGProperty* property, wxWindow* ctrl, wxEvent& event ) const { if ( event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED ) { wxPGMultiButton* buttons = (wxPGMultiButton*) propGrid->GetEditorControlSecondary(); wxArrayProperty* pArrayProperty = static_cast<wxArrayProperty*>(property); if(event.GetId() == buttons->GetButtonId(0)) // + - add element { if(pArrayProperty->GetMaxElems() < 0 || pArrayProperty->GetChildCount() < u32(pArrayProperty->GetMaxElems())) { // determine new property name IProperty* pNewProperty = pArrayProperty->GetSubPropertyTemplate(); std::stringstream ss; ss << "[" << property->GetChildCount() << "]"; pNewProperty->SetName(ss.str()); // create a new wxPGProperty out of it and insert it wxPGProperty* pWxProperty = PropertyList::GetWxProperty(pNewProperty, pArrayProperty->GetParent()); property->InsertChild(-1, pWxProperty); if(pNewProperty->GetType() == PT_Reference) { pArrayProperty->GetParent()->FillArrayProperties(pNewProperty, pWxProperty); } pArrayProperty->UpdateValue(); propGrid->RefreshProperty(property); // update the corresponding property in the property stream wxPropertyGridEvent PGEvent; PGEvent.SetProperty(property); pArrayProperty->SetEventType(wxArrayProperty::E_PropertyAdded); pArrayProperty->GetParent()->OnPropertyGridChange(PGEvent); } } else if(event.GetId() == buttons->GetButtonId(1)) // - remove element { int childCount = property->GetChildCount(); if(childCount > 0) { // remove the wx property wxPGProperty* pChild = property->Item(childCount-1); propGrid->DeleteProperty(pChild); pArrayProperty->UpdateValue(); propGrid->RefreshProperty(property); // update the corresponding property in the property stream wxPropertyGridEvent PGEvent; PGEvent.SetProperty(property); pArrayProperty->SetEventType(wxArrayProperty::E_PropertyRemoved); pArrayProperty->GetParent()->OnPropertyGridChange(PGEvent); } } return true; } else { return wxPGTextCtrlEditor::OnEvent(propGrid, property, ctrl, event); } }