Project.h 3.4 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 Project : public Object
  31. {
  32. friend class ProjectFile;
  33. OBJECT(Project);
  34. public:
  35. /// Construct.
  36. Project(Context* context);
  37. /// Destruct.
  38. virtual ~Project();
  39. bool Load(const String& fullpath);
  40. void Save(const String& fullpath = "");
  41. /// Paths
  42. const String& GetResourcePath() { return resourcePath_; }
  43. void SetResourcePath(const String& resourcePath)
  44. {
  45. resourcePath_ = AddTrailingSlash(resourcePath);
  46. componentsPath_ = resourcePath_ + "Components";
  47. scriptsPath_ = resourcePath_ + "Scripts";
  48. modulesPath_ = resourcePath_ + "Modules";
  49. }
  50. const String& GetComponentsPath() { return componentsPath_; }
  51. const String& GetScriptsPath() { return scriptsPath_; }
  52. const String& GetModulesPath() { return modulesPath_; }
  53. bool IsComponentsDirOrFile(const String& fullPath);
  54. bool IsScriptsDirOrFile(const String& fullPath);
  55. bool IsModulesDirOrFile(const String& fullPath);
  56. void AddPlatform(PlatformID platformID);
  57. bool ContainsPlatform(PlatformID platformID);
  58. void RemovePlatform(PlatformID platformID);
  59. bool IsDirty() { return dirty_; }
  60. void SetDirty() { if (!loading_) dirty_ = true; }
  61. ProjectBuildSettings* GetBuildSettings() { return buildSettings_; }
  62. ProjectUserPrefs* GetUserPrefs() { return userPrefs_; }
  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. void SaveUserPrefs();
  72. bool LoadUserPrefs();
  73. private:
  74. String version_;
  75. String projectPath_;
  76. String projectFilePath_;
  77. String resourcePath_;
  78. String componentsPath_;
  79. String scriptsPath_;
  80. String modulesPath_;
  81. bool loading_;
  82. bool dirty_;
  83. SharedPtr<ProjectUserPrefs> userPrefs_;
  84. SharedPtr<ProjectBuildSettings> buildSettings_;
  85. List<PlatformID> platforms_;
  86. };
  87. }