/* * 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 namespace AZ { namespace SceneProcessingConfig { SoftNameSetting::SoftNameSetting(const char* pattern, SceneAPI::SceneCore::PatternMatcher::MatchApproach approach, const char* virtualType) : m_pattern(pattern, approach) , m_virtualType(virtualType) { } SoftNameSetting::~SoftNameSetting() = default; Crc32 SoftNameSetting::GetVirtualTypeHash() const { if (m_virtualTypeHash == Crc32()) { m_virtualTypeHash = Crc32(m_virtualType.c_str()); } return m_virtualTypeHash; } const AZStd::string& SoftNameSetting::GetVirtualType() const { return m_virtualType; } void SoftNameSetting::Reflect(ReflectContext* context) { SerializeContext* serialize = azrtti_cast(context); if (serialize) { serialize->Class() ->Version(1) ->Field("pattern", &SoftNameSetting::m_pattern) ->Field("virtualType", &SoftNameSetting::m_virtualType); EditContext* editContext = serialize->GetEditContext(); if (editContext) { editContext->Class("Soft name setting", "A pattern matcher to setup project specific naming conventions.") ->ClassElement(Edit::ClassElements::EditorData, "") ->Attribute(Edit::Attributes::AutoExpand, true) ->Attribute(Edit::Attributes::Visibility, AZ_CRC("PropertyVisibility_ShowChildrenOnly", 0xef428f20)) ->DataElement(Edit::UIHandlers::Default, &SoftNameSetting::m_pattern, "Pattern", "The pattern the matcher will check against.") ->Attribute(Edit::Attributes::Visibility, AZ_CRC("PropertyVisibility_ShowChildrenOnly", 0xef428f20)) ->DataElement(Edit::UIHandlers::ComboBox, &SoftNameSetting::m_virtualType, "Virtual Type", "The node(s) will be converted to this type after their pattern matches.") ->Attribute(Edit::Attributes::StringList, &SoftNameSetting::GetAllVirtualTypes); } } } AZStd::vector SoftNameSetting::GetAllVirtualTypes() const { using namespace SceneAPI::Events; AZStd::set virtualTypes; GraphMetaInfoBus::Broadcast(&GraphMetaInfoBus::Events::GetAllVirtualTypes, virtualTypes); AZStd::vector result; for (Crc32 virtualType : virtualTypes) { AZStd::string virtualTypeName; GraphMetaInfoBus::Broadcast(&GraphMetaInfoBus::Events::GetVirtualTypeName, virtualTypeName, virtualType); AZ_Assert(!virtualTypeName.empty(), "No name found for virtual type with hash %i.", static_cast(virtualType)); result.emplace_back(AZStd::move(virtualTypeName)); } AZStd::sort(result.begin(), result.end()); return result; } } // namespace SceneProcessingConfig } // namespace AZ