BsEditorSettings.h 6.5 KB

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