Esempio n. 1
0
 public bool Run(CreateParams prms, CocosCreateMonitor monitor)
 {
     this.Monitor = monitor;
     try
     {
         return(this.OnRun(prms));
     }
     catch (Exception ex)
     {
         this.SendOutputInfo("Failed to create");
         LogConfig.Logger.Error((object)("新建项目时出错:\r\n" + ex.ToString()));
         return(false);
     }
 }
Esempio n. 2
0
 internal static bool CopyFolder(string srcPath, string dstPath, CocosCreateMonitor monitor)
 {
     try
     {
         if (monitor.IsCancelled)
         {
             return(false);
         }
         if (!Directory.Exists(dstPath))
         {
             Directory.CreateDirectory(dstPath);
         }
         string[] files = Directory.GetFiles(srcPath);
         if (files.Length > 0)
         {
             foreach (string str in files)
             {
                 string destFileName = Path.Combine(dstPath, Path.GetFileName(str));
                 File.Copy(str, destFileName, true);
             }
         }
         foreach (string directory in Directory.GetDirectories(srcPath))
         {
             if (monitor.IsCancelled)
             {
                 return(false);
             }
             string dstPath1 = Path.Combine(dstPath, Path.GetFileName(directory));
             if (!CreateHelper.CopyFolder(directory, dstPath1, monitor))
             {
                 return(false);
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         if (monitor != null)
         {
             monitor.SendInfo("Failed to copy file");
         }
         LogConfig.Logger.Error((object)("复制文件失败:\r\n" + ex.ToString()));
         return(false);
     }
 }
Esempio n. 3
0
 public void CreateCocosProject(CreateParams prms, CocosCreateMonitor monitor)
 {
     monitor.Start();
     if (prms == null)
     {
         monitor.SendInfo("The create params is null");
         monitor.Finish(false);
     }
     else
     {
         string path = Path.Combine(prms.Directory, prms.ProjName);
         if (Directory.Exists(path))
         {
             try
             {
                 monitor.SendInfo("Delete exist files");
                 new DirectoryInfo(path).Delete(true);
             }
             catch
             {
                 monitor.SendInfo("Failed to delete exist files");
                 monitor.Finish(false);
                 return;
             }
         }
         foreach (ICreateStep createStep in new List <ICreateStep>()
         {
             (ICreateStep) new StepCocosV2(), (ICreateStep) new StepCocosV3(), (ICreateStep) new StepIntelCCF(), (ICreateStep) new StepX86()
         })
         {
             if (createStep.CanCreate(prms) && !createStep.Run(prms, monitor))
             {
                 monitor.Finish(false);
                 return;
             }
         }
         monitor.Finish(true);
     }
 }