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