BsEditorApplication.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsEditorPrerequisites.h"
  5. #include "BsApplication.h"
  6. namespace BansheeEngine
  7. {
  8. /** @addtogroup Application-Editor
  9. * @{
  10. */
  11. /** Types of render APIs supported by the editor. */
  12. enum class EditorRenderAPI
  13. {
  14. DX11,
  15. OpenGL
  16. };
  17. /** Primary editor class containing the editor entry point. */
  18. class BS_ED_EXPORT EditorApplication : public Application
  19. {
  20. public:
  21. EditorApplication(EditorRenderAPI renderAPI);
  22. virtual ~EditorApplication();
  23. /** Starts the editor with the specified render system. */
  24. static void startUp(EditorRenderAPI renderAPI);
  25. /** Checks whether the editor currently has a project loaded. */
  26. bool isProjectLoaded() const { return mIsProjectLoaded; }
  27. /** Returns the path to the currently loaded project. */
  28. const Path& getProjectPath() const { return mProjectPath; }
  29. /** Returns the name of the currently loaded project. */
  30. const WString& getProjectName() const { return mProjectName; }
  31. /** Returns the absolute path to the built-in managed editor assembly file. */
  32. Path getEditorAssemblyPath() const;
  33. /** Returns the absolute path of the managed editor script assembly file. */
  34. Path getEditorScriptAssemblyPath() const;
  35. /** @copydoc Application::getScriptAssemblyFolder */
  36. Path getScriptAssemblyFolder() const override;
  37. /** Returns a set of serializable editor settings that contain every globally customizable editor property. */
  38. EditorSettingsPtr getEditorSettings() const { return mEditorSettings; }
  39. /** Returns a set of serializable project settings that contain every customizable property specific to a project. */
  40. ProjectSettingsPtr getProjectSettings() const { return mProjectSettings; }
  41. /** Saves the current editor settings at the default location. */
  42. void saveEditorSettings();
  43. /** Saves the current project settings at the default location. Does nothing if no project is loaded. */
  44. void saveProjectSettings();
  45. /** Saves any project specific data, if a project is currently loaded. */
  46. void saveProject();
  47. /** Unloads the currently loaded project, if any. */
  48. void unloadProject();
  49. /**
  50. * Loads a new project, unloading the current one.
  51. *
  52. * @param[in] path Absolute path to the root project folder. Must be pointing to a valid project.
  53. */
  54. void loadProject(const Path& path);
  55. /**
  56. * Creates a new project at the specified path.
  57. *
  58. * @param[in] path Path to the folder where to create the project in. Name of this folder will be the name of
  59. * the project.
  60. */
  61. void createProject(const Path& path);
  62. /**
  63. * Checks is the provided folder a valid project.
  64. *
  65. * @param[in] path Absolute path to the root project folder.
  66. */
  67. bool isValidProjectPath(const Path& path);
  68. /** @copydoc Application::isEditor */
  69. bool isEditor() const override { return true; }
  70. private:
  71. /** @copydoc Module::onStartUp */
  72. virtual void onStartUp() override;
  73. /** @copydoc Module::onShutDown */
  74. virtual void onShutDown() override;
  75. /** @copydoc CoreApplication::preUpdate */
  76. virtual void preUpdate() override;
  77. /** @copydoc CoreApplication::postUpdate */
  78. virtual void postUpdate() override;
  79. /** @copydoc CoreApplication::quitRequested */
  80. virtual void quitRequested() override;
  81. /** @copydoc Application::loadScriptSystem */
  82. void loadScriptSystem() override;
  83. /**
  84. * Loads the previously saved editor widget layout from the default location. Can return null if no layout was
  85. * previously saved.
  86. */
  87. EditorWidgetLayoutPtr loadWidgetLayout();
  88. /** Saves the provided widget layout at the default layout location. */
  89. void saveWidgetLayout(const EditorWidgetLayoutPtr& layout);
  90. /** Loads the previously saved editor settings from the default location. Overwrites any current settings. */
  91. void loadEditorSettings();
  92. /**
  93. * Loads the previously saved project settings from the default location within the active project. Loads default
  94. * settings if no project is active. Overwrites any current settings.
  95. */
  96. void loadProjectSettings();
  97. /** @copydoc Application::getShaderIncludeHandler */
  98. virtual ShaderIncludeHandlerPtr getShaderIncludeHandler() const override;
  99. /** Converts a render API type supported by the editor into a type recognized by the lower layers of the engine. */
  100. static RenderAPIPlugin toEngineRenderAPI(EditorRenderAPI renderAPI);
  101. private:
  102. static const Path WIDGET_LAYOUT_PATH;
  103. static const Path BUILD_DATA_PATH;
  104. static const Path PROJECT_SETTINGS_PATH;
  105. RenderAPIPlugin mActiveRAPIPlugin;
  106. EditorSettingsPtr mEditorSettings;
  107. ProjectSettingsPtr mProjectSettings;
  108. bool mIsProjectLoaded;
  109. Path mProjectPath;
  110. WString mProjectName;
  111. DynLib* mSBansheeEditorPlugin;
  112. };
  113. /** Easy way to access EditorApplication. */
  114. BS_ED_EXPORT EditorApplication& gEditorApplication();
  115. /** @} */
  116. }