extern "C" LUALIB_API int luaopen_RtAudio_core (lua_State* L) { #if defined(USE_SNDFILE) luaL_newmetatable(L, LIBSNDFILE); /* metatable.__index = metatable */ lua_pushvalue(L, -1); /* duplicates the metatable */ lua_setfield(L, -2, "__index"); luaL_register(L, NULL, funcs_libsndfile); #endif //luaL_register(L, "RtAudio", funcs); luaL_newmetatable(L, "DAC"); /* metatable.__index = metatable */ lua_pushvalue(L, -1); /* duplicates the metatable */ lua_setfield(L, -2, "__index"); luaL_register(L, NULL, funcs); luaL_register(L, "DAC", thislib); registerConstants(L, rtaudio_Const); registerConstants(L, rtaudio_formats); #if defined(USE_SNDFILE) lua_newtable(L); //RtAudio, table registerConstants(L, libsndfile_const); lua_pushstring(L, "libsndfile");//RtAudio, table libsndfile lua_pushvalue(L, -2);//RtAudio, table libsndfile table lua_settable(L,-4);//RtAudio, table lua_pop(L, 1);//RtAudio #endif return 1; }
wxPGConstants * FairySkillEditDialog::PopulateConstants(const Ogre::String& name) { size_t id = reinterpret_cast<size_t>(&name); wxPGConstants* constants = wxPropertyGrid::GetConstantsArray(id); if (constants) { for (std::list<wxPGConstants*>::iterator it = mConstantList.begin(); it != mConstantList.end(); ++it) { if (constants == *it) { if (constants->UnRef()) delete constants; mConstantList.erase(it); break; } } } // if (!constants) // { constants = wxPropertyGrid::CreateConstantsArray(id); if ( name == "Animation" ) { // 第一个为空,表示设置这个元素的材质是用原mesh的材质 for ( unsigned short i = 0; i < mDObject->getSkeletonAnimationCount(); ++i ) { Ogre::Animation *anim = mDObject->getSkeletonAnimation(i); if ( anim ) { constants->Add(anim->getName().c_str()); } } } else if ( name == "EffectTemplateName" ) { WX::EffectManager::EffectTemplateIterator it = WX::EffectManager::getSingleton().getEffectTemplateIterator(); while ( it.hasMoreElements() ) { constants->Add(it.peekNextKey().c_str()); it.moveNext(); } } else if ( name == "AttachPoint" ) { for ( unsigned short i=0; i<mDObject->getNumBones(); ++i ) { constants->Add(mDObject->getBoneName(i).c_str()); } Ogre::StringVector locatorNames; mDObject->getLocatorNames(locatorNames); for ( size_t i=0; i<locatorNames.size(); ++i ) { constants->Add(locatorNames[i].c_str()); } } else if ( name == "Material" ) { typedef std::list<Ogre::String> MaterialFileNameList; MaterialFileNameList materialFileNameList; Ogre::FileInfoListPtr fileInfoList = Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo( Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, "*.material"); for (Ogre::FileInfoList::const_iterator it = fileInfoList->begin(); it != fileInfoList->end(); ++it) { if ( it->archive->getName() == MATERIAL_PATH) { materialFileNameList.push_back(it->filename); } } Ogre::ResourceManager::ResourceMapIterator resourceMapIterator = Ogre::MaterialManager::getSingleton().getResourceIterator(); while ( resourceMapIterator.hasMoreElements() ) { Ogre::String matName = resourceMapIterator.peekNextValue()->getName(); for ( MaterialFileNameList::iterator i = materialFileNameList.begin(); i != materialFileNameList.end(); ++i ) { if ( *i == resourceMapIterator.peekNextValue()->getOrigin() ) { constants->Add(matName.c_str()); break; } } resourceMapIterator.moveNext(); } } else if ( name == "SoundName" ) { constants->Add("NULL"); //----------------------------------- //得到所有文件名 if (wxGetApp().funcEnumSoundFile) { int nIndex = 0; do { char szTemp[100]; int id; bool bHave = wxGetApp().funcEnumSoundFile(nIndex++, szTemp, 100, id); if(!bHave) break; constants->Add(szTemp); }while(true); } } registerConstants(constants); //} return constants; }
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; }
wxPGConstants * WXEffectEditDialog::PopulateConstants(const Ogre::String& type) { size_t id = reinterpret_cast<size_t>(&type); wxPGConstants* constants = wxPropertyGrid::GetConstantsArray(id); if (constants) { for (std::list<wxPGConstants*>::iterator it = mConstantList.begin(); it != mConstantList.end(); ++it) { if (constants == *it) { if (constants->UnRef()) delete constants; mConstantList.erase(it); break; } } } // if (!constants) // { constants = wxPropertyGrid::CreateConstantsArray(id); if ( type == "Material" ) { typedef std::list<Ogre::String> MaterialFileNameList; MaterialFileNameList materialFileNameList; Ogre::FileInfoListPtr fileInfoList = Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo( Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, "*.material"); for (Ogre::FileInfoList::const_iterator it = fileInfoList->begin(); it != fileInfoList->end(); ++it) { if ( it->archive->getName() == EFFECT_PATH) { materialFileNameList.push_back(it->filename); } } // 第一个为空,表示设置这个元素的材质是用原mesh的材质 constants->Add("none"); Ogre::ResourceManager::ResourceMapIterator resourceMapIterator = Ogre::MaterialManager::getSingleton().getResourceIterator(); while ( resourceMapIterator.hasMoreElements() ) { Ogre::String matName = resourceMapIterator.peekNextValue()->getName(); for ( MaterialFileNameList::iterator i = materialFileNameList.begin(); i != materialFileNameList.end(); ++i ) { if ( *i == resourceMapIterator.peekNextValue()->getOrigin() ) { constants->Add(matName.c_str()); break; } } resourceMapIterator.moveNext(); } } else if ( type == "MeshName" ) { constants->Add("none"); Ogre::FileInfoListPtr fileInfoList = Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo( Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, "*.mesh"); for (Ogre::FileInfoList::const_iterator it = fileInfoList->begin(); it != fileInfoList->end(); ++it) { if ( it->archive->getName() == EFFECT_PATH) { const Fairy::String& name = it->filename; constants->Add(name.c_str()); } } } else if ( type == "ParticleSystem" ) { Ogre::ParticleSystemManager::ParticleSystemTemplateIterator iterator = Ogre::ParticleSystemManager::getSingleton().getTemplateIterator(); while ( iterator.hasMoreElements() ) { // 获取到粒子系统的名称 Ogre::String parName = iterator.peekNextKey(); constants->Add(parName.c_str()); // 使iterator往后移 iterator.moveNext(); } } registerConstants(constants); // } return constants; }