Example #1
0
void WXEffectEditDialog::OnDelElementButtonDown(wxCommandEvent &e)
{
	wxPGId id = mPropertiesViewer->GetSelectedProperty();

	if ( true == id.IsOk() && false == mPropertiesViewer->IsPropertyEnabled(id) )
	{
		unsigned short index = mPropertiesViewer->GetPropertyIndex(id);
		
		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 (index < effect->getNumElements())
			{
				// 现在做的是直接对模板的修改,所以要修改全部的同个模板的特效
				if ( effect->getTemplateName() == mEffect->getTemplateName() )
				{
					effect->destroyElement(index);
				}

				mPropertiesViewer->Delete(id);
			}
		}
	}
}
Example #2
0
void WXEffectEditDialog::OnAddElementButtonDown(wxCommandEvent &e)
{
	AddEffectElementDialog *dlg = new AddEffectElementDialog(this, wxID_ANY,
		_("特效元素类型"));

	bool ok = (dlg->ShowModal() == wxID_OK);
	if(ok)
	{
		Ogre::String type = wxDynamicCast(dlg->FindWindow(feID_COMBOCTRL_ELEMENT_TYPE),wxComboBox)->GetValue().c_str();

		if ( false == type.empty() )
		{
			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() )
				{
					effect->addElement(type);
				}
			}

			InitEffectDialog(mEffect, mSceneManipulator);
		}		
	}

	dlg->Destroy();
}
Example #3
0
void WXEffectEditDialog::OnSaveAsButtonDown(wxCommandEvent &e)
{
	SaveAsEffectDialog *dlg = new SaveAsEffectDialog(this, wxID_ANY,
		_("保存特效"), mEffect);

	bool ok = (dlg->ShowModal() == wxID_OK);
	if(ok)
	{
	//	bool append = true;
		// 如果模板名称不一样了,说明是要存成一个新的模板
		/*if ( dlg->mTextCtrl->GetValue().c_str() == mEffect->getTemplateName() )
		{
			append = false;
		}*/
		Ogre::StringVector templates;

		const Ogre::String fileName = dlg->mComboBox->GetValue().c_str();
		const Ogre::String templateName = dlg->mTextCtrl->GetValue().c_str();

		Ogre::StringVector strings = Ogre::StringUtil::split( fileName, "." );
		if ( (strings.size() != 2) || (strings[1] != "effect") )
		{
			wxMessageBox ( _("The Script File Name Is Wrong!") );
			return;
		}

		Fairy::EffectManager::getSingleton().getTemplatesFromScriptFile(fileName, templates);

		std::ofstream outFile;

		Ogre::String pathFileName = EFFECT_PATH+fileName;
		outFile.open ( pathFileName.c_str(), std::ios::out | std::ios::trunc ); // append to file

		if (!outFile.is_open())
		{
			return;
		}
		
		bool newTemplate = true;

		// 把所有的模板都写入该文件中
		for ( size_t i=0; i<templates.size(); ++i )
		{
		//	if (templates[i] != mEffect->getTemplateName())
			///{
				Fairy::Effect *effect = Fairy::EffectManager::getSingleton().getTemplate(templates[i]);
				assert (effect);

				if (effect->getTemplateName() == dlg->mTextCtrl->GetValue().c_str())
				{
					saveEffect(mEffect, dlg->mTextCtrl->GetValue().c_str(), outFile );

					*effect = *mEffect;

					newTemplate = false;
				}
				else
					saveEffect(effect, effect->getTemplateName(), outFile);
		
		}


		if (newTemplate)
		{
			saveEffect(mEffect, templateName, outFile );
			mEffect->setTemplateName(templateName);

			// 刷新EffectManager中的模板内容
			Fairy::Effect *effect = Fairy::EffectManager::getSingleton().createEffectTemplate(mEffect->getTemplateName());

			*effect = *mEffect;

			Fairy::EffectManager::getSingleton().addToEffectTemplateScriptFileMap(templateName, fileName);
		}

		outFile.close();
	}

	dlg->Destroy();
}
Example #4
0
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);
                }
            }
        }
    }
}