EditorPreferencesPageViewportDebug.cpp 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 "EditorDefs.h"
  9. #include "EditorPreferencesPageViewportDebug.h"
  10. // AzCore
  11. #include <AzCore/Serialization/EditContext.h>
  12. // Editor
  13. #include "Settings.h"
  14. void CEditorPreferencesPage_ViewportDebug::Reflect(AZ::SerializeContext& serialize)
  15. {
  16. serialize.Class<Profiling>()
  17. ->Version(1)
  18. ->Field("ShowMeshStatsOnMouseOver", &Profiling::m_showMeshStatsOnMouseOver);
  19. serialize.Class<Warnings>()
  20. ->Version(1)
  21. ->Field("WarningIconsDrawDistance", &Warnings::m_warningIconsDrawDistance)
  22. ->Field("ShowScaleWarnings", &Warnings::m_showScaleWarnings)
  23. ->Field("ShowRotationWarnings", &Warnings::m_showRotationWarnings);
  24. serialize.Class<CEditorPreferencesPage_ViewportDebug>()
  25. ->Version(1)
  26. ->Field("Profiling", &CEditorPreferencesPage_ViewportDebug::m_profiling)
  27. ->Field("Warnings", &CEditorPreferencesPage_ViewportDebug::m_warnings);
  28. AZ::EditContext* editContext = serialize.GetEditContext();
  29. if (editContext)
  30. {
  31. editContext->Class<Profiling>("Profiling", "Profiling")
  32. ->DataElement(AZ::Edit::UIHandlers::CheckBox, &Profiling::m_showMeshStatsOnMouseOver, "Show Mesh Statistics", "Show Mesh Statistics on Mouse Over");
  33. editContext->Class<Warnings>("Viewport Warning Settings", "")
  34. ->DataElement(AZ::Edit::UIHandlers::SpinBox, &Warnings::m_warningIconsDrawDistance, "Warning Icons Draw Distance", "Warning Icons Draw Distance")
  35. ->DataElement(AZ::Edit::UIHandlers::CheckBox, &Warnings::m_showScaleWarnings, "Show Scale Warnings", "Show Scale Warnings")
  36. ->DataElement(AZ::Edit::UIHandlers::CheckBox, &Warnings::m_showRotationWarnings, "Show Rotation Warnings", "Show Rotation Warnings");
  37. editContext->Class<CEditorPreferencesPage_ViewportDebug>("Viewport Debug Preferences", "Viewport Debug Preferences")
  38. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  39. ->Attribute(AZ::Edit::Attributes::Visibility, AZ_CRC_CE("PropertyVisibility_ShowChildrenOnly"))
  40. ->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_ViewportDebug::m_profiling, "Profiling", "Profiling")
  41. ->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_ViewportDebug::m_warnings, "Viewport Warning Settings", "Viewport Warning Settings");
  42. }
  43. }
  44. CEditorPreferencesPage_ViewportDebug::CEditorPreferencesPage_ViewportDebug()
  45. {
  46. InitializeSettings();
  47. m_icon = QIcon(":/res/Debug.svg");
  48. }
  49. QIcon& CEditorPreferencesPage_ViewportDebug::GetIcon()
  50. {
  51. return m_icon;
  52. }
  53. void CEditorPreferencesPage_ViewportDebug::OnApply()
  54. {
  55. gSettings.viewports.bShowMeshStatsOnMouseOver = m_profiling.m_showMeshStatsOnMouseOver;
  56. gSettings.viewports.bShowRotationWarnings = m_warnings.m_showRotationWarnings;
  57. gSettings.viewports.bShowScaleWarnings = m_warnings.m_showScaleWarnings;
  58. gSettings.viewports.fWarningIconsDrawDistance = m_warnings.m_warningIconsDrawDistance;
  59. }
  60. void CEditorPreferencesPage_ViewportDebug::InitializeSettings()
  61. {
  62. m_profiling.m_showMeshStatsOnMouseOver = gSettings.viewports.bShowMeshStatsOnMouseOver;
  63. m_warnings.m_showRotationWarnings = gSettings.viewports.bShowRotationWarnings;
  64. m_warnings.m_showScaleWarnings = gSettings.viewports.bShowScaleWarnings;
  65. m_warnings.m_warningIconsDrawDistance = gSettings.viewports.fWarningIconsDrawDistance;
  66. }