EditorApplication.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Runtime.CompilerServices;
  4. using BansheeEngine;
  5. namespace BansheeEditor
  6. {
  7. public enum SceneViewTool
  8. {
  9. View,
  10. Move,
  11. Rotate,
  12. Scale
  13. }
  14. public enum HandlePivotMode
  15. {
  16. Center,
  17. Pivot
  18. }
  19. public enum HandleCoordinateMode
  20. {
  21. Local,
  22. World
  23. }
  24. public enum EditorPlatformType
  25. {
  26. Windows
  27. }
  28. public class EditorApplication
  29. {
  30. public static SceneViewTool ActiveSceneTool
  31. {
  32. get { return EditorSettings.ActiveSceneTool; }
  33. set { EditorSettings.ActiveSceneTool = value; }
  34. }
  35. public static HandleCoordinateMode ActiveCoordinateMode
  36. {
  37. get { return EditorSettings.ActiveCoordinateMode; }
  38. set { EditorSettings.ActiveCoordinateMode = value; }
  39. }
  40. public static HandlePivotMode ActivePivotMode
  41. {
  42. get { return EditorSettings.ActivePivotMode; }
  43. set { EditorSettings.ActivePivotMode = value; }
  44. }
  45. public static Camera SceneViewCamera
  46. {
  47. get { return instance.scene.GetCamera(); }
  48. }
  49. public static EditorPlatformType EditorPlatform
  50. {
  51. get { return EditorPlatformType.Windows; } // TODO - Set this properly once we have support for more platforms
  52. }
  53. public static string ProjectPath { get { return Internal_GetProjectPath(); } }
  54. public static string ProjectName { get { return Internal_GetProjectName(); } }
  55. internal static string CompilerPath { get { return Internal_GetCompilerPath(); } }
  56. internal static string BuiltinAssemblyPath { get { return Internal_GetBuiltinAssemblyPath(); } }
  57. internal static string ScriptAssemblyPath { get { return Internal_GetScriptAssemblyPath(); } }
  58. internal static string FrameworkAssemblyPath { get { return Internal_GetFrameworkAssemblyPath(); } }
  59. internal static string EngineAssembly { get { return Internal_GetEngineAssemblyName(); } }
  60. internal static string EditorAssembly { get { return Internal_GetEditorAssemblyName(); } }
  61. internal static string ScriptGameAssembly { get { return Internal_GetScriptGameAssemblyName(); } }
  62. internal static string ScriptEditorAssembly { get { return Internal_GetScriptEditorAssemblyName(); } }
  63. private static EditorApplication instance;
  64. private InspectorWindow inspector;
  65. private SceneWindow scene;
  66. private FolderMonitor monitor;
  67. // DEBUG ONLY
  68. Debug_Component1 dbgComponent;
  69. // END DEBUG ONLY
  70. internal EditorApplication()
  71. {
  72. instance = this;
  73. // Register controls
  74. InputConfiguration inputConfig = VirtualInput.KeyConfig;
  75. inputConfig.RegisterButton(SceneCamera.MoveForwardBinding, ButtonCode.W);
  76. inputConfig.RegisterButton(SceneCamera.MoveBackBinding, ButtonCode.S);
  77. inputConfig.RegisterButton(SceneCamera.MoveLeftBinding, ButtonCode.A);
  78. inputConfig.RegisterButton(SceneCamera.MoveRightBinding, ButtonCode.D);
  79. inputConfig.RegisterButton(SceneCamera.MoveForwardBinding, ButtonCode.Up);
  80. inputConfig.RegisterButton(SceneCamera.MoveBackBinding, ButtonCode.Back);
  81. inputConfig.RegisterButton(SceneCamera.MoveLeftBinding, ButtonCode.Left);
  82. inputConfig.RegisterButton(SceneCamera.MoveRightBinding, ButtonCode.Right);
  83. inputConfig.RegisterButton(SceneCamera.FastMoveBinding, ButtonCode.LeftShift);
  84. inputConfig.RegisterButton(SceneCamera.RotateBinding, ButtonCode.MouseRight);
  85. inputConfig.RegisterAxis(SceneCamera.HorizontalAxisBinding, InputAxis.MouseX);
  86. inputConfig.RegisterAxis(SceneCamera.VerticalAxisBinding, InputAxis.MouseY);
  87. // Open windows
  88. inspector = EditorWindow.OpenWindow<InspectorWindow>();
  89. scene = EditorWindow.OpenWindow<SceneWindow>();
  90. ProjectLibrary.Refresh();
  91. monitor = new FolderMonitor(ProjectLibrary.ResourceFolder);
  92. monitor.OnAdded += OnAssetModified;
  93. monitor.OnRemoved += OnAssetModified;
  94. monitor.OnModified += OnAssetModified;
  95. // DEBUG ONLY
  96. SceneObject newDbgObject = new SceneObject("NewDbgObject");
  97. dbgComponent = newDbgObject.AddComponent<Debug_Component1>();
  98. newDbgObject.AddComponent<Debug_Component2>();
  99. inspector.SetObjectToInspect(newDbgObject);
  100. SceneObject gizmoDbgObject = new SceneObject("GizmoDebug");
  101. gizmoDbgObject.AddComponent<DbgGizmoComponent>();
  102. //ProgressBar.Show("Test", 0.5f);
  103. //ColorPicker.Show();
  104. // DEBUG ONLY END
  105. }
  106. private void OnAssetModified(string path)
  107. {
  108. ProjectLibrary.Refresh(path);
  109. }
  110. internal void OnEditorUpdate()
  111. {
  112. ProjectLibrary.Update();
  113. // DEBUG ONLY
  114. if (dbgComponent != null)
  115. dbgComponent.intArray[0] = dbgComponent.intArray[0] + 1;
  116. // DEBUG ONLY END
  117. }
  118. [MethodImpl(MethodImplOptions.InternalCall)]
  119. private static extern string Internal_GetProjectPath();
  120. [MethodImpl(MethodImplOptions.InternalCall)]
  121. private static extern string Internal_GetProjectName();
  122. [MethodImpl(MethodImplOptions.InternalCall)]
  123. private static extern string Internal_GetCompilerPath();
  124. [MethodImpl(MethodImplOptions.InternalCall)]
  125. private static extern string Internal_GetBuiltinAssemblyPath();
  126. [MethodImpl(MethodImplOptions.InternalCall)]
  127. private static extern string Internal_GetScriptAssemblyPath();
  128. [MethodImpl(MethodImplOptions.InternalCall)]
  129. private static extern string Internal_GetFrameworkAssemblyPath();
  130. [MethodImpl(MethodImplOptions.InternalCall)]
  131. private static extern string Internal_GetEngineAssemblyName();
  132. [MethodImpl(MethodImplOptions.InternalCall)]
  133. private static extern string Internal_GetEditorAssemblyName();
  134. [MethodImpl(MethodImplOptions.InternalCall)]
  135. private static extern string Internal_GetScriptGameAssemblyName();
  136. [MethodImpl(MethodImplOptions.InternalCall)]
  137. private static extern string Internal_GetScriptEditorAssemblyName();
  138. }
  139. }