BsEditorSettings.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsEditorPrerequisites.h"
  5. #include "Settings/BsSettings.h"
  6. #include "Math/BsDegree.h"
  7. namespace bs
  8. {
  9. /** @addtogroup Settings
  10. * @{
  11. */
  12. struct RecentProject;
  13. /** Contains various globally accessible editor preferences. */
  14. class BS_ED_EXPORT EditorSettings final : public Settings
  15. {
  16. public:
  17. /** Checks is snapping enabled for move handles in scene view. */
  18. bool getMoveHandleSnapActive() const { return mMoveSnapActive; }
  19. /** Checks is angle snapping enabled for rotate handles in scene view. */
  20. bool getRotateHandleSnapActive() const { return mRotateSnapActive; }
  21. /** Gets the snap amount if move snapping is enabled. All move handles will move in multiples of this amount. */
  22. float getMoveHandleSnap() const { return mMoveSnap; }
  23. /**
  24. * Gets the snap amount if rotate snapping is enabled. All rotate handles will rotate in multiples of this amount.
  25. */
  26. Degree getRotationHandleSnap() const { return mRotationSnap; }
  27. /** Returns the size that determines to total size of the scene view grid (its width and height). */
  28. UINT32 getGridSize() const { return mGridSize; }
  29. /** Returns the distance between scene view grid lines. */
  30. float getGridSpacing() const { return mGridAxisSpacing; }
  31. /** Gets the default size of all scene view handles. */
  32. float getHandleSize() const { return mHandleSize; }
  33. /** Returns the currently active scene view tool (for example move, rotate, etc.). */
  34. UINT32 getActiveSceneTool() const { return mActiveSceneTool; }
  35. /** Returns the currently active coordinate mode for scene view (for example global/local). */
  36. UINT32 getActiveCoordinateMode() const { return mActiveCoordinateMode; }
  37. /** Returns the currently active pivot mode for scene view (for example pivot/center). */
  38. UINT32 getActivePivotMode() const { return mActivePivotMode; }
  39. /** Retrieves the path to the last project open in the editor. */
  40. Path getLastOpenProject() const { return mLastOpenProject; }
  41. /** Retrieves whether the last open project should be automatically loaded on editor start up. */
  42. bool getAutoLoadLastProject() const { return mAutoLoadLastProject; }
  43. /** Retrieves a list of most recently loaded project paths and their last access times. */
  44. const Vector<RecentProject>& getRecentProjects() const { return mRecentProjects; }
  45. /** Retrieves the maximum number of frames per second the editor is allowed to execute. Zero means infinite. */
  46. UINT32 getFPSLimit() const { return mFPSLimit; }
  47. /**
  48. * Retrieves a value that controls sensitivity of mouse movements. This doesn't apply to mouse cursor.
  49. * Default value is 1.0f.
  50. */
  51. float getMouseSensitivity() const { return mMouseSensitivity; }
  52. /** Enables/disables snapping for move handles in scene view. */
  53. void setMoveHandleSnapActive(bool snapActive) { mMoveSnapActive = snapActive; markAsDirty(); }
  54. /** Enables/disables angle snapping for rotate handles in scene view. */
  55. void setRotateHandleSnapActive(bool snapActive) { mRotateSnapActive = snapActive; markAsDirty(); }
  56. /** Sets the move snap amount. All move handles will move in multiples of this amount. */
  57. void setMoveHandleSnap(float value) { mMoveSnap = value; markAsDirty(); }
  58. /** Sets the rotate snap amount. All rotate handles will rotate in multiples of this amount. */
  59. void setRotationHandleSnap(Degree value) { mRotationSnap = value; markAsDirty(); }
  60. /** Sets the size that determines to total size of the scene view grid (its width and height). */
  61. void setGridSize(UINT32 value) { mGridSize = value; markAsDirty(); }
  62. /** Sets the distance between scene view grid lines. */
  63. void setGridSpacing(float value) { mGridAxisSpacing = value; markAsDirty(); }
  64. /** Sets the default size of all scene view handles. */
  65. void setHandleSize(float value) { mHandleSize = value; markAsDirty(); }
  66. /** Changes the currently active scene view tool (for example move, rotate, etc.). */
  67. void setActiveSceneTool(UINT32 value) { mActiveSceneTool = value; markAsDirty(); }
  68. /** Changes the currently active coordinate mode for scene view (for example global/local). */
  69. void setActiveCoordinateMode(UINT32 value) { mActiveCoordinateMode = value; markAsDirty(); }
  70. /** Changes the currently active pivot mode for scene view (for example pivot/center). */
  71. void setActivePivotMode(UINT32 value) { mActivePivotMode = value; markAsDirty(); }
  72. /** Sets the path to the last project open in the editor. */
  73. void setLastOpenProject(const Path& value) { mLastOpenProject = value; markAsDirty(); }
  74. /** Sets whether the last open project should be automatically loaded on editor start up. */
  75. void setAutoLoadLastProject(bool value) { mAutoLoadLastProject = value; markAsDirty(); }
  76. /** Sets a list of most recently loaded project paths and their last access times. */
  77. void setRecentProjects(const Vector<RecentProject>& value) { mRecentProjects = value; markAsDirty(); }
  78. /** Sets the maximum number of frames per second the editor is allowed to execute. Zero means infinite. */
  79. void setFPSLimit(UINT32 limit) { mFPSLimit = limit; markAsDirty(); }
  80. /**
  81. * Sets a value that controls sensitivity of mouse movements. This doesn't apply to mouse cursor.
  82. * Default value is 1.0f.
  83. */
  84. void setMouseSensitivity(float value) { mMouseSensitivity = value; markAsDirty(); }
  85. private:
  86. bool mMoveSnapActive = false;
  87. bool mRotateSnapActive = false;
  88. float mMoveSnap = 0.1f;
  89. Degree mRotationSnap { 20.0f };
  90. UINT32 mGridSize = 256;
  91. float mGridAxisSpacing = 1.0f;
  92. UINT32 mActiveSceneTool = 1; // Move tool
  93. UINT32 mActiveCoordinateMode = 0;
  94. UINT32 mActivePivotMode = 0;
  95. float mHandleSize = 0.10f;
  96. UINT32 mFPSLimit = 60;
  97. float mMouseSensitivity = 1.0f;
  98. Path mLastOpenProject;
  99. bool mAutoLoadLastProject = true;
  100. Vector<RecentProject> mRecentProjects;
  101. /************************************************************************/
  102. /* RTTI */
  103. /************************************************************************/
  104. public:
  105. friend class EditorSettingsRTTI;
  106. static RTTITypeBase* getRTTIStatic();
  107. RTTITypeBase* getRTTI() const override;
  108. };
  109. /** Data about a recently loaded project. */
  110. struct RecentProject
  111. {
  112. Path path;
  113. UINT64 accessTimestamp;
  114. };
  115. /** @} */
  116. }