BsEditorApplication.h 5.0 KB

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