MenuItems.cs 8.9 KB

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