private void BTN_CreatePak_Click(object sender, EventArgs e) { bBatchMode = false; ApplyConfigs(); if (!ValidateConfigs()) { return; } if (bContentOnly && !File.Exists(ProjectFilePath)) { MessageBox.Show("Project File does not exist (<Content Files Only> requires a valid uproject file)!", "Missing Project File"); return; } if (LB_FilesToPak.Items.Count == 0) { MessageBox.Show("Nothing to Pak!", "Nothing to Pak"); return; } if (DialogResult.OK != OFD_BrowseOutputFile.ShowDialog()) { return; } ShowLog("///////////////////////// START PACKING /////////////////////////"); string[] FilesToPak = LB_FilesToPak.Items.Cast <string>().ToArray(); PakBatch Batch = new PakBatch(FilesToPak); Batch.OutputPath = OFD_BrowseOutputFile.FileName; CreateSinglePak(Batch); }
private void TV_BatchFiles_DragDrop(object sender, DragEventArgs e) { TV_BatchFiles.BeginUpdate(); string[] FileNames = e.Data.GetData(DataFormats.FileDrop, false) as string[]; if (CKB_FolderPak.Checked) { List <string> SingleFiles = new List <string>(); foreach (string FileName in FileNames) { if (IsDirectory(FileName)) { PakBatch Batch = new PakBatch(new string[] { FileName }); TreeNode Node = new TreeNode(Batch.BatchNodeText); Node.Tag = Batch; foreach (string SubDirFileName in Batch.Files) { Node.Nodes.Add(new TreeNode(SubDirFileName.Substring(Batch.CommonPath.Length))); } TV_BatchFiles.Nodes.Add(Node); } else { SingleFiles.Add(FileName); } } if (SingleFiles.Count > 0) { PakBatch Batch = new PakBatch(SingleFiles.ToArray()); TreeNode Node = new TreeNode(Batch.BatchNodeText); Node.Tag = Batch; TV_BatchFiles.Nodes.Add(Node); } } else { PakBatch Batch = new PakBatch(FileNames); TreeNode Node = new TreeNode(Batch.BatchNodeText); Node.Tag = Batch; foreach (string FileName in Batch.Files) { Node.Nodes.Add(new TreeNode(FileName.Substring(Batch.CommonPath.Length))); } TV_BatchFiles.Nodes.Add(Node); TV_BatchFiles.CollapseAll(); Node.Expand(); } TV_BatchFiles.EndUpdate(); }
private void CreateSinglePak(PakBatch Batch) { string ResponseFilePath = string.Empty; List <string> Args = new List <string>(); ResponseFilePath = CreateResponseFile(Batch); if (!File.Exists(ResponseFilePath)) { return; } if (string.IsNullOrEmpty(Batch.OutputPath)) { return; } string FileOutputPath = Batch.OutputPath; if (bAsPatch) { FileOutputPath = FileOutputPath.Insert(FileOutputPath.LastIndexOf(".pak"), "_p"); } Args.Add(FileOutputPath); Args.Add($"-create={ResponseFilePath}"); if (bEncryption) { Args.Add($"-cryptokeys={CryptoFilePath}"); Args.Add("-encryptindex"); } if (bCompression) { Args.Add("-compress"); } Args.Add("-patchpaddingalign=2048"); Args.Add($"-compressionformats={ProjectFilePath}"); Args.Add("-multiprocess"); Thread Worker = new Thread(() => RunPackingWorker(Args.ToArray())); Worker.IsBackground = true; Worker.Start(); }
private void BTN_BatchCreatePaks_Click(object sender, EventArgs e) { bBatchMode = true; ApplyConfigs(); if (!ValidateConfigs()) { return; } if (bContentOnly && !File.Exists(ProjectFilePath)) { MessageBox.Show("Project File does not exist (<Content Files Only> requires a valid uproject file)!", "Missing Project File"); return; } if (TV_BatchFiles.Nodes.Count == 0) { MessageBox.Show("Nothing to Pak!", "Nothing to Pak"); return; } if (!Directory.Exists(BatchOutputPath)) { MessageBox.Show("Output directory does not exist!"); return; } ShowLog("////////////////////// START BATCH PACKING //////////////////////"); BatchCount = BatchTotal = TV_BatchFiles.GetNodeCount(false); foreach (TreeNode Node in TV_BatchFiles.Nodes) { PakBatch Batch = Node.Tag as PakBatch; Batch.OutputPath = BatchOutputPath; if (Batch == null) { continue; } CreateSinglePak(Batch); } }
private string CreateResponseFile(PakBatch Batch) { string[] FilesToPak = Batch.Files; string ProjectName = Path.GetFileNameWithoutExtension(ProjectFilePath); string ResponseFileDir = @".\ResponseFiles"; string ResponseFilePath = Path.Combine(ResponseFileDir, $"{ProjectName}-{DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss")}"); string MountPoint = bContentOnly ? $"../../../{ProjectName}/" : Batch.CommonPath.Replace(@"\", "/"); List <string> Lines = new List <string>(); for (int i = 0; i < FilesToPak.Length; i++) { string FileName = FilesToPak[i]; string FileExtension = Path.GetExtension(FileName); int RelativeIndex = bContentOnly ? FileName.LastIndexOf(@"Content\") : Batch.CommonPath.Length; if (RelativeIndex < 0) { continue; } string RelativeFilePath = MountPoint + FileName.Substring(RelativeIndex).Replace(@"\", "/"); string Line = "\"" + FileName + "\" \"" + RelativeFilePath + "\""; if (bEncryption && FileExtension == ".uasset" || FileExtension == ".ini") { Line += " -encrypt"; } Lines.Add(Line); } if (Lines.Count == 0) { string ErrMsg = $"ERROR: No eligible file{ (bBatchMode ? $" for batch {Batch.BatchNodeText}!" : "!") }"; ShowLog(ErrMsg); return(string.Empty); } if (!Directory.Exists(ResponseFileDir)) { Directory.CreateDirectory(ResponseFileDir); } if (File.Exists(ResponseFilePath + ".txt")) { int DuplicateCount = 1; while (File.Exists(ResponseFilePath + $"_{DuplicateCount}.txt")) { DuplicateCount++; } ResponseFilePath += $"_{DuplicateCount}.txt"; } else { ResponseFilePath += ".txt"; } File.WriteAllLines(ResponseFilePath, Lines); return(Path.GetFullPath(ResponseFilePath)); }