GNConfiguration.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <Editor/Configuration/GNConfiguration.h>
  9. #include <AzCore/Memory/SystemAllocator.h>
  10. #include <AzCore/Serialization/EditContext.h>
  11. #include <AzCore/Serialization/SerializeContext.h>
  12. namespace GeomNodes
  13. {
  14. AZ_CLASS_ALLOCATOR_IMPL(GNConfiguration, AZ::SystemAllocator);
  15. void GNConfiguration::Reflect(AZ::ReflectContext* context)
  16. {
  17. if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  18. {
  19. serializeContext->Class<GNConfiguration>()
  20. ->Version(2)
  21. ->Field("Blender Path", &GNConfiguration::m_blenderPath)
  22. ->Field("Last Selected Path", &GNConfiguration::m_lastFilePath);
  23. if (auto* editContext = serializeContext->GetEditContext())
  24. {
  25. editContext->Class<GNConfiguration>("GeomNodes Configuration", "Default GeomNodes configuration")
  26. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  27. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  28. ->DataElement(
  29. AZ::Edit::UIHandlers::ExeSelectBrowseEdit, &GNConfiguration::m_blenderPath, "Blender Path", "Blender Path")
  30. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &GNConfiguration::OnBlenderPathChanged);
  31. }
  32. }
  33. }
  34. GNConfiguration GNConfiguration::CreateDefault()
  35. {
  36. return GNConfiguration();
  37. }
  38. bool GNConfiguration::operator==(const GNConfiguration& other) const
  39. {
  40. return m_blenderPath == other.m_blenderPath && m_lastFilePath == other.m_lastFilePath;
  41. }
  42. bool GNConfiguration::operator!=(const GNConfiguration& other) const
  43. {
  44. return !(*this == other);
  45. }
  46. AZ::u32 GNConfiguration::OnBlenderPathChanged()
  47. {
  48. return AZ::Edit::PropertyRefreshLevels::AttributesAndValues;
  49. }
  50. } // namespace GeomNodes