wxPGProperty* WXEffectEditDialog::CreateProperty(const Ogre::ParameterDef& propertyDef, Ogre::StringInterface *basic) { wxPGProperty* property = NULL; wxString name = propertyDef.name.c_str(); Ogre::String value = basic->getParameter(name.c_str()); Ogre::ParameterType paraType = propertyDef.paramType; switch ( paraType ) { case Ogre::PT_COLOURVALUE: property = wxFairyColourProperty(name, name, colorConverter(value)); break; case Ogre::PT_STRING: { wxPGConstants* constants = PopulateConstants(propertyDef.name); if (constants) { // 创建出combobox property = wxEnumProperty(name, name, *constants); // 设置成当前这个参数的值 property->SetValueFromString(value.c_str(),0); } break; } case Ogre::PT_REAL: { property = wxFloatProperty(name, name, Ogre::StringConverter::parseReal(value)); break; } default: property = wxStringProperty(name, name, value.c_str()); break; } assert (property); return property; }
wxPGProperty* FairySkillEditDialog::CreateProperty(const Ogre::ParameterDef& propertyDef, Ogre::String &value) { wxPGProperty* property = NULL; wxString name = propertyDef.name.c_str(); Ogre::ParameterType paraType = propertyDef.paramType; switch ( paraType ) { case Ogre::PT_COLOURVALUE: property = wxFairyColourProperty(name, name, colorConverter(value)); break; case Ogre::PT_STRING: { if (name == "HitTime") { Ogre::String newValue(""); for (unsigned short i=0; i<mSkill->getNumHitTimes(); ++i) { float time = mSkill->getHitTime(i); newValue += Ogre::StringConverter::toString( (time * mDObject->getCurrentAnimationLength() * mFramePerSecond) ); newValue += " "; } property = wxStringProperty(name, name, newValue.c_str()); } else if (name == "BreakTime") { Ogre::String newValue(""); for (unsigned short i=0; i<mSkill->getNumBreakTimes(); ++i) { float time = mSkill->getBreakTime(i); newValue += Ogre::StringConverter::toString( (time * mDObject->getCurrentAnimationLength() * mFramePerSecond) ); newValue += " "; } property = wxStringProperty(name, name, newValue.c_str()); } else if (name == "ShakeTime") { Ogre::String newValue(""); for (unsigned short i=0; i<mSkill->getNumShakeTimes(); ++i) { float time = mSkill->getShakeTime(i); newValue += Ogre::StringConverter::toString( (time * mDObject->getCurrentAnimationLength() * mFramePerSecond) ); newValue += " "; } property = wxStringProperty(name, name, newValue.c_str()); } else { wxPGConstants* constants = PopulateConstants(propertyDef.name); if (constants) { // 创建出combobox property = wxEnumProperty(name, name, *constants); // 设置成当前这个参数的值 property->SetValueFromString(value.c_str()); } else { property = wxStringProperty(name, name, value.c_str()); } } break; } case Ogre::PT_REAL: { if (name == "AttachTime") { float inputValue = Ogre::StringConverter::parseReal(value); if (inputValue >= 0.0f && inputValue <= 1.0f) value = Ogre::StringConverter::toString( (inputValue * mDObject->getCurrentAnimationLength() * mFramePerSecond) ); } property = wxFloatProperty(name, name, Ogre::StringConverter::parseReal(value)); break; } case Ogre::PT_BOOL: { size_t id = reinterpret_cast<size_t>(&name); wxPGConstants* constants = wxPropertyGrid::GetConstantsArray(id); if (!constants) { constants = wxPropertyGrid::CreateConstantsArray(id); constants->Add("true"); constants->Add("false"); registerConstants(constants); } if (constants) { // 创建出combobox property = wxEnumProperty(name, name, *constants); // 设置成当前这个参数的值 property->SetValueFromString(value.c_str()); } break; } default: property = wxStringProperty(name, name, value.c_str()); break; } assert (property); return property; }