//---------------------------------------------------------------------------------------- bool ZoneListWidget::OnDragEnter() { QList<QListWidgetItem*> selected = listWidget->selectedItems(); if(selected.size()) { QString stxt = selected[0]->text(); mDragData.ObjectType = "Modular Zone Object"; OgitorsPropertyValue pvalue; mDragData.Parameters["init"] = EMPTY_PROPERTY_VALUE; pvalue.propType = PROP_INT; pvalue.val = Ogre::Any(selected[0]->data(Qt::UserRole).toInt()); mDragData.Parameters["zonetemplate"] = pvalue; CBaseEditor *parent = OgitorsRoot::getSingletonPtr()->GetSceneManagerEditor(); CBaseEditorFactory *factory = OgitorsRoot::getSingletonPtr()->GetEditorObjectFactory("Modular Zone Object"); mDragData.Object = factory->CreateObject(&parent, mDragData.Parameters); dynamic_cast<ModularZoneEditor*>(mDragData.Object)->mDragging = true; mDragData.Object->load(); static_cast<ModularZoneEditor*>(mDragData.Object)->getZoneMesh()->setMaterialName("scbMATWIREFRAME"); static_cast<ModularZoneEditor*>(mDragData.Object)->getZoneMesh()->setQueryFlags(0); return true; } return false; }
//---------------------------------------------------------------------------------------- bool ObjectsViewWidget::OnDragEnter() { mDragData.Object = 0; mDragData.Parameters.clear(); QList<QListWidgetItem*> selected = listWidget->selectedItems(); if(selected.size()) { QString stxt = selected[0]->text(); CBaseEditorFactory *factory = OgitorsRoot::getSingletonPtr()->GetEditorObjectFactory(stxt.toStdString() + " Object"); if(!factory) return false; mDragData.ObjectType = factory->mTypeName; Ogre::String placeholder = ""; if(factory->mRequirePlacement) placeholder = factory->GetPlaceHolderName(); if(placeholder == "") return true; OgitorsPropertyValue pvalue; mDragData.Parameters["init"] = EMPTY_PROPERTY_VALUE; pvalue.propType = PROP_STRING; pvalue.val = Ogre::Any(placeholder); mDragData.Parameters["meshfile"] = pvalue; pvalue.propType = PROP_VECTOR3; pvalue.val = Ogre::Any(Ogre::Vector3(999999,999999,999999)); mDragData.Parameters["position"] = pvalue; CBaseEditor *parent = OgitorsRoot::getSingletonPtr()->GetSceneManagerEditor(); CBaseEditorFactory *entityfactory = OgitorsRoot::getSingletonPtr()->GetEditorObjectFactory("Entity Object"); mDragData.Object = entityfactory->CreateObject(&parent, mDragData.Parameters); mDragData.Object->load(); static_cast<Ogre::Entity*>(mDragData.Object->getHandle())->setMaterialName("scbMATWIREFRAME"); static_cast<Ogre::Entity*>(mDragData.Object->getHandle())->setQueryFlags(0); return true; } return false; }
//--------------------------------------------------------------------------------- bool OgitorsClipboardManager::isTemplateInstantiable(const Ogre::String& templatename) { ObjectTemplateMap::const_iterator it; it = mGeneralTemplates.find(templatename); if(it == mGeneralTemplates.end()) { it = mProjectTemplates.find(templatename); if(it == mProjectTemplates.end()) return false; } if(it->second.size() == 0) return false; CBaseEditorFactory *factory = OgitorsRoot::getSingletonPtr()->GetEditorObjectFactory(it->second[0].mTypeName); if(!factory) return false; return factory->CanInstantiate(); }