BsEditorSettings.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsDegree.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief Contains various globally accessible editor preferences.
  8. */
  9. class BS_ED_EXPORT EditorSettings
  10. {
  11. public:
  12. EditorSettings();
  13. /**
  14. * @brief Checks is snapping enabled for move handles in scene view.
  15. */
  16. bool getMoveHandleSnapActive() const { return mMoveSnapActive; }
  17. /**
  18. * @brief Checks is angle snapping enabled for rotate handles in scene view.
  19. */
  20. bool getRotateHandleSnapActive() const { return mRotateSnapActive; }
  21. /**
  22. * @brief Gets the snap amount if move snapping is enabled. All move handles
  23. * will move in multiples of this amount.
  24. */
  25. float getMoveHandleSnap() const { return mMoveSnap; }
  26. /**
  27. * @brief Gets the snap amount if rotate snapping is enabled. All rotate handles
  28. * will rotate in multiples of this amount.
  29. */
  30. Degree getRotationHandleSnap() const { return mRotationSnap; }
  31. /**
  32. * @brief Returns the size that determines to total size of the scene view grid (its width and height).
  33. */
  34. UINT32 getGridSize() const { return mGridSize; }
  35. /**
  36. * @brief Returns the distance between scene view grid lines.
  37. */
  38. float getGridSpacing() const { return mGridAxisSpacing; }
  39. /**
  40. * @brief Gets the default size of all scene view handles.
  41. */
  42. float getHandleSize() const { return mHandleSize; }
  43. /**
  44. * @brief Returns the currently active scene view tool (e.g. move, rotate, etc.)
  45. */
  46. UINT32 getActiveSceneTool() const { return mActiveSceneTool; }
  47. /**
  48. * @brief Returns the currently active coordinate mode for scene view (e.g. global/local)
  49. */
  50. UINT32 getActiveCoordinateMode() const { return mActiveCoordinateMode; }
  51. /**
  52. * @brief Returns the currently active pivot mode for scene view (e.g. pivot/center)
  53. */
  54. UINT32 getActivePivotMode() const { return mActivePivotMode; }
  55. /**
  56. * @brief Enables/disables snapping for move handles in scene view.
  57. */
  58. void setMoveHandleSnapActive(bool snapActive) { mMoveSnapActive = snapActive; markAsDirty(); }
  59. /**
  60. * @brief Enables/disables angle snapping for rotate handles in scene view.
  61. */
  62. void setRotateHandleSnapActive(bool snapActive) { mRotateSnapActive = snapActive; markAsDirty(); }
  63. /**
  64. * @brief Sets the move snap amount. All move handles will move in multiples of this amount.
  65. */
  66. void setMoveHandleSnap(float value) { mMoveSnap = value; markAsDirty(); }
  67. /**
  68. * @brief Sets the rotate snap amount. All rotate handles will rotate in multiples of this amount.
  69. */
  70. void setRotationHandleSnap(Degree value) { mRotationSnap = value; markAsDirty(); }
  71. /**
  72. * @brief Sets the size that determines to total size of the scene view grid (its width and height).
  73. */
  74. void setGridSize(UINT32 value) { mGridSize = value; markAsDirty(); }
  75. /**
  76. * @brief Sets the distance between scene view grid lines.
  77. */
  78. void setGridSpacing(float value) { mGridAxisSpacing = value; markAsDirty(); }
  79. /**
  80. * @brief Sets the default size of all scene view handles.
  81. */
  82. void setHandleSize(float value) { mHandleSize = value; markAsDirty(); }
  83. /**
  84. * @brief Changes the currently active scene view tool (e.g. move, rotate, etc.)
  85. */
  86. void setActiveSceneTool(UINT32 value) { mActiveSceneTool = value; markAsDirty(); }
  87. /**
  88. * @brief Changes the currently active coordinate mode for scene view (e.g. global/local)
  89. */
  90. void setActiveCoordinateMode(UINT32 value) { mActiveCoordinateMode = value; markAsDirty(); }
  91. /**
  92. * @brief Changes the currently active pivot mode for scene view (e.g. pivot/center)
  93. */
  94. void setActivePivotMode(UINT32 value) { mActivePivotMode = value; markAsDirty(); }
  95. /**
  96. * @brief Adds or updates a property key/value pair with a floating point value.
  97. */
  98. void setFloat(const String& name, float value);
  99. /**
  100. * @brief Adds or updates a property key/value pair with a signed integer value.
  101. */
  102. void setInt(const String& name, INT32 value);
  103. /**
  104. * @brief Adds or updates a property key/value pair with a boolean value.
  105. */
  106. void setBool(const String& name, bool value);
  107. /**
  108. * @brief Adds or updates a property key/value pair with a string value.
  109. */
  110. void setString(const String& name, const WString& value);
  111. /**
  112. * @brief Returns the floating point value of the specified key, or the default value
  113. * if such key cannot be found.
  114. */
  115. float getFloat(const String& name, float defaultValue = 0.0f);
  116. /**
  117. * @brief Returns the integer point value of the specified key, or the default value
  118. * if such key cannot be found.
  119. */
  120. INT32 getInt(const String& name, INT32 defaultValue = 0);
  121. /**
  122. * @brief Returns the boolean point value of the specified key, or the default value
  123. * if such key cannot be found.
  124. */
  125. bool getBool(const String& name, bool defaultValue = false);
  126. /**
  127. * @brief Returns the string point value of the specified key, or the default value
  128. * if such key cannot be found.
  129. */
  130. WString getString(const String& name, const WString& defaultValue = StringUtil::WBLANK);
  131. /**
  132. * @brief Returns true if the key with the specified name exists.
  133. */
  134. bool hasKey(const String& name);
  135. /**
  136. * @brief Deletes a key with the specified name.
  137. */
  138. void deleteKey(const String& name);
  139. /**
  140. * @brief Deletes all key/value pairs.
  141. */
  142. void deleteAllKeys();
  143. /**
  144. * @brief Returns a hash value that may be used for checking if any internal settings were
  145. * modified.
  146. */
  147. UINT32 getHash() const { return mHash; }
  148. private:
  149. /**
  150. * @brief Marks the object as dirty so that outside objects know when to update.
  151. */
  152. void markAsDirty() const { mHash++; }
  153. bool mMoveSnapActive;
  154. bool mRotateSnapActive;
  155. float mMoveSnap;
  156. Degree mRotationSnap;
  157. UINT32 mGridSize;
  158. float mGridAxisSpacing;
  159. UINT32 mActiveSceneTool;
  160. UINT32 mActiveCoordinateMode;
  161. UINT32 mActivePivotMode;
  162. float mHandleSize;
  163. Map<String, float> mFloatProperties;
  164. Map<String, INT32> mIntProperties;
  165. Map<String, bool> mBoolProperties;
  166. Map<String, WString> mStringProperties;
  167. mutable UINT32 mHash;
  168. };
  169. }