2019-10-30 12:29:06 +00:00
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
public class IncludeDummyESPs : ACompilationStep
|
|
|
|
|
{
|
2019-11-03 16:45:49 +00:00
|
|
|
|
public IncludeDummyESPs(ACompiler compiler) : base(compiler)
|
2019-10-30 12:29:06 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Directive Run(RawSourceFile source)
|
|
|
|
|
{
|
|
|
|
|
if (Path.GetExtension(source.AbsolutePath) != ".esp" &&
|
|
|
|
|
Path.GetExtension(source.AbsolutePath) != ".esm") return null;
|
2019-10-31 02:24:42 +00:00
|
|
|
|
|
2019-10-30 12:29:06 +00:00
|
|
|
|
var bsa = Path.Combine(Path.GetDirectoryName(source.AbsolutePath),
|
|
|
|
|
Path.GetFileNameWithoutExtension(source.AbsolutePath) + ".bsa");
|
|
|
|
|
var bsaTextures = Path.Combine(Path.GetDirectoryName(source.AbsolutePath),
|
|
|
|
|
Path.GetFileNameWithoutExtension(source.AbsolutePath) + " - Textures.bsa");
|
|
|
|
|
var espSize = new FileInfo(source.AbsolutePath).Length;
|
2019-10-31 02:24:42 +00:00
|
|
|
|
|
|
|
|
|
if (espSize > 250 || !File.Exists(bsa) && !File.Exists(bsaTextures)) return null;
|
|
|
|
|
|
2019-10-30 12:29:06 +00:00
|
|
|
|
var inline = source.EvolveTo<InlineFile>();
|
|
|
|
|
inline.SourceDataID = _compiler.IncludeFile(File.ReadAllBytes(source.AbsolutePath));
|
|
|
|
|
return inline;
|
2019-10-31 02:24:42 +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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[JsonObject("IncludeDummyESPs")]
|
|
|
|
|
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 IncludeDummyESPs(compiler);
|
|
|
|
|
}
|
2019-10-30 12:29:06 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-10-31 02:24:42 +00:00
|
|
|
|
}
|