BsEditorApplication.h 4.7 KB

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