Added WABBAJACK_ALWAYS_DISABLE flag

This commit is contained in:
erri120 2020-08-10 19:18:16 +02:00
parent 04d69299ec
commit 4bf1e943a2
No known key found for this signature in database
GPG Key ID: A8C0A18D8D4D3135
3 changed files with 11 additions and 8 deletions

View File

@ -43,6 +43,7 @@ namespace Wabbajack.Common
public static string WABBAJACK_INCLUDE = "WABBAJACK_INCLUDE";
public static string WABBAJACK_ALWAYS_ENABLE = "WABBAJACK_ALWAYS_ENABLE";
public static string WABBAJACK_ALWAYS_DISABLE = "WABBAJACK_ALWAYS_DISABLE";
public static string WABBAJACK_NOMATCH_INCLUDE = "WABBAJACK_NOMATCH_INCLUDE";
public static string GAME_PATH_MAGIC_BACK = "{--||GAME_PATH_MAGIC_BACK||--}";

View File

@ -15,13 +15,16 @@ namespace Wabbajack.Lib.CompilationSteps
public IgnoreDisabledMods(ACompiler compiler) : base(compiler)
{
_mo2Compiler = (MO2Compiler) compiler;
var alwaysEnabled = _mo2Compiler.ModInis.Where(f => IsAlwaysEnabled(f.Value)).Select(f => f.Key).Distinct();
var alwaysEnabled = _mo2Compiler.ModInis.Where(f => HasFlagInNotes(f.Value, Consts.WABBAJACK_ALWAYS_ENABLE)).Select(f => f.Key).Distinct();
var alwaysDisabled = _mo2Compiler.ModInis
.Where(f => HasFlagInNotes(f.Value, Consts.WABBAJACK_ALWAYS_DISABLE)).Select(f => f.Key).Distinct();
_allEnabledMods = _mo2Compiler.SelectedProfiles
.SelectMany(p => _mo2Compiler.MO2Folder.Combine("profiles", p, "modlist.txt").ReadAllLines())
.Where(line => line.StartsWith("+") || line.EndsWith("_separator"))
.Select(line => line.Substring(1).RelativeTo(_mo2Compiler.MO2ModsFolder))
.Concat(alwaysEnabled)
.Except(alwaysDisabled)
.ToList();
}
@ -35,18 +38,17 @@ namespace Wabbajack.Lib.CompilationSteps
return r;
}
public static bool IsAlwaysEnabled(dynamic data)
public static bool HasFlagInNotes(dynamic data, string flag)
{
if (data == null)
return false;
if (data.General != null && data.General.notes != null &&
data.General.notes.Contains(
Consts.WABBAJACK_ALWAYS_ENABLE))
flag))
return true;
if (data.General != null && data.General.comments != null &&
data.General.comments.Contains(Consts.WABBAJACK_ALWAYS_ENABLE))
return true;
return false;
return data.General != null && data.General.comments != null &&
data.General.comments.Contains(flag);
}
}
}

View File

@ -36,7 +36,7 @@ namespace Wabbajack.Lib.CompilationSteps
private async Task<byte[]> ReadAndCleanModlist(AbsolutePath absolutePath)
{
var alwaysEnabled = _mo2Compiler.ModInis.Where(f => IgnoreDisabledMods.IsAlwaysEnabled(f.Value))
var alwaysEnabled = _mo2Compiler.ModInis.Where(f => IgnoreDisabledMods.HasFlagInNotes(f.Value, Consts.WABBAJACK_ALWAYS_ENABLE))
.Select(f => f.Key)
.Select(f => f.FileName.ToString())
.Distinct();