GNConfiguration.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include <Editor/Configuration/GNConfiguration.h>
  2. #include <AzCore/Memory/SystemAllocator.h>
  3. #include <AzCore/Serialization/EditContext.h>
  4. #include <AzCore/Serialization/SerializeContext.h>
  5. namespace GeomNodes
  6. {
  7. AZ_CLASS_ALLOCATOR_IMPL(GNConfiguration, AZ::SystemAllocator);
  8. /*static*/ void GNConfiguration::Reflect(AZ::ReflectContext* context)
  9. {
  10. if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  11. {
  12. serializeContext->Class<GNConfiguration>()
  13. ->Version(2)
  14. ->Field("Blender Path", &GNConfiguration::m_blenderPath)
  15. ->Field("Last Selected Path", &GNConfiguration::m_lastFilePath)
  16. ;
  17. if (auto* editContext = serializeContext->GetEditContext())
  18. {
  19. editContext->Class<GNConfiguration>("GeomNodes Configuration", "Default GeomNodes configuration")
  20. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  21. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  22. ->DataElement(AZ::Edit::UIHandlers::ExeSelectBrowseEdit, &GNConfiguration::m_blenderPath, "Blender Path", "Blender Path")
  23. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &GNConfiguration::OnBlenderPathChanged)
  24. ;
  25. }
  26. }
  27. }
  28. /*static*/ GNConfiguration GNConfiguration::CreateDefault()
  29. {
  30. return GNConfiguration();
  31. }
  32. bool GNConfiguration::operator==(const GNConfiguration& other) const
  33. {
  34. return m_blenderPath == other.m_blenderPath
  35. && m_lastFilePath == other.m_lastFilePath
  36. ;
  37. }
  38. bool GNConfiguration::operator!=(const GNConfiguration& other) const
  39. {
  40. return !(*this == other);
  41. }
  42. AZ::u32 GNConfiguration::OnBlenderPathChanged()
  43. {
  44. return AZ::Edit::PropertyRefreshLevels::AttributesAndValues;
  45. }
  46. }