BsEditorApplication.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. #include "Utility/BsTimer.h"
  7. namespace bs
  8. {
  9. /** @addtogroup Application-Editor
  10. * @{
  11. */
  12. /** Primary editor class containing the editor entry point. */
  13. class BS_ED_EXPORT EditorApplication : public Application
  14. {
  15. public:
  16. EditorApplication();
  17. virtual ~EditorApplication();
  18. /** Starts the editor with the specified render and audio systems. */
  19. static void startUp();
  20. /** Checks whether the editor currently has a project loaded. */
  21. bool isProjectLoaded() const { return mIsProjectLoaded; }
  22. /** Returns the path to the currently loaded project. */
  23. const Path& getProjectPath() const { return mProjectPath; }
  24. /** Returns the name of the currently loaded project. */
  25. const String& getProjectName() const { return mProjectName; }
  26. /** Returns the absolute path where the builtin editor assets are located. */
  27. Path getDataPath() const { return mBuiltinDataPath; }
  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. SPtr<EditorSettings> getEditorSettings() const { return mEditorSettings; }
  36. /** Returns a set of serializable project settings that contain every customizable property specific to a project. */
  37. SPtr<ProjectSettings> 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. void onStartUp() override;
  70. /** @copydoc Module::onShutDown */
  71. void onShutDown() override;
  72. /** @copydoc CoreApplication::preUpdate */
  73. void preUpdate() override;
  74. /** @copydoc CoreApplication::postUpdate */
  75. void postUpdate() override;
  76. /** @copydoc CoreApplication::quitRequested */
  77. void quitRequested() override;
  78. /** @copydoc Application::loadScriptSystem */
  79. void loadScriptSystem() override;
  80. /** @copydoc Application::unloadScriptSystem */
  81. void unloadScriptSystem() override;
  82. /** @copydoc Application::startUpRenderer */
  83. void startUpRenderer() override;
  84. /**
  85. * Loads the previously saved editor widget layout from the default location. Can return null if no layout was
  86. * previously saved.
  87. */
  88. SPtr<EditorWidgetLayout> loadWidgetLayout();
  89. /** Saves the provided widget layout at the default layout location. */
  90. void saveWidgetLayout(const SPtr<EditorWidgetLayout>& layout);
  91. /** Saves the default widget layout in the provided folder. */
  92. void saveDefaultWidgetLayout(const Path& folder);
  93. /** Loads the previously saved editor settings from the default location. Overwrites any current settings. */
  94. void loadEditorSettings();
  95. /**
  96. * Loads the previously saved project settings from the default location within the active project. Loads default
  97. * settings if no project is active. Overwrites any current settings.
  98. */
  99. void loadProjectSettings();
  100. /** @copydoc Application::getShaderIncludeHandler */
  101. SPtr<IShaderIncludeHandler> getShaderIncludeHandler() const override;
  102. private:
  103. static const Path WIDGET_LAYOUT_PATH;
  104. static const Path BUILD_DATA_PATH;
  105. static const Path PROJECT_SETTINGS_PATH;
  106. SPtr<EditorSettings> mEditorSettings;
  107. SPtr<ProjectSettings> mProjectSettings;
  108. Path mBuiltinDataPath;
  109. bool mIsProjectLoaded;
  110. Path mProjectPath;
  111. String mProjectName;
  112. Timer mSplashScreenTimer;
  113. bool mSplashScreenShown = true;
  114. DynLib* mSBansheeEditorPlugin;
  115. };
  116. /** Easy way to access EditorApplication. */
  117. BS_ED_EXPORT EditorApplication& gEditorApplication();
  118. /** @} */
  119. }