BsEditorApplication.h 4.9 KB

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