Browse Source

Default project file on new project, log level for AtomicTool

Josh Engebretson 10 years ago
parent
commit
cda337f526

+ 1 - 1
CLI/index.js

@@ -22,7 +22,7 @@ exports.VERSION = JSON.parse(fs.readFileSync(__dirname + "/package.json")).versi
 var exec = function (command, flags, opts) {
     opts = opts || {};
     if (opts.verbose !== false) {
-        console.log([command].concat(flags).join(" "));
+        //console.log([command].concat(flags).join(" "));
     }
 
     // Run everything through cmd.exe on Windows to be able to find .bat files

+ 1 - 0
Source/AtomicTool/AtomicTool.cpp

@@ -56,6 +56,7 @@ void AtomicTool::Setup()
         ErrorExit("Unable to parse --data-path");
 
     engineParameters_["Headless"] = true;
+    engineParameters_["LogLevel"] = LOG_WARNING;
     engineParameters_["ResourcePaths"] = "";
 }
 

+ 3 - 2
Source/ToolCore/Command/NewProjectCmd.cpp

@@ -4,6 +4,7 @@
 #include <Atomic/IO/File.h>
 
 #include "../ToolSystem.h"
+#include "../Project/ProjectFile.h"
 
 #include "NewProjectCmd.h"
 
@@ -71,8 +72,8 @@ void NewProjectCmd::Run()
     projectSrc.copyTo((projectPath_ + "/Resources").CString());
 
     String filename("NewProject");
-    File file(context_, projectPath_ + "/" + filename + ".atomic", FILE_WRITE);
-    file.Close();
+    SharedPtr<ProjectFile> pfile(new ProjectFile(context_));
+    pfile->WriteNewProject(projectPath_ + "/" + filename + ".atomic");
 
     Finished();
 }

+ 23 - 3
Source/ToolCore/Project/ProjectFile.cpp

@@ -22,6 +22,27 @@ ProjectFile::~ProjectFile()
 
 }
 
+void ProjectFile::WriteNewProject(const String& fullpath)
+{
+    SharedPtr<JSONFile> jsonFile(new JSONFile(context_));
+
+    JSONValue root = jsonFile->CreateRoot();
+
+    root.SetInt("version", PROJECTFILE_VERSION);
+
+    // project object
+    JSONValue jproject = root.CreateChild("project");
+    jproject.SetString("version", "1.0.0");
+
+    // platforms
+    root.CreateChild("platforms", JSON_ARRAY);
+
+    SharedPtr<File> file(new File(context_, fullpath, FILE_WRITE));
+    jsonFile->Save(*file, String("   "));
+    file->Close();
+
+}
+
 void ProjectFile::Save(Project* project)
 {
     project_ = project;
@@ -36,12 +57,10 @@ void ProjectFile::Save(Project* project)
     root.SetInt("version", PROJECTFILE_VERSION);
 
     // project object
-
     JSONValue jproject = root.CreateChild("project");
     jproject.SetString("version", project_->GetVersion());
 
     // platforms
-
     JSONValue platforms = root.CreateChild("platforms", JSON_ARRAY);
 
     for (List<PlatformID>::ConstIterator i = project_->platforms_.Begin(); i != project_->platforms_.End(); ++i)
@@ -70,7 +89,8 @@ bool ProjectFile::Load(Project* project)
     SharedPtr<File> file(new File(context_, fullpath, FILE_READ));
     SharedPtr<JSONFile> jsonFile(new JSONFile(context_));
 
-    jsonFile->BeginLoad(*file);
+    if (!jsonFile->BeginLoad(*file))
+        return false;
 
     JSONValue root = jsonFile->GetRoot();
 

+ 2 - 0
Source/ToolCore/Project/ProjectFile.h

@@ -25,6 +25,8 @@ public:
     void Save(Project* project);
     bool Load(Project* project);
 
+    void WriteNewProject(const String& fullpath);
+
 private:
 
     SharedPtr<Project> project_;

+ 1 - 1
Source/ToolCore/ToolSystem.cpp

@@ -36,7 +36,7 @@ ToolSystem::~ToolSystem()
 
 bool ToolSystem::LoadProject(const String& fullpath)
 {
-    String path = GetPath(fullpath);
+    String path = RemoveTrailingSlash(GetPath(fullpath));
 
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     cache->AddResourceDir(path, 0);