MenuItems.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using BansheeEngine;
  7. namespace BansheeEditor
  8. {
  9. /// <summary>
  10. /// Contains various menu item callbacks for the main editor menu bar.
  11. /// </summary>
  12. static class MenuItems
  13. {
  14. /// <summary>
  15. /// Adds a camera component to the currently selected scene object.
  16. /// </summary>
  17. [MenuItem("Components/Camera", 7050)]
  18. private static void AddCamera()
  19. {
  20. SceneObject so = Selection.SceneObject;
  21. if (so == null)
  22. return;
  23. UndoRedo.RecordSO(so, "Added a Camera component");
  24. so.AddComponent<Camera>();
  25. EditorApplication.SetSceneDirty();
  26. }
  27. /// <summary>
  28. /// Adds a renderable component to the currently selected scene object.
  29. /// </summary>
  30. [MenuItem("Components/Renderable", 7049)]
  31. private static void AddRenderable()
  32. {
  33. SceneObject so = Selection.SceneObject;
  34. if (so == null)
  35. return;
  36. UndoRedo.RecordSO(so, "Added a Renderable component");
  37. so.AddComponent<Renderable>();
  38. EditorApplication.SetSceneDirty();
  39. }
  40. /// <summary>
  41. /// Adds a point light component to the currently selected scene object.
  42. /// </summary>
  43. [MenuItem("Components/Point light", 7048)]
  44. private static void AddPointLight()
  45. {
  46. SceneObject so = Selection.SceneObject;
  47. if (so == null)
  48. return;
  49. UndoRedo.RecordSO(so, "Added a Light component");
  50. Light light = so.AddComponent<Light>();
  51. light.Type = LightType.Point;
  52. EditorApplication.SetSceneDirty();
  53. }
  54. /// <summary>
  55. /// Adds a spot light component to the currently selected scene object.
  56. /// </summary>
  57. [MenuItem("Components/Spot light", 7047)]
  58. private static void AddSpotLight()
  59. {
  60. SceneObject so = Selection.SceneObject;
  61. if (so == null)
  62. return;
  63. UndoRedo.RecordSO(so, "Added a Light component");
  64. Light light = so.AddComponent<Light>();
  65. light.Type = LightType.Spot;
  66. EditorApplication.SetSceneDirty();
  67. }
  68. /// <summary>
  69. /// Adds a directional light component to the currently selected scene object.
  70. /// </summary>
  71. [MenuItem("Components/Directional light", 7046)]
  72. private static void AddDirectionalLight()
  73. {
  74. SceneObject so = Selection.SceneObject;
  75. if (so == null)
  76. return;
  77. UndoRedo.RecordSO(so, "Added a Light component");
  78. Light light = so.AddComponent<Light>();
  79. light.Type = LightType.Directional;
  80. EditorApplication.SetSceneDirty();
  81. }
  82. /// <summary>
  83. /// Creates a new empty scene object.
  84. /// </summary>
  85. [MenuItem("Scene Objects/Scene Object", 8051)]
  86. [ToolbarItem("SceneObject", ToolbarIcon.NewSceneObject, "", 1601, true)]
  87. private static void AddEmptySO()
  88. {
  89. SceneObject so = UndoRedo.CreateSO("SceneObject", "Created an empty SceneObject");
  90. Selection.SceneObject = so;
  91. EditorApplication.SetSceneDirty();
  92. }
  93. /// <summary>
  94. /// Creates a new scene object with a camera component.
  95. /// </summary>
  96. [MenuItem("Scene Objects/Camera", 8050)]
  97. [ToolbarItem("Camera", ToolbarIcon.NewCamera, "", 1600, false)]
  98. private static void AddCameraSO()
  99. {
  100. SceneObject so = UndoRedo.CreateSO("Camera", "Created a Camera");
  101. so.AddComponent<Camera>();
  102. Selection.SceneObject = so;
  103. EditorApplication.SetSceneDirty();
  104. }
  105. /// <summary>
  106. /// Creates a new scene object with a renderable component.
  107. /// </summary>
  108. [MenuItem("Scene Objects/Renderable", 8049)]
  109. [ToolbarItem("Renderable", ToolbarIcon.NewRenderable, "", 1599)]
  110. private static void AddRenderableSO()
  111. {
  112. SceneObject so = UndoRedo.CreateSO("Renderable", "Created a Renderable");
  113. so.AddComponent<Renderable>();
  114. Selection.SceneObject = so;
  115. EditorApplication.SetSceneDirty();
  116. }
  117. /// <summary>
  118. /// Creates a new scene object with a point light component.
  119. /// </summary>
  120. [MenuItem("Scene Objects/Point light", 8048)]
  121. [ToolbarItem("Point light", ToolbarIcon.NewPointLight, "", 1598)]
  122. private static void AddPointLightSO()
  123. {
  124. SceneObject so = UndoRedo.CreateSO("Point light", "Created a Light");
  125. Light light = so.AddComponent<Light>();
  126. light.Type = LightType.Point;
  127. Selection.SceneObject = so;
  128. EditorApplication.SetSceneDirty();
  129. }
  130. /// <summary>
  131. /// Creates a new scene object with a spot light component.
  132. /// </summary>
  133. [MenuItem("Scene Objects/Spot light", 8047)]
  134. [ToolbarItem("Spot light", ToolbarIcon.NewSpotLight, "", 1597)]
  135. private static void AddSpotLightSO()
  136. {
  137. SceneObject so = UndoRedo.CreateSO("Spot light", "Created a Light");
  138. Light light = so.AddComponent<Light>();
  139. light.Type = LightType.Spot;
  140. Selection.SceneObject = so;
  141. EditorApplication.SetSceneDirty();
  142. }
  143. /// <summary>
  144. /// Creates a new scene object with a directional light component.
  145. /// </summary>
  146. [MenuItem("Scene Objects/Directional light", 8046)]
  147. [ToolbarItem("Directional light", ToolbarIcon.NewDirLight, "", 1596)]
  148. private static void AddDirectionalLightSO()
  149. {
  150. SceneObject so = UndoRedo.CreateSO("Directional light", "Created a Light");
  151. Light light = so.AddComponent<Light>();
  152. light.Type = LightType.Directional;
  153. Selection.SceneObject = so;
  154. EditorApplication.SetSceneDirty();
  155. }
  156. /// <summary>
  157. /// Creates a new scene object with a box primitive.
  158. /// </summary>
  159. [MenuItem("Scene Objects/3D primitives/Box", 8100)]
  160. [ToolbarItem("Cube", ToolbarIcon.NewCube, "", 1700, true)]
  161. private static void Add3DBox()
  162. {
  163. SceneObject so = UndoRedo.CreateSO("Box", "Created a box");
  164. Renderable renderable = so.AddComponent<Renderable>();
  165. renderable.Mesh = Builtin.Box;
  166. Selection.SceneObject = so;
  167. EditorApplication.SetSceneDirty();
  168. }
  169. /// <summary>
  170. /// Creates a new scene object with a sphere primitive.
  171. /// </summary>
  172. [MenuItem("Scene Objects/3D primitives/Sphere", 8099)]
  173. [ToolbarItem("Sphere", ToolbarIcon.NewSphere, "", 1699)]
  174. private static void Add3DSphere()
  175. {
  176. SceneObject so = UndoRedo.CreateSO("Sphere", "Created a sphere");
  177. Renderable renderable = so.AddComponent<Renderable>();
  178. renderable.Mesh = Builtin.Sphere;
  179. Selection.SceneObject = so;
  180. EditorApplication.SetSceneDirty();
  181. }
  182. /// <summary>
  183. /// Creates a new scene object with a cone primitive.
  184. /// </summary>
  185. [MenuItem("Scene Objects/3D primitives/Cone", 8098)]
  186. [ToolbarItem("Cone", ToolbarIcon.NewCone, "", 1698)]
  187. private static void Add3DCone()
  188. {
  189. SceneObject so = UndoRedo.CreateSO("Cone", "Created a cone");
  190. Renderable renderable = so.AddComponent<Renderable>();
  191. renderable.Mesh = Builtin.Cone;
  192. Selection.SceneObject = so;
  193. EditorApplication.SetSceneDirty();
  194. }
  195. /// <summary>
  196. /// Creates a new scene object with a quad primitive.
  197. /// </summary>
  198. [MenuItem("Scene Objects/3D primitives/Quad", 8097)]
  199. [ToolbarItem("Quad", ToolbarIcon.NewQuad, "", 1697)]
  200. private static void Add3DQuad()
  201. {
  202. SceneObject so = UndoRedo.CreateSO("Quad", "Created a quad");
  203. Renderable renderable = so.AddComponent<Renderable>();
  204. renderable.Mesh = Builtin.Quad;
  205. Selection.SceneObject = so;
  206. EditorApplication.SetSceneDirty();
  207. }
  208. /// <summary>
  209. /// Creates a new scene object with a disc primitive.
  210. /// </summary>
  211. [MenuItem("Scene Objects/3D primitives/Disc", 8096)]
  212. private static void Add3DDisc()
  213. {
  214. SceneObject so = UndoRedo.CreateSO("Disc", "Created a disc");
  215. Renderable renderable = so.AddComponent<Renderable>();
  216. renderable.Mesh = Builtin.Disc;
  217. Selection.SceneObject = so;
  218. EditorApplication.SetSceneDirty();
  219. }
  220. }
  221. }