mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
commit
5518747b10
@ -40,8 +40,7 @@ namespace Wabbajack.Lib.CompilationSteps
|
|||||||
return new State();
|
return new State();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsAlwaysEnabled(dynamic data)
|
||||||
private static bool IsAlwaysEnabled(dynamic data)
|
|
||||||
{
|
{
|
||||||
if (data == null)
|
if (data == null)
|
||||||
return false;
|
return false;
|
||||||
|
@ -10,7 +10,7 @@ namespace Wabbajack.Lib.CompilationSteps
|
|||||||
public class IncludeThisProfile : ACompilationStep
|
public class IncludeThisProfile : ACompilationStep
|
||||||
{
|
{
|
||||||
private readonly IEnumerable<string> _correctProfiles;
|
private readonly IEnumerable<string> _correctProfiles;
|
||||||
private readonly MO2Compiler _mo2Compiler;
|
private MO2Compiler _mo2Compiler;
|
||||||
|
|
||||||
public IncludeThisProfile(ACompiler compiler) : base(compiler)
|
public IncludeThisProfile(ACompiler compiler) : base(compiler)
|
||||||
{
|
{
|
||||||
@ -20,18 +20,17 @@ namespace Wabbajack.Lib.CompilationSteps
|
|||||||
|
|
||||||
public override async ValueTask<Directive> Run(RawSourceFile source)
|
public override async ValueTask<Directive> Run(RawSourceFile source)
|
||||||
{
|
{
|
||||||
if (_correctProfiles.Any(p => source.Path.StartsWith(p)))
|
if (!_correctProfiles.Any(p => source.Path.StartsWith(p)))
|
||||||
{
|
return null;
|
||||||
var data = source.Path.EndsWith("\\modlist.txt")
|
|
||||||
? ReadAndCleanModlist(source.AbsolutePath)
|
|
||||||
: File.ReadAllBytes(source.AbsolutePath);
|
|
||||||
|
|
||||||
var e = source.EvolveTo<InlineFile>();
|
var data = source.Path.EndsWith("\\modlist.txt")
|
||||||
e.SourceDataID = _compiler.IncludeFile(data);
|
? ReadAndCleanModlist(source.AbsolutePath)
|
||||||
return e;
|
: File.ReadAllBytes(source.AbsolutePath);
|
||||||
}
|
|
||||||
|
var e = source.EvolveTo<InlineFile>();
|
||||||
|
e.SourceDataID = _compiler.IncludeFile(data);
|
||||||
|
return e;
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IState GetState()
|
public override IState GetState()
|
||||||
@ -39,12 +38,17 @@ namespace Wabbajack.Lib.CompilationSteps
|
|||||||
return new State();
|
return new State();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] ReadAndCleanModlist(string absolutePath)
|
private byte[] ReadAndCleanModlist(string absolutePath)
|
||||||
{
|
{
|
||||||
var lines = File.ReadAllLines(absolutePath);
|
var alwaysEnabled = _mo2Compiler.ModInis.Where(f => IgnoreDisabledMods.IsAlwaysEnabled(f.Value))
|
||||||
lines = (from line in lines
|
.Select(f => f.Key)
|
||||||
where !(line.StartsWith("-") && !line.EndsWith("_separator"))
|
.Distinct();
|
||||||
select line).ToArray();
|
var lines = File.ReadAllLines(absolutePath).Where(l =>
|
||||||
|
{
|
||||||
|
return l.StartsWith("+")
|
||||||
|
|| alwaysEnabled.Any(x => x == l.Substring(1))
|
||||||
|
|| l.EndsWith("_separator");
|
||||||
|
}).ToArray();
|
||||||
return Encoding.UTF8.GetBytes(string.Join("\r\n", lines));
|
return Encoding.UTF8.GetBytes(string.Join("\r\n", lines));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user