//----------------------------------------------------------------------------- void Property::OnChange (wxPropertyGridEvent &event) { wxPGProperty *id = event.GetProperty(); PX2_UNUSED(id); const wxString &name = event.GetPropertyName(); std::string stdName = std::string(name); wxVariant variant = event.GetPropertyValue(); if (name != wxString(mName.c_str())) return; if (variant.IsNull()) return; if (!mData) return; if (mType == PT_INT) { *((int*)mData) = wxPGVariantToInt(variant); } else if (mType == PT_FLOAT) { double value = 0; wxPGVariantToDouble(variant, &value); *((float*)mData) = (float)value; } else if (mType == PT_BOOL) { bool value = (bool)(event.GetPropertyValueAsBool()!=0); *((bool*)mData) = value; } else if (mType == PT_BOOLCHECK) { bool value = (bool)(event.GetPropertyValueAsBool()!=0); *((bool*)mData) = value; } else if (PT_COLOR3FLOAT3 == mType) { wxString strColor = event.GetPropertyValueAsString(); wxColor color = StringToColor(strColor); Float3 float3Color((float)color.Red()/255.0f, (float)color.Green()/255.0f, (float)color.Blue()/255.0f); *((Float3*)mData) = float3Color; } else if (PT_FLOAT3 == mType) { *((Float3*)mData) = Float3FromVariant(variant); } else if (mType == PT_STRING) { std::string value; wxString wxValue = event.GetPropertyValueAsString(); value = std::string(wxValue.ToAscii()); *((std::string*)mData) = value; } }
void TechniquePropertyGridPage::propertyChanged(wxPropertyGridEvent& event) { wxPGId id = event.GetProperty(); if(id == mNameId) { mController->setName(event.GetPropertyValueAsString().c_str()); } else if(id == mSchemeNameId) { mController->setSchemeName(event.GetPropertyValueAsString().c_str()); } else if(id = mLodIndexId) { mController->setLodIndex(event.GetPropertyValueAsInt()); } }
void ObjectPropertyEditor::OnPropertyChanged(wxPropertyGridEvent& e) { // Skip parent properties if (e.GetPropertyPtr()->GetParentingType() != 0) return; // Skip if no current selected object Fairy::ObjectPtr object = mCurrentObject.lock(); if (!object) return; Ogre::String propertyName = AS_STRING(e.GetPropertyName()); Ogre::String propertyValue = AS_STRING(e.GetPropertyValueAsString()); if(propertyName == "position" || propertyName == "scale") { Ogre::Vector3 vValue = Ogre::StringConverter::parseVector3(propertyValue); object->setProperty(propertyName,vValue); } else if(propertyName == "orientation") { Ogre::Quaternion qValue = Ogre::StringConverter::parseQuaternion(propertyValue); object->setProperty(propertyName,qValue); } else if(propertyName == "actor name") { m_Frame->ClearAllSelectorObject(); m_Frame->GetActorSettingEditor()->SetCurrentObject(Ogre::String(propertyValue.c_str())); return; } mPropertiesViewer->Freeze(); const Fairy::PropertyList& properties = object->getProperties(); for (Fairy::PropertyList::const_iterator it = properties.begin(); it != properties.end(); ++it) { const Fairy::PropertyDef& propertyDef = *it; Fairy::uint propertyFlags = object->getPropertyFlags(propertyDef.name); wxPGId id = mPropertiesViewer->GetPropertyByName(propertyDef.name.c_str()); assert(id.IsOk()); if (!id.IsOk()) continue; if (propertyFlags & Fairy::PF_READONLY) { if (mPropertiesViewer->IsPropertyEnabled(id)) mPropertiesViewer->DisableProperty(id); } else { if (!mPropertiesViewer->IsPropertyEnabled(id)) mPropertiesViewer->EnableProperty(id); } } mPropertiesViewer->Thaw(); }
void ObjectPropertyEditor::OnPropertyChanged(wxPropertyGridEvent& e) { // Skip parent properties if (e.GetPropertyPtr()->GetParentingType() != 0) return; // Skip if no current selected object WX::ObjectPtr object = mCurrentObject.lock(); if (!object) return; WX::String propertyName = AS_STRING(e.GetPropertyName()); WX::String propertyValue = AS_STRING(e.GetPropertyValueAsString()); WX::Variant oldValue = object->getProperty(propertyName); object->setPropertyAsString(propertyName, propertyValue); mSceneManipulator->_fireObjectPropertyChanged(object, propertyName, this); WX::Variant newValue = object->getProperty(propertyName); WX::ModifyObjectPropertyOperator* op = new WX::ModifyObjectPropertyOperator(mSceneManipulator); op->add(object->getName(), propertyName, oldValue, newValue); mSceneManipulator->getOperatorManager()->addOperator(op); mPropertiesViewer->Freeze(); const WX::PropertyList& properties = object->getProperties(); for (WX::PropertyList::const_iterator it = properties.begin(); it != properties.end(); ++it) { const WX::PropertyDef& propertyDef = *it; WX::uint propertyFlags = object->getPropertyFlags(propertyDef.name); wxPGId id = mPropertiesViewer->GetPropertyByName(propertyDef.name.c_str()); assert(id.IsOk()); if (!id.IsOk()) continue; if (propertyFlags & WX::PF_READONLY) { if (mPropertiesViewer->IsPropertyEnabled(id)) mPropertiesViewer->DisableProperty(id); } else { if (!mPropertiesViewer->IsPropertyEnabled(id)) mPropertiesViewer->EnableProperty(id); } } mPropertiesViewer->Thaw(); }
void FairySkillEditDialog::OnPropertyChanged(wxPropertyGridEvent& e) { unsigned short numOfEffectInfos = mSkill->getNumAnimationEffectInfos(); unsigned short numOfRibbons = mSkill->getNumAnimationRibbons(); unsigned short numOfSounds = mSkill->getNumAnimationSounds(); unsigned short unmOfLights = mSkill->getNumAnimationSceneLightInfos(); // Skip parent properties if (e.GetPropertyPtr()->GetParentingType() != 0) return; wxPGId id = e.GetPropertyPtr()->GetId(); wxPGId parentId = mPropertiesViewer->GetPropertyParent(id); WX::String propertyName = e.GetPropertyName().c_str(); WX::String propertyValue = e.GetPropertyValueAsString().c_str(); if (propertyName == "AttachTime") { float inputValue = Ogre::StringConverter::parseReal(propertyValue); float outputTime = inputValue / ( mDObject->getCurrentAnimationLength() * mFramePerSecond ); if ( outputTime >= 1.0f ) { wxMessageBox(_("Wrong parameter!")); return; } propertyValue = Ogre::StringConverter::toString(outputTime); } else if (propertyName == "HitTime" || propertyName == "BreakTime" || propertyName == "ShakeTime") { Ogre::StringVector valueArray = Ogre::StringUtil::split(propertyValue); propertyValue.clear(); for (size_t i=0; i<valueArray.size(); ++i) { float inputValue = Ogre::StringConverter::parseReal(valueArray[i]); float outputTime = inputValue / ( mDObject->getCurrentAnimationLength() * mFramePerSecond ); if ( outputTime >= 1.0f ) { wxMessageBox(_("Wrong parameter!")); return; } propertyValue += Ogre::StringConverter::toString(outputTime); propertyValue += " "; } } unsigned short index = mPropertiesViewer->GetPropertyIndex(parentId); if ( index == 0 ) { mSkill->setParameter(propertyName, propertyValue); } else if ( index > 0 && index <= numOfEffectInfos ) { mSkill->getAnimationEffectInfo(index-1)->setParameter(propertyName, propertyValue); } else if ( index > numOfEffectInfos && index <= (numOfEffectInfos + numOfRibbons) ) { mSkill->getAnimationRibbon(index-numOfEffectInfos-1)->setParameter(propertyName, propertyValue); } else if ( index > numOfEffectInfos + numOfRibbons && index <= (numOfEffectInfos + numOfRibbons + numOfSounds) ) { mSkill->getAnimationSound(index-numOfEffectInfos-numOfRibbons-1)->setParameter(propertyName, propertyValue); } else if ( index > numOfEffectInfos + numOfRibbons + numOfSounds && index <= (numOfEffectInfos + numOfRibbons + numOfSounds + unmOfLights) ) { mSkill->getAnimationSceneLightInfo(index-numOfEffectInfos-numOfRibbons-numOfSounds-1)->setParameter(propertyName, propertyValue); } // 更新模板 WX::Skill *skill = WX::EffectManager::getSingleton().getSkill(mSkill->getSkillName()); *skill = *mSkill; }
void WXEffectEditDialog::OnPropertyChanged(wxPropertyGridEvent& e) { // Skip parent properties if (e.GetPropertyPtr()->GetParentingType() != 0) return; wxPGId id = e.GetPropertyPtr()->GetId(); wxPGId parentId = mPropertiesViewer->GetPropertyParent(id); const wxString &parentLabel = mPropertiesViewer->GetPropertyLabel(parentId); unsigned short index = mPropertiesViewer->GetPropertyIndex(parentId); Fairy::String propertyName = e.GetPropertyName().c_str(); Fairy::String propertyValue = e.GetPropertyValueAsString().c_str(); Fairy::Scene::ObjectsByTypeRange effects = mSceneManipulator->getSceneInfo()->findObjectsByType(Fairy::EffectObject::msType); for (Fairy::Scene::ObjectsByTypeIterator it = effects.first; it != effects.second; ++it) { const Fairy::ObjectPtr& object = *it; const Fairy::EffectObject* effectObject = static_cast<Fairy::EffectObject *>(object.get()); Fairy::Effect *effect = effectObject->getEffect(); assert (effect); // 现在做的是直接对模板的修改,所以要修改全部的同个模板的特效 if ( effect->getTemplateName() == mEffect->getTemplateName() ) { if (index < effect->getNumElements()) { Fairy::EffectElement *element = effect->getElement(index); assert (element); element->setParameter(propertyName, propertyValue); } else { effect->setParameter(propertyName, propertyValue); } } } // 更新当前的skill if (gEffectSettingGlobalData.mCurrentSkill) { for ( unsigned short i = 0; i < gEffectSettingGlobalData.mCurrentSkill->getNumAnimationEffectInfos(); ++i ) { Fairy::AnimationEffectInfo *effectInfo = gEffectSettingGlobalData.mCurrentSkill->getAnimationEffectInfo(i); assert (effectInfo); Fairy::Effect *effect = effectInfo->getEffect(); assert (effect); // 现在做的是直接对模板的修改,所以要修改全部的同个模板的特效 if ( effect->getTemplateName() == mEffect->getTemplateName() ) { if (index < effect->getNumElements()) { Fairy::EffectElement *element = effect->getElement(index); assert (element); element->setParameter(propertyName, propertyValue); } else { effect->setParameter(propertyName, propertyValue); } } } } }