162 lines
6.4 KiB
C#
162 lines
6.4 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.ComponentModel;
|
|
using System.IO;
|
|
using NUnit.Framework;
|
|
|
|
using Packager.Parameters;
|
|
|
|
namespace Packager.Tasks
|
|
{
|
|
[DisplayName("Cook Assets")]
|
|
public class CookTask: AssetCookerTask
|
|
{
|
|
[Input("Asset Files List", IOCardinality.Multi, IOType.File)]
|
|
public ReferenceList AssetsList { get; set; }
|
|
|
|
[Input("Scene to override", IOCardinality.Multi, IOType.File, Flags = InputFlags.Optional)]
|
|
public ReferenceList OriginalSceneParam { get; set; }
|
|
|
|
[Input("Repl. scene", IOCardinality.Multi, IOType.File, Flags = InputFlags.Optional)]
|
|
public ReferenceList ReplacementSceneParam { get; set; }
|
|
|
|
[Input("BuildAtls", IOCardinality.Single, IOType.String, Flags = InputFlags.Optional)]
|
|
public SingleReference BuildAtls { get; set; }
|
|
|
|
[Input("BuildSgs", IOCardinality.Single, IOType.String, Flags = InputFlags.Optional)]
|
|
public SingleReference BuildSgs { get; set; }
|
|
|
|
[Output("Failed Files", IOType.File)]
|
|
public ReferenceList FailedFiles = new ReferenceList();
|
|
|
|
public CookTask()
|
|
{
|
|
AssetsList = new ReferenceList();
|
|
OriginalSceneParam = new ReferenceList();
|
|
ReplacementSceneParam = new ReferenceList();
|
|
BuildAtls = new SingleReference("true");
|
|
BuildSgs = new SingleReference("true");
|
|
|
|
BuildAtl = true;
|
|
PackSgs = true;
|
|
CookList = true;
|
|
Cook = true;
|
|
}
|
|
|
|
protected override void StartInternal(BuildConfiguration profile, cookerWrapper cooker)
|
|
{
|
|
if (BuildAtls.Value.Equals("false"))
|
|
{
|
|
BuildAtl = false;
|
|
}
|
|
|
|
if (BuildSgs.Value.Equals("false"))
|
|
{
|
|
PackSgs = false;
|
|
}
|
|
|
|
MergeList = CreateMergeFile(AssetsList);
|
|
|
|
ErrorOutputFile = GetTempFileName();
|
|
|
|
if (OriginalSceneParam.Count == ReplacementSceneParam.Count && OriginalSceneParam.Count > 0)
|
|
{
|
|
var originalAndReplacementScenes = OriginalSceneParam.Zip(ReplacementSceneParam,
|
|
(originalScene, replacementScene) =>
|
|
new {OriginalScene = originalScene, ReplacementScene = replacementScene});
|
|
|
|
foreach (var scene in originalAndReplacementScenes)
|
|
{
|
|
OriginalScene = scene.OriginalScene;
|
|
ReplacementScene = scene.ReplacementScene;
|
|
|
|
if ((OriginalScene != null && OriginalScene.Length > 0) &&
|
|
(ReplacementScene != null && ReplacementScene.Length > 0))
|
|
{
|
|
OverrideScene = true;
|
|
}
|
|
|
|
Start(profile);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Start(profile);
|
|
}
|
|
}
|
|
|
|
public override void ProcessExited()
|
|
{
|
|
if(File.Exists(ErrorOutputFile))
|
|
{
|
|
FailedFiles.Add(File.ReadAllLines(ErrorOutputFile));
|
|
try
|
|
{
|
|
File.Delete(ErrorOutputFile);
|
|
}
|
|
catch (IOException)
|
|
{}
|
|
}
|
|
|
|
base.ProcessExited();
|
|
}
|
|
}
|
|
|
|
[TestFixture]
|
|
internal class CookTaskTest
|
|
{
|
|
private readonly CookTask _cookTask;
|
|
private readonly TestBuildConfiguration _testProfile;
|
|
|
|
public CookTaskTest()
|
|
{
|
|
_cookTask = new CookTask();
|
|
_testProfile = new TestBuildConfiguration(new[] { @"dataversion=0;platform=X360;" });
|
|
_cookTask.CacheKey = GetGuid();
|
|
}
|
|
|
|
private SingleReference GetGuid()
|
|
{
|
|
var genGuidTask = new GenGUIDTask();
|
|
genGuidTask.StartTaskTest();
|
|
return genGuidTask.Guid;
|
|
}
|
|
|
|
[Test]
|
|
public void Test_cook_task()
|
|
{
|
|
_cookTask.AssetsList.Add( @"enginedata/common.alias8",
|
|
@"enginedata/console/x360/arial_16.xpr",
|
|
@"enginedata/feedback/feedbacks.frt",
|
|
@"enginedata/textures/cooking.png",
|
|
@"enginedata/textures/cutoutmask.png",
|
|
@"enginedata/textures/mir.png",
|
|
@"enginedata/textures/white.png",
|
|
@"enginedata/editor/icons/editoricons.atl",
|
|
@"enginedata/editor/icons/editoricons.tga",
|
|
@"enginedata/editor/icons/tagicons.atl",
|
|
@"enginedata/editor/icons/tagicons.tga",
|
|
@"enginedata/editor/icons/trajectory.tga",
|
|
@"enginedata/shaders/compiled/ps3/afterfx.fx.fxb",
|
|
@"enginedata/shaders/compiled/ps3/autodance.fx.fxb",
|
|
@"enginedata/shaders/compiled/ps3/conversionutils.fx.fxb",
|
|
@"enginedata/shaders/compiled/ps3/debug.fx.fxb",
|
|
@"enginedata/shaders/compiled/ps3/font.fx.fxb",
|
|
@"enginedata/shaders/compiled/ps3/movie.fx.fxb",
|
|
@"enginedata/shaders/compiled/ps3/multitexture.fx.fxb",
|
|
@"enginedata/shaders/compiled/ps3/mumomat.fx.fxb",
|
|
@"enginedata/shaders/compiled/ps3/musicmotion.fx.fxb",
|
|
@"enginedata/shaders/compiled/ps3/pip.fx.fxb",
|
|
@"enginedata/shaders/compiled/ps3/pleo.fx.fxb",
|
|
@"enginedata/shaders/compiled/ps3/renderpct.fx.fxb",
|
|
@"enginedata/shaders/unified/afterfx.fx",
|
|
@"enginedata/shaders/unified/autodance.fx",
|
|
@"enginedata/shaders/unified/conversionutils.fx",
|
|
@"enginedata/shaders/unified/debug.fx",
|
|
@"enginedata/shaders/unified/font.fx"
|
|
);
|
|
|
|
_cookTask.StartTaskTest(_testProfile);
|
|
}
|
|
}
|
|
}
|