BsEditorApplication.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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 Unloads the currently loaded project, if any.
  63. */
  64. void unloadProject();
  65. /**
  66. * @brief Loads a new project, unloading the current one.
  67. *
  68. * @param path Absolute path to the root project folder. Must be pointing
  69. * to a valid project.
  70. */
  71. void loadProject(const Path& path);
  72. /**
  73. * @brief Checks is the provided folder a valid project.
  74. *
  75. * @param path Absolute path to the root project folder.
  76. */
  77. bool isValidProjectPath(const Path& path);
  78. private:
  79. /**
  80. * @copydoc Module::onStartUp
  81. */
  82. virtual void onStartUp() override;
  83. /**
  84. * @copydoc Module::onShutDown
  85. */
  86. virtual void onShutDown() override;
  87. /**
  88. * @copydoc Module::preUpdate
  89. */
  90. virtual void preUpdate() override;
  91. /**
  92. * @copydoc Module::postUpdate
  93. */
  94. virtual void postUpdate() override;
  95. /**
  96. * @copydoc Application::loadScriptSystem
  97. */
  98. void loadScriptSystem() override;
  99. /**
  100. * @brief Loads the previously saved editor widget layout from the default location.
  101. * Can return null if no layout was previously saved.
  102. */
  103. EditorWidgetLayoutPtr loadWidgetLayout();
  104. /**
  105. * @brief Saves the provided widget layout at the default layout location.
  106. */
  107. void saveWidgetLayout(const EditorWidgetLayoutPtr& layout);
  108. /**
  109. * @brief Loads the previously saved editor settings from the default location.
  110. * Overwrites any current settings.
  111. */
  112. void loadEditorSettings();
  113. /**
  114. * @brief Loads the previously saved project settings from the default location
  115. * within the active project. Loads default settings if no project is active.
  116. * Overwrites any current settings.
  117. */
  118. void loadProjectSettings();
  119. /**
  120. * @copydoc Application::getShaderIncludeHandler
  121. */
  122. virtual ShaderIncludeHandlerPtr getShaderIncludeHandler() const override;
  123. private:
  124. static const Path WIDGET_LAYOUT_PATH;
  125. static const Path BUILD_DATA_PATH;
  126. static const Path EDITOR_SETTINGS_PATH;
  127. static const Path PROJECT_SETTINGS_PATH;
  128. RenderAPIPlugin mActiveRAPIPlugin;
  129. EditorSettingsPtr mEditorSettings;
  130. ProjectSettingsPtr mProjectSettings;
  131. bool mIsProjectLoaded;
  132. Path mProjectPath;
  133. WString mProjectName;
  134. DynLib* mSBansheeEditorPlugin;
  135. // DEBUG ONLY
  136. HShader mTestShader;
  137. HMaterial mTestMaterial;
  138. HTexture mTestTexRef;
  139. HMesh mDbgMeshRef;
  140. };
  141. /**
  142. * @brief Returns the globally accessible instance of editor application.
  143. */
  144. BS_ED_EXPORT EditorApplication& gEditorApplication();
  145. }