BsEditorApplication.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsApplication.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief Types of render APIs supported by the editor.
  8. */
  9. enum class EditorRenderAPI
  10. {
  11. DX11,
  12. OpenGL
  13. };
  14. /**
  15. * @brief Primary editor class containing the editor entry point.
  16. */
  17. class BS_ED_EXPORT EditorApplication : public Application
  18. {
  19. public:
  20. EditorApplication(EditorRenderAPI renderAPI);
  21. virtual ~EditorApplication();
  22. /**
  23. * @brief Starts the editor with the specified render system.
  24. */
  25. static void startUp(EditorRenderAPI renderAPI);
  26. /**
  27. * @brief Checks whether the editor currently has a project loaded.
  28. */
  29. bool isProjectLoaded() const { return mIsProjectLoaded; }
  30. /**
  31. * @brief Returns the path to the currently loaded project.
  32. */
  33. const Path& getProjectPath() const { return mProjectPath; }
  34. /**
  35. * @brief Returns the name of the currently loaded project.
  36. */
  37. const WString& getProjectName() const { return mProjectName; }
  38. /**
  39. * @brief Returns the absolute path to the built-in managed editor assembly file.
  40. */
  41. Path getEditorAssemblyPath() const;
  42. /**
  43. * @brief Returns the absolute path of the managed editor script assembly file.
  44. */
  45. Path getEditorScriptAssemblyPath() const;
  46. /**
  47. * @copydoc Application::getScriptAssemblyFolder
  48. */
  49. Path getScriptAssemblyFolder() const override;
  50. /**
  51. * @brief Returns a set of serializable editor settings that contain
  52. * every globally customizable editor property.
  53. */
  54. EditorSettingsPtr getEditorSettings() const { return mEditorSettings; }
  55. /**
  56. * @brief Returns a set of serializable project settings that contain
  57. * every customizable property specific to a project.
  58. */
  59. ProjectSettingsPtr getProjectSettings() const { return mProjectSettings; }
  60. /**
  61. * @brief Saves the current editor settings at the default location.
  62. */
  63. void saveEditorSettings();
  64. /**
  65. * @brief Saves the current project settings at the default location.
  66. * Does nothing if no project is loaded.
  67. */
  68. void saveProjectSettings();
  69. /**
  70. * @brief Saves any project specific data, if a project is currently loaded.
  71. */
  72. void saveProject();
  73. /**
  74. * @brief Unloads the currently loaded project, if any.
  75. */
  76. void unloadProject();
  77. /**
  78. * @brief Loads a new project, unloading the current one.
  79. *
  80. * @param path Absolute path to the root project folder. Must be pointing
  81. * to a valid project.
  82. */
  83. void loadProject(const Path& path);
  84. /**
  85. * @brief Creates a new project at the specified path.
  86. *
  87. * @param path Path to the folder where to create the project in. Name of this
  88. * folder will be the name of the project.
  89. */
  90. void createProject(const Path& path);
  91. /**
  92. * @brief Checks is the provided folder a valid project.
  93. *
  94. * @param path Absolute path to the root project folder.
  95. */
  96. bool isValidProjectPath(const Path& path);
  97. private:
  98. /**
  99. * @copydoc Module::onStartUp
  100. */
  101. virtual void onStartUp() override;
  102. /**
  103. * @copydoc Module::onShutDown
  104. */
  105. virtual void onShutDown() override;
  106. /**
  107. * @copydoc Module::preUpdate
  108. */
  109. virtual void preUpdate() override;
  110. /**
  111. * @copydoc Module::postUpdate
  112. */
  113. virtual void postUpdate() override;
  114. /**
  115. * @copydoc Application::loadScriptSystem
  116. */
  117. void loadScriptSystem() override;
  118. /**
  119. * @brief Loads the previously saved editor widget layout from the default location.
  120. * Can return null if no layout was previously saved.
  121. */
  122. EditorWidgetLayoutPtr loadWidgetLayout();
  123. /**
  124. * @brief Saves the provided widget layout at the default layout location.
  125. */
  126. void saveWidgetLayout(const EditorWidgetLayoutPtr& layout);
  127. /**
  128. * @brief Loads the previously saved editor settings from the default location.
  129. * Overwrites any current settings.
  130. */
  131. void loadEditorSettings();
  132. /**
  133. * @brief Loads the previously saved project settings from the default location
  134. * within the active project. Loads default settings if no project is active.
  135. * Overwrites any current settings.
  136. */
  137. void loadProjectSettings();
  138. /**
  139. * @copydoc Application::getShaderIncludeHandler
  140. */
  141. virtual ShaderIncludeHandlerPtr getShaderIncludeHandler() const override;
  142. /**
  143. * @brief Converts a render API type supported by the editor into a type recognized by the lower
  144. * layers of the engine.
  145. */
  146. static RenderAPIPlugin toEngineRenderAPI(EditorRenderAPI renderAPI);
  147. private:
  148. static const Path WIDGET_LAYOUT_PATH;
  149. static const Path BUILD_DATA_PATH;
  150. static const Path EDITOR_SETTINGS_PATH;
  151. static const Path PROJECT_SETTINGS_PATH;
  152. RenderAPIPlugin mActiveRAPIPlugin;
  153. EditorSettingsPtr mEditorSettings;
  154. ProjectSettingsPtr mProjectSettings;
  155. bool mIsProjectLoaded;
  156. Path mProjectPath;
  157. WString mProjectName;
  158. DynLib* mSBansheeEditorPlugin;
  159. };
  160. /**
  161. * @brief Returns the globally accessible instance of editor application.
  162. */
  163. BS_ED_EXPORT EditorApplication& gEditorApplication();
  164. }