|
|
@@ -12,6 +12,7 @@
|
|
|
|
|
|
#include <Atomic/Resource/JSONFile.h>
|
|
|
|
|
|
+#include "../ToolSystem.h"
|
|
|
#include "../Platform/Platform.h"
|
|
|
|
|
|
#include "ProjectFile.h"
|
|
|
@@ -26,8 +27,10 @@ namespace ToolCore
|
|
|
|
|
|
Project::Project(Context* context) :
|
|
|
Object(context),
|
|
|
+ loading_(false),
|
|
|
dirty_(false)
|
|
|
{
|
|
|
+ version_ = "1.0.0";
|
|
|
userPrefs_ = new ProjectUserPrefs(context_);
|
|
|
buildSettings_ = new ProjectBuildSettings(context_);
|
|
|
}
|
|
|
@@ -37,84 +40,33 @@ Project::~Project()
|
|
|
|
|
|
}
|
|
|
|
|
|
-void Project::LoadUserPrefs(const String& fullpath)
|
|
|
+void Project::SaveUserPrefs()
|
|
|
{
|
|
|
- rapidjson::Document document;
|
|
|
|
|
|
- File jsonFile(context_, fullpath);
|
|
|
-
|
|
|
- if (!jsonFile.IsOpen())
|
|
|
- return;
|
|
|
-
|
|
|
- String json;
|
|
|
- jsonFile.ReadText(json);
|
|
|
-
|
|
|
- if (!json.Length())
|
|
|
- return;
|
|
|
-
|
|
|
- if (document.Parse<0>(json.CString()).HasParseError())
|
|
|
- {
|
|
|
- LOGERRORF("Could not parse Project JSON data from %s", fullpath.CString());
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- const Value::Member* current_platform = document.FindMember("current_platform");
|
|
|
+}
|
|
|
|
|
|
- /*
|
|
|
- AEEditorPlatform platform = AE_PLATFORM_UNDEFINED;
|
|
|
- if (current_platform && current_platform->value.IsString())
|
|
|
- {
|
|
|
- String splatform = current_platform->value.GetString();
|
|
|
- if (splatform == "Windows")
|
|
|
- platform = AE_PLATFORM_WINDOWS;
|
|
|
- else if (splatform == "Mac")
|
|
|
- platform = AE_PLATFORM_MAC;
|
|
|
- else if (splatform == "HTML5")
|
|
|
- platform = AE_PLATFORM_HTML5;
|
|
|
- else if (splatform == "iOS")
|
|
|
- platform = AE_PLATFORM_IOS;
|
|
|
- else if (splatform == "Android")
|
|
|
- platform = AE_PLATFORM_ANDROID;
|
|
|
- }
|
|
|
- if (platform == AE_PLATFORM_UNDEFINED)
|
|
|
- {
|
|
|
-#ifdef ATOMIC_PLATFORM_OSX
|
|
|
- platform = AE_PLATFORM_MAC;
|
|
|
-#else
|
|
|
- platform = AE_PLATFORM_WINDOWS;
|
|
|
-#endif
|
|
|
- }
|
|
|
- */
|
|
|
+bool Project::LoadUserPrefs()
|
|
|
+{
|
|
|
+ ToolSystem* tsystem = GetSubsystem<ToolSystem>();
|
|
|
|
|
|
- /*
|
|
|
- const Value::Member* last_build_path = document.FindMember("last_build_path");
|
|
|
- if (last_build_path && last_build_path->value.IsString())
|
|
|
+ // If we're in CLI mode, the Build folder is always relative to project
|
|
|
+ if (tsystem->IsCLI())
|
|
|
{
|
|
|
- lastBuildPath_ = last_build_path->value.GetString();
|
|
|
+ String path = GetPath(projectFilePath_) + "Build";
|
|
|
+ userPrefs_->SetLastBuildPath(path);
|
|
|
}
|
|
|
- */
|
|
|
-
|
|
|
- // probably will want to move this, it will trigger a save (which is guarded with load_)
|
|
|
- /*
|
|
|
- Editor* editor = GetSubsystem<Editor>();
|
|
|
- editor->RequestPlatformChange(platform);
|
|
|
- */
|
|
|
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
-void Project::SaveUserPrefs(const String& fullpath)
|
|
|
+void Project::SaveBuildSettings()
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
-void Project::SaveBuildSettings(const String& path)
|
|
|
+bool Project::LoadBuildSettings()
|
|
|
{
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-bool Project::LoadBuildSettings(const String& path)
|
|
|
-{
|
|
|
- return false;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
void Project::AddPlatform(PlatformID platformID)
|
|
|
@@ -122,7 +74,7 @@ void Project::AddPlatform(PlatformID platformID)
|
|
|
if (ContainsPlatform(platformID))
|
|
|
return;
|
|
|
|
|
|
- dirty_ = true;
|
|
|
+ SetDirty();
|
|
|
|
|
|
platforms_.Push(platformID);
|
|
|
|
|
|
@@ -149,9 +101,18 @@ bool Project::ContainsPlatform(PlatformID platformID)
|
|
|
|
|
|
bool Project::Load(const String& fullpath)
|
|
|
{
|
|
|
+ loading_ = true;
|
|
|
+
|
|
|
projectFilePath_ = fullpath;
|
|
|
SharedPtr<ProjectFile> pfile(new ProjectFile(context_));
|
|
|
- return pfile->Load(this);
|
|
|
+ bool result = pfile->Load(this);
|
|
|
+
|
|
|
+ loading_ = false;
|
|
|
+
|
|
|
+ LoadBuildSettings();
|
|
|
+ LoadUserPrefs();
|
|
|
+
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
String Project::GetBuildSettingsFullPath()
|