2021-09-27 12:42:46 +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;
|
2021-09-27 12:42:46 +00:00
|
|
|
using Wabbajack.DTOs;
|
|
|
|
using Wabbajack.DTOs.Directives;
|
|
|
|
using Wabbajack.Paths;
|
2019-10-30 12:29:06 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
namespace Wabbajack.Compiler.CompilationSteps;
|
|
|
|
|
|
|
|
public class IgnoreOtherProfiles : ACompilationStep
|
2019-10-30 12:29:06 +00:00
|
|
|
{
|
2021-10-23 16:51:17 +00:00
|
|
|
private readonly MO2Compiler _mo2Compiler;
|
|
|
|
private readonly IEnumerable<AbsolutePath> _profiles;
|
|
|
|
private readonly AbsolutePath _modProfilesFolder;
|
2019-10-30 12:29:06 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
public IgnoreOtherProfiles(ACompiler compiler) : base(compiler)
|
|
|
|
{
|
|
|
|
_mo2Compiler = (MO2Compiler) compiler;
|
|
|
|
_modProfilesFolder = _mo2Compiler._settings.Source.Combine("profiles");
|
2019-11-11 20:03:27 +00:00
|
|
|
|
2022-05-30 20:50:24 +00:00
|
|
|
_profiles = _mo2Compiler._settings.AllProfiles
|
2021-10-23 16:51:17 +00:00
|
|
|
.Select(p => _modProfilesFolder.Combine(p))
|
|
|
|
.ToList();
|
|
|
|
}
|
2019-10-30 12:29:06 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
public override async ValueTask<Directive?> Run(RawSourceFile source)
|
|
|
|
{
|
|
|
|
if (!source.AbsolutePath.InFolder(_modProfilesFolder)) return null;
|
|
|
|
if (_profiles.Any(profile => source.AbsolutePath.InFolder(profile))) return null;
|
|
|
|
var c = source.EvolveTo<IgnoredDirectly>();
|
|
|
|
c.Reason = "File not for selected profiles";
|
|
|
|
return c;
|
2019-10-30 12:29:06 +00:00
|
|
|
}
|
2021-09-27 12:42:46 +00:00
|
|
|
}
|