2019-10-31 02:24:42 +00:00
|
|
|
|
using System.Collections.Generic;
|
2019-10-30 12:29:06 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using Alphaleonis.Win32.Filesystem;
|
2019-10-31 02:24:42 +00:00
|
|
|
|
using Newtonsoft.Json;
|
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
|
|
|
|
{
|
|
|
|
|
public IncludePropertyFiles(Compiler compiler) : base(compiler)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Directive Run(RawSourceFile source)
|
|
|
|
|
{
|
|
|
|
|
var files = new HashSet<string>
|
|
|
|
|
{
|
|
|
|
|
_compiler.ModListImage, _compiler.ModListReadme
|
|
|
|
|
};
|
|
|
|
|
if (!files.Any(f => source.AbsolutePath.Equals(f))) return null;
|
|
|
|
|
if (!File.Exists(source.AbsolutePath)) return null;
|
|
|
|
|
var isBanner = source.AbsolutePath == _compiler.ModListImage;
|
|
|
|
|
//var isReadme = source.AbsolutePath == ModListReadme;
|
|
|
|
|
var result = source.EvolveTo<PropertyFile>();
|
|
|
|
|
result.SourceDataID = _compiler.IncludeFile(File.ReadAllBytes(source.AbsolutePath));
|
|
|
|
|
if (isBanner)
|
|
|
|
|
{
|
|
|
|
|
result.Type = PropertyType.Banner;
|
|
|
|
|
_compiler.ModListImage = result.SourceDataID;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result.Type = PropertyType.Readme;
|
|
|
|
|
_compiler.ModListReadme = result.SourceDataID;
|
|
|
|
|
}
|
2019-10-31 02:24:42 +00:00
|
|
|
|
|
2019-10-30 12:29:06 +00:00
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
public ICompilationStep CreateStep(Compiler compiler)
|
|
|
|
|
{
|
|
|
|
|
return new IncludePropertyFiles(compiler);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-10-30 12:29:06 +00:00
|
|
|
|
}
|
2019-10-31 02:24:42 +00:00
|
|
|
|
}
|