EditorSettings.cs 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Runtime.CompilerServices;
  6. using System.Runtime.InteropServices;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using BansheeEngine;
  10. namespace BansheeEditor
  11. {
  12. internal static class EditorSettings
  13. {
  14. public static bool MoveHandleSnapActive
  15. {
  16. get { return Internal_GetMoveHandleSnapActive(); }
  17. set { Internal_SetMoveHandleSnapActive(value); }
  18. }
  19. public static bool RotateHandleSnapActive
  20. {
  21. get { return Internal_GetRotateHandleSnapActive(); }
  22. set { Internal_SetRotateHandleSnapActive(value); }
  23. }
  24. public static float MoveHandleSnapAmount
  25. {
  26. get { return Internal_GetMoveHandleSnapAmount(); }
  27. set { Internal_SetMoveHandleSnapAmount(value); }
  28. }
  29. public static Degree RotateHandleSnapAmount
  30. {
  31. get { return Internal_GetRotateHandleSnapAmount(); }
  32. set { Internal_SetRotateHandleSnapAmount(value.Degrees); }
  33. }
  34. public static float DefaultHandleSize
  35. {
  36. get { return Internal_GetDefaultHandleSize(); }
  37. set { Internal_SetDefaultHandleSize(value); }
  38. }
  39. public static SceneViewTool ActiveSceneTool
  40. {
  41. get { return (SceneViewTool)Internal_GetActiveSceneTool(); }
  42. set { Internal_SetActiveSceneTool((int)value); }
  43. }
  44. public static HandleCoordinateMode ActiveCoordinateMode
  45. {
  46. get { return (HandleCoordinateMode)Internal_GetActiveCoordinateMode(); }
  47. set { Internal_SetActiveCoordinateMode((int)value); }
  48. }
  49. public static HandlePivotMode ActivePivotMode
  50. {
  51. get { return (HandlePivotMode)Internal_GetActivePivotMode(); }
  52. set { Internal_SetActivePivotMode((int)value); }
  53. }
  54. public static string LastOpenProject
  55. {
  56. get { return Internal_GetLastOpenProject(); }
  57. set { Internal_SetLastOpenProject(value); }
  58. }
  59. public static bool AutoLoadLastProject
  60. {
  61. get { return Internal_GetAutoLoadLastProject(); }
  62. set { Internal_SetAutoLoadLastProject(value); }
  63. }
  64. public static RecentProject[] RecentProjects
  65. {
  66. get
  67. {
  68. string[] paths;
  69. UInt64[] timeStamps;
  70. Internal_GetRecentProjects(out paths, out timeStamps);
  71. RecentProject[] output = new RecentProject[paths.Length];
  72. for (int i = 0; i < paths.Length; i++)
  73. output[i] = new RecentProject(paths[i], timeStamps[i]);
  74. return output;
  75. }
  76. set
  77. {
  78. int numEntries = 0;
  79. if (value != null)
  80. numEntries = value.Length;
  81. string[] paths = new string[numEntries];
  82. UInt64[] timeStamps = new UInt64[numEntries];
  83. for (int i = 0; i < numEntries; i++)
  84. {
  85. paths[i] = value[i].path;
  86. timeStamps[i] = value[i].accessTimestamp;
  87. }
  88. Internal_SetRecentProjects(paths, timeStamps);
  89. }
  90. }
  91. public static int Hash
  92. {
  93. get { return Internal_GetHash(); }
  94. }
  95. public static void SetFloat(string name, float value)
  96. {
  97. Internal_SetFloat(name, value);
  98. }
  99. public static void SetInt(string name, int value)
  100. {
  101. Internal_SetInt(name, value);
  102. }
  103. public static void SetBool(string name, bool value)
  104. {
  105. Internal_SetBool(name, value);
  106. }
  107. public static void SetString(string name, String value)
  108. {
  109. Internal_SetString(name, value);
  110. }
  111. public static float GetFloat(string name, float defaultValue = 0.0f)
  112. {
  113. return Internal_GetFloat(name, defaultValue);
  114. }
  115. public static int GetInt(string name, int defaultValue = 0)
  116. {
  117. return Internal_GetInt(name, defaultValue);
  118. }
  119. public static bool GetBool(string name, bool defaultValue = false)
  120. {
  121. return Internal_GetBool(name, defaultValue);
  122. }
  123. public static String GetString(string name, string defaultValue = "")
  124. {
  125. return Internal_GetString(name, defaultValue);
  126. }
  127. public static bool HasKey(string name)
  128. {
  129. return Internal_HasKey(name);
  130. }
  131. public static void DeleteKey(string name)
  132. {
  133. Internal_DeleteKey(name);
  134. }
  135. public static void DeleteAllKeys()
  136. {
  137. Internal_DeleteAllKeys();
  138. }
  139. public static void Save()
  140. {
  141. Internal_Save();
  142. }
  143. [MethodImpl(MethodImplOptions.InternalCall)]
  144. private static extern bool Internal_GetMoveHandleSnapActive();
  145. [MethodImpl(MethodImplOptions.InternalCall)]
  146. private static extern void Internal_SetMoveHandleSnapActive(bool value);
  147. [MethodImpl(MethodImplOptions.InternalCall)]
  148. private static extern bool Internal_GetRotateHandleSnapActive();
  149. [MethodImpl(MethodImplOptions.InternalCall)]
  150. private static extern void Internal_SetRotateHandleSnapActive(bool value);
  151. [MethodImpl(MethodImplOptions.InternalCall)]
  152. private static extern float Internal_GetMoveHandleSnapAmount();
  153. [MethodImpl(MethodImplOptions.InternalCall)]
  154. private static extern void Internal_SetMoveHandleSnapAmount(float value);
  155. [MethodImpl(MethodImplOptions.InternalCall)]
  156. private static extern float Internal_GetRotateHandleSnapAmount();
  157. [MethodImpl(MethodImplOptions.InternalCall)]
  158. private static extern void Internal_SetRotateHandleSnapAmount(float value);
  159. [MethodImpl(MethodImplOptions.InternalCall)]
  160. private static extern float Internal_GetDefaultHandleSize();
  161. [MethodImpl(MethodImplOptions.InternalCall)]
  162. private static extern void Internal_SetDefaultHandleSize(float value);
  163. [MethodImpl(MethodImplOptions.InternalCall)]
  164. private static extern int Internal_GetActiveSceneTool();
  165. [MethodImpl(MethodImplOptions.InternalCall)]
  166. private static extern void Internal_SetActiveSceneTool(int value);
  167. [MethodImpl(MethodImplOptions.InternalCall)]
  168. private static extern int Internal_GetActiveCoordinateMode();
  169. [MethodImpl(MethodImplOptions.InternalCall)]
  170. private static extern void Internal_SetActiveCoordinateMode(int value);
  171. [MethodImpl(MethodImplOptions.InternalCall)]
  172. private static extern int Internal_GetActivePivotMode();
  173. [MethodImpl(MethodImplOptions.InternalCall)]
  174. private static extern void Internal_SetActivePivotMode(int value);
  175. [MethodImpl(MethodImplOptions.InternalCall)]
  176. private static extern string Internal_GetLastOpenProject();
  177. [MethodImpl(MethodImplOptions.InternalCall)]
  178. private static extern void Internal_SetLastOpenProject(string value);
  179. [MethodImpl(MethodImplOptions.InternalCall)]
  180. private static extern bool Internal_GetAutoLoadLastProject();
  181. [MethodImpl(MethodImplOptions.InternalCall)]
  182. private static extern void Internal_SetAutoLoadLastProject(bool value);
  183. [MethodImpl(MethodImplOptions.InternalCall)]
  184. private static extern void Internal_GetRecentProjects(out string[] paths, out UInt64[] timestamps);
  185. [MethodImpl(MethodImplOptions.InternalCall)]
  186. private static extern void Internal_SetRecentProjects(string[] paths, UInt64[] timestamps);
  187. [MethodImpl(MethodImplOptions.InternalCall)]
  188. private static extern void Internal_SetFloat(string name, float value);
  189. [MethodImpl(MethodImplOptions.InternalCall)]
  190. private static extern void Internal_SetInt(string name, int value);
  191. [MethodImpl(MethodImplOptions.InternalCall)]
  192. private static extern void Internal_SetBool(string name, bool value);
  193. [MethodImpl(MethodImplOptions.InternalCall)]
  194. private static extern void Internal_SetString(string name, String value);
  195. [MethodImpl(MethodImplOptions.InternalCall)]
  196. private static extern float Internal_GetFloat(string name, float defaultValue);
  197. [MethodImpl(MethodImplOptions.InternalCall)]
  198. private static extern int Internal_GetInt(string name, int defaultValue);
  199. [MethodImpl(MethodImplOptions.InternalCall)]
  200. private static extern bool Internal_GetBool(string name, bool defaultValue);
  201. [MethodImpl(MethodImplOptions.InternalCall)]
  202. private static extern string Internal_GetString(string name, string defaultValue);
  203. [MethodImpl(MethodImplOptions.InternalCall)]
  204. private static extern bool Internal_HasKey(string name);
  205. [MethodImpl(MethodImplOptions.InternalCall)]
  206. private static extern void Internal_DeleteKey(string name);
  207. [MethodImpl(MethodImplOptions.InternalCall)]
  208. private static extern void Internal_DeleteAllKeys();
  209. [MethodImpl(MethodImplOptions.InternalCall)]
  210. private static extern int Internal_GetHash();
  211. [MethodImpl(MethodImplOptions.InternalCall)]
  212. private static extern void Internal_Save();
  213. }
  214. // Note: Must match C++ struct RecentProject
  215. [StructLayout(LayoutKind.Sequential)]
  216. public struct RecentProject
  217. {
  218. public RecentProject(string path, UInt64 timestamp)
  219. {
  220. this.path = path;
  221. this.accessTimestamp = timestamp;
  222. }
  223. public string path;
  224. public UInt64 accessTimestamp;
  225. }
  226. }