PreferencesStdPages.cpp 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 "PreferencesStdPages.h"
  10. #include <AzToolsFramework/Entity/EditorEntityHelpers.h>
  11. // Editor
  12. #include "EditorPreferencesPageGeneral.h"
  13. #include "EditorPreferencesPageFiles.h"
  14. #include "EditorPreferencesPageViewportGeneral.h"
  15. #include "EditorPreferencesPageViewportManipulator.h"
  16. #include "EditorPreferencesPageViewportCamera.h"
  17. #include "EditorPreferencesPageViewportDebug.h"
  18. #include "EditorPreferencesPageAWS.h"
  19. //////////////////////////////////////////////////////////////////////////
  20. // Implementation of ClassDesc for standard Editor preferences.
  21. //////////////////////////////////////////////////////////////////////////
  22. CStdPreferencesClassDesc::CStdPreferencesClassDesc()
  23. : m_refCount(0)
  24. {
  25. m_pageCreators = {
  26. [](){ return new CEditorPreferencesPage_General(); },
  27. [](){ return new CEditorPreferencesPage_Files(); },
  28. [](){ return new CEditorPreferencesPage_ViewportGeneral(); },
  29. [](){ return new CEditorPreferencesPage_ViewportCamera(); },
  30. [](){ return new CEditorPreferencesPage_ViewportManipulator(); },
  31. [](){ return new CEditorPreferencesPage_ViewportDebug(); }
  32. };
  33. if (AzToolsFramework::IsComponentWithServiceRegistered(AZ_CRC_CE("AWSCoreEditorService")))
  34. {
  35. m_pageCreators.push_back([]() { return new CEditorPreferencesPage_AWS(); });
  36. }
  37. }
  38. HRESULT CStdPreferencesClassDesc::QueryInterface(const IID& riid, void** ppvObj)
  39. {
  40. if (riid == __az_uuidof(IPreferencesPageCreator))
  41. {
  42. *ppvObj = (IPreferencesPageCreator*)this;
  43. return S_OK;
  44. }
  45. return E_NOINTERFACE;
  46. }
  47. //////////////////////////////////////////////////////////////////////////
  48. ULONG CStdPreferencesClassDesc::AddRef()
  49. {
  50. m_refCount++;
  51. return m_refCount;
  52. };
  53. //////////////////////////////////////////////////////////////////////////
  54. ULONG CStdPreferencesClassDesc::Release()
  55. {
  56. ULONG refs = --m_refCount;
  57. if (m_refCount <= 0)
  58. {
  59. delete this;
  60. }
  61. return refs;
  62. }
  63. //////////////////////////////////////////////////////////////////////////
  64. REFGUID CStdPreferencesClassDesc::ClassID()
  65. {
  66. // {95FE3251-796C-4e3b-82F0-AD35F7FFA267}
  67. static const GUID guid = {
  68. 0x95fe3251, 0x796c, 0x4e3b, { 0x82, 0xf0, 0xad, 0x35, 0xf7, 0xff, 0xa2, 0x67 }
  69. };
  70. return guid;
  71. }
  72. //////////////////////////////////////////////////////////////////////////
  73. int CStdPreferencesClassDesc::GetPagesCount()
  74. {
  75. return static_cast<int>(m_pageCreators.size());
  76. }
  77. IPreferencesPage* CStdPreferencesClassDesc::CreateEditorPreferencesPage(int index)
  78. {
  79. return (index >= m_pageCreators.size()) ? nullptr : m_pageCreators[index]();
  80. }