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-28 18:22:53 +00:00
|
|
|
|
using Wabbajack.Common;
|
2020-04-09 18:14:05 +00:00
|
|
|
|
#nullable enable
|
2019-10-30 12:29:06 +00:00
|
|
|
|
|
|
|
|
|
namespace Wabbajack.Lib.CompilationSteps
|
|
|
|
|
{
|
|
|
|
|
public class IgnoreOtherProfiles : ACompilationStep
|
|
|
|
|
{
|
2020-03-28 18:22:53 +00:00
|
|
|
|
private readonly IEnumerable<AbsolutePath> _profiles;
|
2019-11-18 00:17:06 +00:00
|
|
|
|
private readonly MO2Compiler _mo2Compiler;
|
2020-03-28 18:22:53 +00:00
|
|
|
|
private AbsolutePath _modProfilesFolder;
|
2019-10-30 12:29:06 +00:00
|
|
|
|
|
2019-11-03 16:45:49 +00:00
|
|
|
|
public IgnoreOtherProfiles(ACompiler compiler) : base(compiler)
|
2019-10-30 12:29:06 +00:00
|
|
|
|
{
|
2019-11-18 00:17:06 +00:00
|
|
|
|
_mo2Compiler = (MO2Compiler) compiler;
|
2020-03-28 18:22:53 +00:00
|
|
|
|
_modProfilesFolder = _mo2Compiler.MO2Folder.Combine("profiles");
|
2019-11-11 20:03:27 +00:00
|
|
|
|
|
2020-03-28 18:22:53 +00:00
|
|
|
|
_profiles = _mo2Compiler.SelectedProfiles
|
|
|
|
|
.Select(p => _modProfilesFolder.Combine(p))
|
2019-10-30 12:29:06 +00:00
|
|
|
|
.ToList();
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-09 18:14:05 +00:00
|
|
|
|
public override async ValueTask<Directive?> Run(RawSourceFile source)
|
2019-10-30 12:29:06 +00:00
|
|
|
|
{
|
2020-03-28 18:22:53 +00:00
|
|
|
|
if (!source.AbsolutePath.InFolder(_modProfilesFolder)) return null;
|
|
|
|
|
if (_profiles.Any(profile => source.AbsolutePath.InFolder(profile))) return null;
|
2019-10-30 12:29:06 +00:00
|
|
|
|
var c = source.EvolveTo<IgnoredDirectly>();
|
|
|
|
|
c.Reason = "File not for selected profiles";
|
|
|
|
|
return c;
|
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("IgnoreOtherProfiles")]
|
|
|
|
|
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 IgnoreOtherProfiles(compiler);
|
|
|
|
|
}
|
2019-10-30 12:29:06 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-12-04 01:26:26 +00:00
|
|
|
|
}
|