BsEditorApplication.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. static const Path PROJECT_INTERNAL_DIR;
  90. private:
  91. /**
  92. * @copydoc Module::onStartUp
  93. */
  94. virtual void onStartUp() override;
  95. /**
  96. * @copydoc Module::onShutDown
  97. */
  98. virtual void onShutDown() override;
  99. /**
  100. * @copydoc Module::preUpdate
  101. */
  102. virtual void preUpdate() override;
  103. /**
  104. * @copydoc Module::postUpdate
  105. */
  106. virtual void postUpdate() override;
  107. /**
  108. * @copydoc Application::loadScriptSystem
  109. */
  110. void loadScriptSystem() override;
  111. /**
  112. * @brief Loads the previously saved editor widget layout from the default location.
  113. * Can return null if no layout was previously saved.
  114. */
  115. EditorWidgetLayoutPtr loadWidgetLayout();
  116. /**
  117. * @brief Saves the provided widget layout at the default layout location.
  118. */
  119. void saveWidgetLayout(const EditorWidgetLayoutPtr& layout);
  120. /**
  121. * @brief Loads the previously saved editor settings from the default location.
  122. * Overwrites any current settings.
  123. */
  124. void loadEditorSettings();
  125. /**
  126. * @brief Loads the previously saved project settings from the default location
  127. * within the active project. Loads default settings if no project is active.
  128. * Overwrites any current settings.
  129. */
  130. void loadProjectSettings();
  131. /**
  132. * @copydoc Application::getShaderIncludeHandler
  133. */
  134. virtual ShaderIncludeHandlerPtr getShaderIncludeHandler() const override;
  135. private:
  136. static const Path WIDGET_LAYOUT_PATH;
  137. static const Path BUILD_DATA_PATH;
  138. static const Path EDITOR_SETTINGS_PATH;
  139. static const Path PROJECT_SETTINGS_PATH;
  140. RenderAPIPlugin mActiveRAPIPlugin;
  141. EditorSettingsPtr mEditorSettings;
  142. ProjectSettingsPtr mProjectSettings;
  143. bool mIsProjectLoaded;
  144. Path mProjectPath;
  145. WString mProjectName;
  146. DynLib* mSBansheeEditorPlugin;
  147. // DEBUG ONLY
  148. HShader mTestShader;
  149. HMaterial mTestMaterial;
  150. HTexture mTestTexRef;
  151. HMesh mDbgMeshRef;
  152. };
  153. /**
  154. * @brief Returns the globally accessible instance of editor application.
  155. */
  156. BS_ED_EXPORT EditorApplication& gEditorApplication();
  157. }