BsEditorSettings.h 6.4 KB

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