Browse Source

New project command copying template

Josh Engebretson 10 years ago
parent
commit
8f85bbb919
3 changed files with 26 additions and 2 deletions
  1. 2 1
      .gitignore
  2. 3 1
      CLI/.gitignore
  3. 21 0
      Source/ToolCore/Command/NewProjectCmd.cpp

+ 2 - 1
.gitignore

@@ -9,4 +9,5 @@ Build/*
 Docs/out/*
 Docs/out/*
 Docs/node_modules/*
 Docs/node_modules/*
 Data/AtomicEditor/Deployment/Web/AtomicPlayer.js
 Data/AtomicEditor/Deployment/Web/AtomicPlayer.js
-Data/AtomicEditor/Deployment/IOS/AtomicPlayer.app/AtomicPlayer
+Data/AtomicEditor/Deployment/IOS/AtomicPlayer.app/AtomicPlayer
+node_modules/*

+ 3 - 1
CLI/.gitignore

@@ -1 +1,3 @@
-Bin/*
+data/bin/*
+data/Atomic/*
+node_modules/*

+ 21 - 0
Source/ToolCore/Command/NewProjectCmd.cpp

@@ -1,6 +1,9 @@
 
 
 #include <Atomic/Core/StringUtils.h>
 #include <Atomic/Core/StringUtils.h>
 #include <Atomic/IO/Log.h>
 #include <Atomic/IO/Log.h>
+#include <Atomic/IO/File.h>
+
+#include "../ToolSystem.h"
 
 
 #include "NewProjectCmd.h"
 #include "NewProjectCmd.h"
 
 
@@ -51,8 +54,26 @@ void NewProjectCmd::Run()
         return;
         return;
     }
     }
 
 
+    ToolSystem* tsystem = GetSubsystem<ToolSystem>();
+    String templateDir = tsystem->GetDataPath();
+    templateDir += "/Atomic/ProjectTemplates/Project2D/Resources";
+
+    Poco::File projectSrc(templateDir.CString());
+    if (!projectSrc.exists() || !projectSrc.isDirectory())
+    {
+        Error(ToString("New project path: %s source does not exist", templateDir.CString()));
+        return;
+    }
+
     LOGINFOF("Creating new project in: %s", projectPath_.CString());
     LOGINFOF("Creating new project in: %s", projectPath_.CString());
 
 
+    projectDest.createDirectory();
+    projectSrc.copyTo((projectPath_ + "/Resources").CString());
+
+    String filename("NewProject");
+    File file(context_, projectPath_ + "/" + filename + ".atomic", FILE_WRITE);
+    file.Close();
+
     Finished();
     Finished();
 }
 }