2019-10-31 02:24:42 +00:00
|
|
|
|
using System.Collections.Generic;
|
2019-10-30 12:29:06 +00:00
|
|
|
|
using System.Linq;
|
2019-12-04 01:26:26 +00:00
|
|
|
|
using System.Threading.Tasks;
|
2019-10-30 12:29:06 +00:00
|
|
|
|
using Alphaleonis.Win32.Filesystem;
|
2019-10-31 02:24:42 +00:00
|
|
|
|
using Newtonsoft.Json;
|
2020-03-25 12:47:25 +00:00
|
|
|
|
using Wabbajack.Common;
|
2019-10-30 12:29:06 +00:00
|
|
|
|
|
|
|
|
|
namespace Wabbajack.Lib.CompilationSteps
|
|
|
|
|
{
|
2019-10-31 02:24:42 +00:00
|
|
|
|
public class IncludePropertyFiles : ACompilationStep
|
2019-10-30 12:29:06 +00:00
|
|
|
|
{
|
2019-11-11 20:05:23 +00:00
|
|
|
|
|
2019-11-03 16:45:49 +00:00
|
|
|
|
public IncludePropertyFiles(ACompiler compiler) : base(compiler)
|
2019-10-30 12:29:06 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-04 01:26:26 +00:00
|
|
|
|
public override async ValueTask<Directive> Run(RawSourceFile source)
|
2019-10-30 12:29:06 +00:00
|
|
|
|
{
|
2020-03-25 12:47:25 +00:00
|
|
|
|
var files = new HashSet<AbsolutePath>
|
2019-10-30 12:29:06 +00:00
|
|
|
|
{
|
2019-11-17 14:30:06 +00:00
|
|
|
|
_compiler.ModListImage, _compiler.ModListReadme
|
2019-10-30 12:29:06 +00:00
|
|
|
|
};
|
|
|
|
|
if (!files.Any(f => source.AbsolutePath.Equals(f))) return null;
|
2020-03-25 12:47:25 +00:00
|
|
|
|
if (!source.AbsolutePath.Exists) return null;
|
2019-11-17 14:30:06 +00:00
|
|
|
|
var isBanner = source.AbsolutePath == _compiler.ModListImage;
|
2019-10-30 12:29:06 +00:00
|
|
|
|
//var isReadme = source.AbsolutePath == ModListReadme;
|
|
|
|
|
var result = source.EvolveTo<PropertyFile>();
|
2020-03-25 22:30:43 +00:00
|
|
|
|
result.SourceDataID = await _compiler.IncludeFile(await source.AbsolutePath.ReadAllBytesAsync());
|
2019-10-30 12:29:06 +00:00
|
|
|
|
if (isBanner)
|
|
|
|
|
{
|
|
|
|
|
result.Type = PropertyType.Banner;
|
2020-03-25 22:30:43 +00:00
|
|
|
|
_compiler.ModListImage = result.SourceDataID.RelativeTo(_compiler.ModListOutputFolder);
|
2019-10-30 12:29:06 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result.Type = PropertyType.Readme;
|
2020-03-25 22:30:43 +00:00
|
|
|
|
_compiler.ModListReadme = result.SourceDataID.RelativeTo(_compiler.ModListOutputFolder);
|
2019-10-30 12:29:06 +00:00
|
|
|
|
}
|
2019-10-31 02:24:42 +00:00
|
|
|
|
|
2019-10-30 12:29:06 +00:00
|
|
|
|
return result;
|
2019-11-17 14:30:06 +00:00
|
|
|
|
}
|
2019-10-30 12:29:06 +00:00
|
|
|
|
|
2019-10-31 02:24:42 +00:00
|
|
|
|
public override IState GetState()
|
|
|
|
|
{
|
|
|
|
|
return new State();
|
|
|
|
|
}
|
2019-10-30 12:29:06 +00:00
|
|
|
|
|
2019-10-31 02:24:42 +00:00
|
|
|
|
[JsonObject("IncludePropertyFiles")]
|
|
|
|
|
public class State : IState
|
|
|
|
|
{
|
2019-11-03 16:45:49 +00:00
|
|
|
|
public ICompilationStep CreateStep(ACompiler compiler)
|
2019-10-31 02:24:42 +00:00
|
|
|
|
{
|
|
|
|
|
return new IncludePropertyFiles(compiler);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-10-30 12:29:06 +00:00
|
|
|
|
}
|
2019-12-04 01:26:26 +00:00
|
|
|
|
}
|