issue-861 - Fix always enabled mods being out of order

This commit is contained in:
Timothy Baldridge 2020-05-23 15:41:41 -06:00
parent 05314801d1
commit dd1303e2d7
4 changed files with 63 additions and 6 deletions

View File

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

View File

@ -43,6 +43,7 @@ namespace Wabbajack.Lib.CompilationSteps
{
var alwaysEnabled = _mo2Compiler.ModInis.Where(f => IgnoreDisabledMods.IsAlwaysEnabled(f.Value))
.Select(f => f.Key)
.Select(f => f.FileName.ToString())
.Distinct();
var lines = (await absolutePath.ReadAllLinesAsync()).Where(l =>
{

View File

@ -472,6 +472,52 @@ namespace Wabbajack.Test
utils.VerifyInstalledFile(mod, @"Data\scripts\test.pex");
}
/// <summary>
/// Issue #861 : https://github.com/wabbajack-tools/wabbajack/issues/861
/// </summary>
/// <returns></returns>
[Fact]
public async Task AlwaysEnabledModsRetainTheirOrder()
{
var profile = utils.AddProfile();
var enabledMod = utils.AddMod();
var enabledTestPex = utils.AddModFile(enabledMod, @"Data\scripts\enabledTestPex.pex", 10);
var disabledMod = utils.AddMod();
var disabledTestPex = utils.AddModFile(disabledMod, @"Data\scripts\disabledTestPex.pex", 10);
await disabledMod.RelativeTo(utils.ModsFolder).Combine("meta.ini").WriteAllLinesAsync(
"[General]",
$"notes={Consts.WABBAJACK_ALWAYS_ENABLE}");
await utils.Configure(new []
{
(disabledMod, false),
(enabledMod, true)
});
utils.AddManualDownload(
new Dictionary<string, byte[]>
{
{"/file1.pex", await enabledTestPex.ReadAllBytesAsync()},
{"/file2.pex", await disabledTestPex.ReadAllBytesAsync()},
});
await CompileAndInstall(profile);
utils.VerifyInstalledFile(enabledMod, @"Data\scripts\enabledTestPex.pex");
utils.VerifyInstalledFile(disabledMod, @"Data\scripts\disabledTestPex.pex");
var modlistTxt = await utils.InstallFolder.Combine("profiles", profile, "modlist.txt").ReadAllLinesAsync();
Assert.Equal(new string[]
{
$"-{disabledMod}",
$"+{enabledMod}"
}, modlistTxt.ToArray());
}
}
}

View File

@ -42,7 +42,7 @@ namespace Wabbajack.Test
public List<string> Mods = new List<string>();
public async Task Configure()
public async Task Configure(IEnumerable<(string ModName, bool IsEnabled)> enabledMods = null)
{
await MO2Folder.Combine("ModOrganizer.ini").WriteAllLinesAsync(
"[General]",
@ -53,11 +53,22 @@ namespace Wabbajack.Test
DownloadsFolder.CreateDirectory();
GameFolder.Combine("Data").CreateDirectory();
Profiles.Do(profile =>
if (enabledMods == null)
{
MO2Folder.Combine("profiles", profile, "modlist.txt").WriteAllLines(
Mods.Select(s => $"+{s}").ToArray());
});
Profiles.Do(profile =>
{
MO2Folder.Combine("profiles", profile, "modlist.txt").WriteAllLines(
Mods.Select(s => $"+{s}").ToArray());
});
}
else
{
Profiles.Do(profile =>
{
MO2Folder.Combine("profiles", profile, "modlist.txt").WriteAllLines(
enabledMods.Select(s => $"{(s.IsEnabled ? "+" : "-")}{s.ModName}").ToArray());
});
}
}
public string AddProfile(string name = null)