BsEditorApplication.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 a set of serializable editor settings that contain every globally customizable editor property. */
  29. SPtr<EditorSettings> getEditorSettings() const { return mEditorSettings; }
  30. /** Returns a set of serializable project settings that contain every customizable property specific to a project. */
  31. SPtr<ProjectSettings> getProjectSettings() const { return mProjectSettings; }
  32. /** Saves the current editor settings at the default location. */
  33. void saveEditorSettings();
  34. /** Saves the current project settings at the default location. Does nothing if no project is loaded. */
  35. void saveProjectSettings();
  36. /** Saves any project specific data, if a project is currently loaded. */
  37. void saveProject();
  38. /** Unloads the currently loaded project, if any. */
  39. void unloadProject();
  40. /**
  41. * Loads a new project, unloading the current one.
  42. *
  43. * @param[in] path Absolute path to the root project folder. Must be pointing to a valid project.
  44. */
  45. void loadProject(const Path& path);
  46. /**
  47. * Creates a new project at the specified path.
  48. *
  49. * @param[in] path Path to the folder where to create the project in. Name of this folder will be the name of
  50. * the project.
  51. */
  52. void createProject(const Path& path);
  53. /**
  54. * Checks is the provided folder a valid project.
  55. *
  56. * @param[in] path Absolute path to the root project folder.
  57. */
  58. bool isValidProjectPath(const Path& path);
  59. /** @copydoc Application::isEditor */
  60. bool isEditor() const override { return true; }
  61. /** Callback when the user requests application exit. The receiver is expected to handle shutdown if required. */
  62. Event<void()> onQuitRequested;
  63. private:
  64. /** @copydoc Module::onStartUp */
  65. void onStartUp() override;
  66. /** @copydoc Module::onShutDown */
  67. void onShutDown() override;
  68. /** @copydoc CoreApplication::preUpdate */
  69. void preUpdate() override;
  70. /** @copydoc CoreApplication::postUpdate */
  71. void postUpdate() override;
  72. /** @copydoc CoreApplication::quitRequested */
  73. void quitRequested() override;
  74. /** @copydoc Application::startUpRenderer */
  75. void startUpRenderer() override;
  76. /** @copydoc Application::startUpScriptManager */
  77. void startUpScriptManager() override;
  78. /** @copydoc Application::updateScriptManager */
  79. void updateScriptManager() 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. SPtr<EditorWidgetLayout> loadWidgetLayout();
  85. /** Saves the provided widget layout at the default layout location. */
  86. void saveWidgetLayout(const SPtr<EditorWidgetLayout>& layout);
  87. /** Saves the default widget layout in the provided folder. */
  88. void saveDefaultWidgetLayout(const Path& folder);
  89. /** Loads the previously saved editor settings from the default location. Overwrites any current settings. */
  90. void loadEditorSettings();
  91. /**
  92. * Loads the previously saved project settings from the default location within the active project. Loads default
  93. * settings if no project is active. Overwrites any current settings.
  94. */
  95. void loadProjectSettings();
  96. /** @copydoc Application::getShaderIncludeHandler */
  97. SPtr<IShaderIncludeHandler> getShaderIncludeHandler() const override;
  98. private:
  99. static const Path WIDGET_LAYOUT_PATH;
  100. static const Path BUILD_DATA_PATH;
  101. static const Path PROJECT_SETTINGS_PATH;
  102. SPtr<EditorSettings> mEditorSettings;
  103. SPtr<ProjectSettings> mProjectSettings;
  104. Path mBuiltinDataPath;
  105. bool mIsProjectLoaded;
  106. Path mProjectPath;
  107. String mProjectName;
  108. Timer mSplashScreenTimer;
  109. bool mSplashScreenShown = true;
  110. };
  111. /** Easy way to access EditorApplication. */
  112. BS_ED_EXPORT EditorApplication& gEditorApplication();
  113. /** @} */
  114. }