/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ #include #include #include #include #include #include namespace AZ { namespace SceneAPI { namespace UI { AZ_CLASS_ALLOCATOR_IMPL_INTERNAL(IManifestVectorHandler, SystemAllocator, 0, template) template SerializeContext* IManifestVectorHandler::s_serializeContext = nullptr; template IManifestVectorHandler* IManifestVectorHandler::s_instance = nullptr; template QWidget* IManifestVectorHandler::CreateGUI(QWidget* parent) { if(IManifestVectorHandler::s_serializeContext) { ManifestVectorWidget* instance = aznew ManifestVectorWidget(IManifestVectorHandler::s_serializeContext, parent); connect(instance, &ManifestVectorWidget::valueChanged, this, [instance]() { EBUS_EVENT(AzToolsFramework::PropertyEditorGUIMessages::Bus, RequestWrite, instance); }); return instance; } else { return nullptr; } } template u32 IManifestVectorHandler::GetHandlerName() const { return AZ_CRC("ManifestVector", 0x895aa9aa); } template bool IManifestVectorHandler::AutoDelete() const { return false; } template void IManifestVectorHandler::ConsumeAttribute(ManifestVectorWidget* widget, u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName) { AZ_TraceContext("Attribute name", debugName); if (attrib == AZ_CRC("ObjectTypeName", 0x6559e0c0)) { AZStd::string name; if (attrValue->Read(name)) { widget->SetCollectionTypeName(name); } } else if (attrib == AZ_CRC("CollectionName", 0xbbc1c898)) { AZStd::string name; if (attrValue->Read(name)) { widget->SetCollectionName(name); } } // Sets the number of entries the user can add through this widget. It doesn't limit // the amount of entries that can be stored. else if (attrib == AZ_CRC("Cap", 0x993387b1)) { size_t cap; if (attrValue->Read(cap)) { widget->SetCapSize(cap); } } } template void IManifestVectorHandler::WriteGUIValuesIntoProperty(size_t /*index*/, ManifestVectorWidget* GUI, typename IManifestVectorHandler::property_t& instance, AzToolsFramework::InstanceDataNode* /*node*/) { instance.clear(); AZStd::vector > manifestVector = GUI->GetManifestVector(); for (auto& manifestObject : manifestVector) { instance.push_back(AZStd::static_pointer_cast(manifestObject)); } } template bool IManifestVectorHandler::ReadValuesIntoGUI(size_t /*index*/, ManifestVectorWidget* GUI, const typename IManifestVectorHandler::property_t& instance, AzToolsFramework::InstanceDataNode* node) { AzToolsFramework::InstanceDataNode* parentNode = node->GetParent(); if (parentNode && parentNode->GetClassMetadata() && parentNode->GetClassMetadata()->m_azRtti) { AZ_TraceContext("Parent UUID", parentNode->GetClassMetadata()->m_azRtti->GetTypeId()); if (parentNode->GetClassMetadata()->m_azRtti->IsTypeOf(DataTypes::IManifestObject::RTTI_Type())) { DataTypes::IManifestObject* owner = static_cast(parentNode->FirstInstance()); GUI->SetManifestVector(instance.begin(), instance.end(), owner); } else if (parentNode->GetClassMetadata()->m_azRtti->IsTypeOf(Containers::RuleContainer::RTTI_Type())) { AzToolsFramework::InstanceDataNode* manifestObject = parentNode->GetParent(); if (manifestObject && manifestObject->GetClassMetadata()->m_azRtti->IsTypeOf(DataTypes::IManifestObject::RTTI_Type())) { DataTypes::IManifestObject* owner = static_cast(manifestObject->FirstInstance()); GUI->SetManifestVector(instance.begin(), instance.end(), owner); } else { AZ_TracePrintf(Utilities::WarningWindow, "RuleContainer requires a ManifestObject parent."); } } else { AZ_TracePrintf(Utilities::WarningWindow, "ManifestVectorWidget requires a ManifestObject parent."); } } else { AZ_TracePrintf(Utilities::WarningWindow, "ManifestVectorWidget requires valid parent with RTTI data specified"); } return false; } template void IManifestVectorHandler::Register() { if (!IManifestVectorHandler::s_instance) { IManifestVectorHandler::s_instance = aznew IManifestVectorHandler(); EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, RegisterPropertyType, IManifestVectorHandler::s_instance); EBUS_EVENT_RESULT(s_serializeContext, AZ::ComponentApplicationBus, GetSerializeContext); AZ_Assert(s_serializeContext, "Serialization context not available"); } } template void IManifestVectorHandler::Unregister() { if (IManifestVectorHandler::s_instance) { EBUS_EVENT(AzToolsFramework::PropertyTypeRegistrationMessages::Bus, UnregisterPropertyType, IManifestVectorHandler::s_instance); delete IManifestVectorHandler::s_instance; IManifestVectorHandler::s_instance = nullptr; } } void ManifestVectorHandler::Register() { IManifestVectorHandler::Register(); IManifestVectorHandler::Register(); } void ManifestVectorHandler::Unregister() { IManifestVectorHandler::Unregister(); IManifestVectorHandler::Unregister(); } } // UI } // SceneAPI } // AZ #include