BsEditorApplication.h 4.4 KB

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