78 lines
2.6 KiB
C#
78 lines
2.6 KiB
C#
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using Ionic.Zip;
|
|
using JD.Core.ProjectManaging;
|
|
using Packager.Parameters;
|
|
|
|
namespace Packager.Tasks
|
|
{
|
|
[DisplayName(@"Build CMU package")]
|
|
public class BuildCMUTask : Task
|
|
{
|
|
private string _platform;
|
|
|
|
public BuildCMUTask()
|
|
{
|
|
FileList = new ReferenceList();
|
|
DLCDescList = new ReferenceList();
|
|
PackageName = new ReferenceList();
|
|
}
|
|
|
|
[Input("File List", IOCardinality.Multi, IOType.File)]
|
|
public ReferenceList FileList { get; set; }
|
|
|
|
[Input("DLC desc file", IOCardinality.Single, IOType.File, Flags = InputFlags.Optional)]
|
|
public ReferenceList DLCDescList { get; set; }
|
|
|
|
[Input("Package Name", IOCardinality.Single, IOType.String, Flags = InputFlags.Optional)]
|
|
public ReferenceList PackageName { get; set; }
|
|
|
|
[Output("CMU package", IOType.File)]
|
|
public ReferenceList CmuPackage = new ReferenceList();
|
|
|
|
public override bool NeedCooker => true;
|
|
|
|
protected override void StartInternal(BuildConfiguration profile, cookerWrapper cooker)
|
|
{
|
|
_platform = profile.PlatformList.First();
|
|
|
|
if (!PackageName.Any())
|
|
{
|
|
PackageName.Add("cmu");
|
|
}
|
|
|
|
foreach (var packageName in PackageName)
|
|
{
|
|
var zipFolderName = packageName + "_" + _platform + ".zip";
|
|
|
|
using (var zip = new ZipFile())
|
|
{
|
|
// add this map file into the "images" directory in the zip archive
|
|
zip.AddFiles(FileList, false, "");
|
|
zip.AddFiles(DLCDescList, false, "");
|
|
zip.AddFiles(GetAtlasContainerAndSgsContainerCooked(profile, cooker), false, "");
|
|
var zipName = Path.Combine(TaskOutputFolder, zipFolderName);
|
|
zip.Save(zipName);
|
|
CmuPackage.Add(zipName);
|
|
}
|
|
}
|
|
}
|
|
|
|
protected IEnumerable<string> GetAtlasContainerAndSgsContainerCooked(BuildConfiguration profile, cookerWrapper cooker)
|
|
{
|
|
var cookedFiles = new[] { "atlascontainer", "sgscontainer", };
|
|
|
|
var translatedCookedFiles = new List<string>();
|
|
|
|
foreach (var file in cookedFiles)
|
|
{
|
|
var cookedFileName = "";
|
|
cooker.getCookedNamePlatform(file, _platform, ref cookedFileName);
|
|
translatedCookedFiles.Add(DataPath.GetAbsolutePath(cookedFileName));
|
|
}
|
|
return translatedCookedFiles;
|
|
}
|
|
}
|
|
}
|