Project.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. //
  2. // Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #include <Atomic/Core/Object.h>
  23. #include <Atomic/IO/FileSystem.h>
  24. using namespace Atomic;
  25. #include "../Platform/Platform.h"
  26. namespace ToolCore
  27. {
  28. class ProjectUserPrefs;
  29. class ProjectBuildSettings;
  30. class ProjectSettings;
  31. class Project : public Object
  32. {
  33. friend class ProjectFile;
  34. ATOMIC_OBJECT(Project, Object);
  35. public:
  36. /// Construct.
  37. Project(Context* context);
  38. /// Destruct.
  39. virtual ~Project();
  40. bool Load(const String& fullpath);
  41. void Save(const String& fullpath = "");
  42. /// Paths
  43. const String& GetResourcePath() { return resourcePath_; }
  44. void SetResourcePath(const String& resourcePath)
  45. {
  46. resourcePath_ = AddTrailingSlash(resourcePath);
  47. componentsPath_ = resourcePath_ + "Components";
  48. scriptsPath_ = resourcePath_ + "Scripts";
  49. modulesPath_ = resourcePath_ + "Modules";
  50. }
  51. const String& GetComponentsPath() { return componentsPath_; }
  52. const String& GetScriptsPath() { return scriptsPath_; }
  53. const String& GetModulesPath() { return modulesPath_; }
  54. bool IsComponentsDirOrFile(const String& fullPath);
  55. bool IsScriptsDirOrFile(const String& fullPath);
  56. bool IsModulesDirOrFile(const String& fullPath);
  57. bool GetSupportsPlatform(const String& platform) const;
  58. bool IsDirty() { return dirty_; }
  59. void SetDirty() { if (!loading_) dirty_ = true; }
  60. ProjectBuildSettings* GetBuildSettings() { return buildSettings_; }
  61. ProjectUserPrefs* GetUserPrefs() { return userPrefs_; }
  62. ProjectSettings* GetProjectSettings() { return projectSettings_; }
  63. const String& GetProjectPath() const { return projectPath_; }
  64. const String& GetProjectFilePath() { return projectFilePath_; }
  65. String GetUserPrefsFullPath();
  66. String GetBuildSettingsFullPath();
  67. const String& GetVersion() { return version_; }
  68. void SetVersion(const String& version) { version_ = version; }
  69. void SaveBuildSettings();
  70. bool LoadBuildSettings();
  71. bool LoadProjectSettings();
  72. void SaveUserPrefs();
  73. bool LoadUserPrefs();
  74. private:
  75. String version_;
  76. String projectPath_;
  77. String projectFilePath_;
  78. String resourcePath_;
  79. String componentsPath_;
  80. String scriptsPath_;
  81. String modulesPath_;
  82. bool loading_;
  83. bool dirty_;
  84. SharedPtr<ProjectUserPrefs> userPrefs_;
  85. SharedPtr<ProjectBuildSettings> buildSettings_;
  86. SharedPtr<ProjectSettings> projectSettings_;
  87. };
  88. }