42 lines
No EOL
1.5 KiB
C#
42 lines
No EOL
1.5 KiB
C#
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using JD.Core.ProjectManaging;
|
|
using Packager.Parameters;
|
|
|
|
namespace Packager.Tasks
|
|
{
|
|
/// <summary>
|
|
/// Output: all the common textures that can be used in a capture.
|
|
/// </summary>
|
|
public class AddAdditionalCapturesDependenciesTask : Task
|
|
{
|
|
private static readonly string[] TexturesExtensions = { ".png", ".tga" };
|
|
|
|
[Output("Dependencies File", IOType.File)]
|
|
public ReferenceList DependenciesFile = new ReferenceList();
|
|
|
|
protected override void StartInternal(BuildConfiguration profile, cookerWrapper cooker)
|
|
{
|
|
var directories = new [] { DataPath.GetAbsolutePath(@"EngineData"), DataPath.GetAbsolutePath(@"World/_COMMON"), DataPath.GetAbsolutePath(@"World/ui") };
|
|
|
|
var textures = directories.SelectMany(GetFilesInDirectory)
|
|
.Where(IsATexture)
|
|
.Select(DataPath.GetRelativePath);
|
|
|
|
var outputFile = Path.Combine(TaskOutputFolder, "CommonTextures.txt");
|
|
File.AppendAllLines(outputFile, textures);
|
|
DependenciesFile.Add(outputFile);
|
|
}
|
|
|
|
private bool IsATexture(string fileName)
|
|
{
|
|
return TexturesExtensions.Any(fileName.EndsWith);
|
|
}
|
|
|
|
private IEnumerable<string> GetFilesInDirectory(string directory)
|
|
{
|
|
return Directory.GetFiles(directory, "*.*", SearchOption.AllDirectories);
|
|
}
|
|
}
|
|
} |