BsBuiltinEditorResources.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsEditorPrerequisites.h"
  5. #include "GUI/BsGUISkin.h"
  6. #include "Utility/BsModule.h"
  7. #include "GUI/BsGUIContent.h"
  8. #include "BsApplication.h"
  9. namespace bs
  10. {
  11. /** @addtogroup Utility-Editor
  12. * @{
  13. */
  14. /** Types of valid icons used when viewing the project library. */
  15. enum class ProjectIcon
  16. {
  17. Folder, Mesh, Font, Texture, PlainText, ScriptCode, SpriteTexture, Shader, ShaderInclude, Material, Prefab, GUISkin,
  18. PhysicsMaterial, PhysicsMesh, AudioClip, AnimationClip
  19. };
  20. /** Types of icons that may be displayed on the tool bar. */
  21. enum class ToolbarIcon
  22. {
  23. NewCamera, NewRenderable, NewPointLight, NewDirLight, NewSpotLight, NewSceneObject, NewCube, NewSphere, NewCone,
  24. NewQuad, NewMat, NewCSScript, NewShader, NewSpriteTex, Pause, Play, Step, Undo, Redo, OpenProject, SaveProject,
  25. SaveScene
  26. };
  27. /** Types of icons that may be displayed in the scene window. */
  28. enum class SceneWindowIcon
  29. {
  30. View, Move, Rotate, Scale, Pivot, Center, Local, World, MoveSnap, RotateSnap
  31. };
  32. /** Types of icons that may be displayed in the inspector window. */
  33. enum class InspectorWindowIcon
  34. {
  35. Create, Clone, Clear, Resize, Delete, MoveUp, MoveDown, Edit, Apply, Add, Cancel
  36. };
  37. /** Types of icons that may be displayed in the library window. */
  38. enum class LibraryWindowIcon
  39. {
  40. Home, Up, Clear, Options
  41. };
  42. /** Types of icons that may be displayed in the animation editor window. */
  43. enum class AnimationWindowIcon
  44. {
  45. Play, Record, FrameForward, FrameBack, AddKeyframe, AddEvent, Keyframe, Event
  46. };
  47. /** Types of icons used in various areas throughout the editor. */
  48. enum class EditorIcon
  49. {
  50. X, Component, SceneObject
  51. };
  52. /** Types of icons to be used along with log messages depending on their severity. */
  53. enum class LogMessageIcon
  54. {
  55. Info, Warning, Error
  56. };
  57. /** Contains a set of built-in resources used by the editor. */
  58. class BS_ED_EXPORT BuiltinEditorResources : public bs::Module<BuiltinEditorResources>
  59. {
  60. public:
  61. BuiltinEditorResources();
  62. /** Returns the default editor GUI skin. */
  63. const HGUISkin& getSkin() const { return mSkin; }
  64. /** Returns the default font used by the editor. */
  65. const HFont& getDefaultFont() const { return mDefaultFont; }
  66. /** Returns the default antialiased font used by the editor. */
  67. const HFont& getDefaultAAFont() const { return mDefaultAAFont; }
  68. /** Creates a material used for docking drop overlay used by the editor. */
  69. HMaterial createDockDropOverlayMaterial() const;
  70. /** Creates a material used for rendering the scene grid. */
  71. HMaterial createSceneGridMaterial() const;
  72. /** Creates a material used for picking non-transparent objects in scene view. */
  73. HMaterial createPicking(CullingMode cullMode) const;
  74. /** Creates a material used for picking transparent objects in scene view. */
  75. HMaterial createPickingAlpha(CullingMode cullMode) const;
  76. /** Creates a material used for rendering line gizmos. */
  77. HMaterial createLineGizmoMat() const;
  78. /** Creates a material used for rendering solid gizmos. */
  79. HMaterial createSolidGizmoMat() const;
  80. /** Creates a material used for rendering wireframe gizmos. */
  81. HMaterial createWireGizmoMat() const;
  82. /** Creates a material used for rendering icon gizmos. */
  83. HMaterial createIconGizmoMat() const;
  84. /** Creates a material used for picking non-transparent gizmos. */
  85. HMaterial createGizmoPickingMat() const;
  86. /** Creates a material used for picking transparent gizmos. */
  87. HMaterial createAlphaGizmoPickingMat() const;
  88. /** Creates a material used for rendering line handles. */
  89. HMaterial createLineHandleMat() const;
  90. /** Creates a material used for rendering solid handles. */
  91. HMaterial createSolidHandleMat() const;
  92. /** Creates a material used for rendering text for gizmos and handles. */
  93. HMaterial createTextGizmoMat() const;
  94. /** Creates a material used for clearing the alpha channel of the handle rendering texture. */
  95. HMaterial createHandleClearAlphaMat() const;
  96. /** Creates a material used for displaying selected objects. */
  97. HMaterial createSelectionMat() const;
  98. /**
  99. * Retrieves an icon that represents a specific resource type that may be displayed when viewing the project
  100. * library.
  101. */
  102. HSpriteTexture getLibraryIcon(ProjectIcon icon, int size) const;
  103. /** Retrieves an icon that may be displayed on the main window's toolbar. */
  104. HSpriteTexture getToolbarIcon(ToolbarIcon icon) const;
  105. /** Retrieves an icon that may be displayed on the scene window. */
  106. GUIContentImages getSceneWindowIcon(SceneWindowIcon icon) const;
  107. /** Retrieves an icon that may be displayed on the library window. */
  108. HSpriteTexture getLibraryWindowIcon(LibraryWindowIcon icon) const;
  109. /** Retrieves an icon that may be displayed on the inspector window. */
  110. HSpriteTexture getInspectorWindowIcon(InspectorWindowIcon icon) const;
  111. /** Retrieves an icon that may be displayed on the animation editor window. */
  112. GUIContentImages getAnimationWindowIcon(AnimationWindowIcon icon) const;
  113. /** Retrieves an icon that represents a specific generic editor icon. */
  114. HSpriteTexture getIcon(EditorIcon icon) const;
  115. /** Retrieves an icon that represents a specific log message type. */
  116. HSpriteTexture getLogMessageIcon(LogMessageIcon icon, UINT32 size, bool dark) const;
  117. /** Returns text contained in the default "empty" shader. */
  118. String getEmptyShaderCode() const;
  119. /** Returns text contained in the default "empty" C# script. */
  120. String getEmptyCSScriptCode() const;
  121. /** Returns image data the Banshee Engine splash screen. */
  122. static SPtr<PixelData> getSplashScreen();
  123. /** Returns absolute path to the builtin shader include folder. */
  124. static Path getShaderIncludeFolder();
  125. /** Returns absolute path to the default widget layout file. */
  126. static Path getDefaultWidgetLayoutPath();
  127. static const String ObjectFieldStyleName;
  128. static const String ObjectFieldLabelStyleName;
  129. static const String ObjectFieldDropBtnStyleName;
  130. static const String ObjectFieldClearBtnStyleName;
  131. static const String TextureFieldStyleName;
  132. static const String TextureFieldLabelStyleName;
  133. static const String TextureFieldDropStyleName;
  134. static const String TextureFieldClearBtnStyleName;
  135. private:
  136. /**
  137. * Imports all necessary resources and converts them to engine-ready format.
  138. *
  139. * @note
  140. * Normally you only want to use this during development phase and then ship with engine-ready format only.
  141. */
  142. void preprocess(bool forceImport, time_t lastUpdateTime);
  143. /** Generates the default editor skin and all GUI element styles. */
  144. SPtr<GUISkin> generateGUISkin();
  145. /** Loads a GUI icon with the specified filename. */
  146. HSpriteTexture getGUIIcon(const String& name) const;
  147. /** Loads a shader with the specified filename */
  148. HShader getShader(const String& name) const;
  149. HShader mShaderDockOverlay;
  150. HShader mShaderSceneGrid;
  151. HShader mShaderPicking[3];
  152. HShader mShaderPickingAlpha[3];
  153. HShader mShaderGizmoSolid;
  154. HShader mShaderGizmoWire;
  155. HShader mShaderGizmoLine;
  156. HShader mShaderGizmoIcon;
  157. HShader mShaderGizmoPicking;
  158. HShader mShaderGizmoAlphaPicking;
  159. HShader mShaderGizmoText;
  160. HShader mShaderHandleSolid;
  161. HShader mShaderHandleLine;
  162. HShader mShaderHandleClearAlpha;
  163. HShader mShaderSelection;
  164. HFont mDefaultFont;
  165. HFont mDefaultAAFont;
  166. HGUISkin mSkin;
  167. SPtr<ResourceManifest> mResourceManifest;
  168. static const char* ShaderFolder;
  169. static const char* SkinFolder;
  170. static const char* IconFolder;
  171. static const char* ShaderIncludeFolder;
  172. static const char* SpriteSubFolder;
  173. static constexpr const char* DATA_LIST_JSON = "DataList.json";
  174. static constexpr const char* GUI_SKIN_JSON = "GUISkin.json";
  175. Path BuiltinDataFolder;
  176. Path EditorSkinFolder;
  177. Path EditorSkinSpritesFolder;
  178. Path EditorIconFolder;
  179. Path EditorIconSpritesFolder;
  180. Path EditorShaderFolder;
  181. Path EditorShaderIncludeFolder;
  182. Path BuiltinRawDataFolder;
  183. Path EditorRawSkinFolder;
  184. Path EditorRawIconsFolder;
  185. Path EditorRawShaderIncludeFolder;
  186. Path EditorRawShaderFolder;
  187. Path ResourceManifestPath;
  188. static const String DefaultFontFilename;
  189. static const String DefaultAAFontFilename;
  190. static const UINT32 DefaultFontSize;
  191. static const UINT32 TitleFontSize;
  192. static const Color TextNormalColor;
  193. static const Color TextActiveColor;
  194. static const String GUISkinFile;
  195. static const String XButtonNormalTex;
  196. static const String FolderIconTex;
  197. static const String MeshIconTex;
  198. static const String TextureIconTex;
  199. static const String FontIconTex;
  200. static const String PlainTextIconTex;
  201. static const String ScriptCodeIconTex;
  202. static const String ShaderIconTex;
  203. static const String ShaderIncludeIconTex;
  204. static const String MaterialIconTex;
  205. static const String SpriteTextureIconTex;
  206. static const String PrefabIconTex;
  207. static const String GUISkinIconTex;
  208. static const String PhysicsMaterialIconTex;
  209. static const String PhysicsMeshIconTex;
  210. static const String AudioClipIconTex;
  211. static const String AnimationClipIconTex;
  212. static const String ShaderDockOverlayFile;
  213. static const String ShaderSceneGridFile;
  214. static const String ShaderPickingCullNoneFile;
  215. static const String ShaderPickingCullCWFile;
  216. static const String ShaderPickingCullCCWFile;
  217. static const String ShaderPickingAlphaCullNoneFile;
  218. static const String ShaderPickingAlphaCullCWFile;
  219. static const String ShaderPickingAlphaCullCCWFile;
  220. static const String ShaderLineGizmoFile;
  221. static const String ShaderSolidGizmoFile;
  222. static const String ShaderWireGizmoFile;
  223. static const String ShaderLineHandleFile;
  224. static const String ShaderSolidHandleFile;
  225. static const String ShaderHandleClearAlphaFile;
  226. static const String ShaderIconGizmoFile;
  227. static const String ShaderGizmoPickingFile;
  228. static const String ShaderGizmoPickingAlphaFile;
  229. static const String ShaderTextGizmoFile;
  230. static const String ShaderSelectionFile;
  231. static const String EmptyShaderCodeFile;
  232. static const String EmptyCSScriptCodeFile;
  233. static const char* SplashScreenName;
  234. };
  235. /** @} */
  236. }