BsEditorApplication.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. /**
  98. * @copydoc Application::isEditor
  99. */
  100. bool isEditor() const override { return true; }
  101. private:
  102. /**
  103. * @copydoc Module::onStartUp
  104. */
  105. virtual void onStartUp() override;
  106. /**
  107. * @copydoc Module::onShutDown
  108. */
  109. virtual void onShutDown() override;
  110. /**
  111. * @copydoc CoreApplication::preUpdate
  112. */
  113. virtual void preUpdate() override;
  114. /**
  115. * @copydoc CoreApplication::postUpdate
  116. */
  117. virtual void postUpdate() override;
  118. /**
  119. * @copydoc CoreApplication::quitRequested
  120. */
  121. virtual void quitRequested() override;
  122. /**
  123. * @copydoc Application::loadScriptSystem
  124. */
  125. void loadScriptSystem() override;
  126. /**
  127. * @brief Loads the previously saved editor widget layout from the default location.
  128. * Can return null if no layout was previously saved.
  129. */
  130. EditorWidgetLayoutPtr loadWidgetLayout();
  131. /**
  132. * @brief Saves the provided widget layout at the default layout location.
  133. */
  134. void saveWidgetLayout(const EditorWidgetLayoutPtr& layout);
  135. /**
  136. * @brief Loads the previously saved editor settings from the default location.
  137. * Overwrites any current settings.
  138. */
  139. void loadEditorSettings();
  140. /**
  141. * @brief Loads the previously saved project settings from the default location
  142. * within the active project. Loads default settings if no project is active.
  143. * Overwrites any current settings.
  144. */
  145. void loadProjectSettings();
  146. /**
  147. * @copydoc Application::getShaderIncludeHandler
  148. */
  149. virtual ShaderIncludeHandlerPtr getShaderIncludeHandler() const override;
  150. /**
  151. * @brief Converts a render API type supported by the editor into a type recognized by the lower
  152. * layers of the engine.
  153. */
  154. static RenderAPIPlugin toEngineRenderAPI(EditorRenderAPI renderAPI);
  155. private:
  156. static const Path WIDGET_LAYOUT_PATH;
  157. static const Path BUILD_DATA_PATH;
  158. static const Path PROJECT_SETTINGS_PATH;
  159. RenderAPIPlugin mActiveRAPIPlugin;
  160. EditorSettingsPtr mEditorSettings;
  161. ProjectSettingsPtr mProjectSettings;
  162. bool mIsProjectLoaded;
  163. Path mProjectPath;
  164. WString mProjectName;
  165. DynLib* mSBansheeEditorPlugin;
  166. };
  167. /**
  168. * @brief Returns the globally accessible instance of editor application.
  169. */
  170. BS_ED_EXPORT EditorApplication& gEditorApplication();
  171. }