fixes #16 - multiple profiles are now supported

This commit is contained in:
Timothy Baldridge 2019-09-03 15:17:00 -06:00
parent d21a11b005
commit 7acd964f48
4 changed files with 42 additions and 19 deletions

View File

@ -11,6 +11,8 @@ that is copied directly into a modfile (commonly used for `SSE Terrain Tamriel.e
* Fix crash caused by multiple downloads with the same SHA256 * Fix crash caused by multiple downloads with the same SHA256
* Putting `WABBAJACK_ALWAYS_INCLUDE` on a mod's notes/comments will cause it to always be included in the modlist, even if disabled * Putting `WABBAJACK_ALWAYS_INCLUDE` on a mod's notes/comments will cause it to always be included in the modlist, even if disabled
* All `.json`, `.ini`, and `.yaml` files that contain remappable paths are now inlined and remapped. * All `.json`, `.ini`, and `.yaml` files that contain remappable paths are now inlined and remapped.
* If Wabbajack finds a file called `otherprofiles.txt` inside the compile'd profile's folder. Then that file is assumed
to be a list of other profiles to be included in the install. This list should be the name of a profile, one name per line.
#### Version 0.8.1 - 8/29/2019 #### Version 0.8.1 - 8/29/2019
* Fixed a bug that was causing VFS temp folders not to be cleaned * Fixed a bug that was causing VFS temp folders not to be cleaned

View File

@ -624,6 +624,7 @@ namespace VFS
Size = fio.Length; Size = fio.Length;
Hash = Utils.FileSHA256(StagedPath); Hash = Utils.FileSHA256(StagedPath);
LastModified = fio.LastWriteTime.ToMilliseconds(); LastModified = fio.LastWriteTime.ToMilliseconds();
} }

View File

@ -113,6 +113,8 @@ namespace Wabbajack
GamePath = ((string)MO2Ini.General.gamePath).Replace("\\\\", "\\"); GamePath = ((string)MO2Ini.General.gamePath).Replace("\\\\", "\\");
} }
public HashSet<string> SelectedProfiles { get; set; } = new HashSet<string>();
private IndexedArchive LoadArchive(string file) private IndexedArchive LoadArchive(string file)
{ {
var info = new IndexedArchive(); var info = new IndexedArchive();
@ -140,6 +142,16 @@ namespace Wabbajack
public void Compile() public void Compile()
{ {
Info($"Looking for other profiles");
var other_profiles_path = Path.Combine(MO2ProfileDir, "otherprofiles.txt");
if (File.Exists(other_profiles_path))
{
SelectedProfiles = File.ReadAllLines(other_profiles_path).ToHashSet();
SelectedProfiles.Add(MO2Profile);
}
Info($"Using Profiles: " + string.Join(", ", SelectedProfiles.OrderBy(p => p)));
Info($"Indexing {MO2Folder}"); Info($"Indexing {MO2Folder}");
VFS.AddRoot(MO2Folder); VFS.AddRoot(MO2Folder);
Info($"Indexing {GamePath}"); Info($"Indexing {GamePath}");
@ -827,21 +839,21 @@ namespace Wabbajack
private Func<RawSourceFile, Directive> IgnoreDisabledMods() private Func<RawSourceFile, Directive> IgnoreDisabledMods()
{ {
var always_enabled = ModInis.Where(f => IsAlwaysEnabled(f.Value)).Select(f => f.Key).ToHashSet(); var always_enabled = ModInis.Where(f => IsAlwaysEnabled(f.Value)).Select(f => f.Key).ToHashSet();
var disabled_mods = File.ReadAllLines(Path.Combine(MO2ProfileDir, "modlist.txt"))
.Where(line => line.StartsWith("-") && !line.EndsWith("_separator")) var all_enabled_mods = SelectedProfiles
.SelectMany(p => File.ReadAllLines(Path.Combine(MO2Folder, "profiles", p, "modlist.txt")))
.Where(line => line.StartsWith("+") || line.EndsWith("_separator"))
.Select(line => line.Substring(1)) .Select(line => line.Substring(1))
.Where(line => !always_enabled.Contains(line)) .Concat(always_enabled)
.Select(line => Path.Combine("mods", line + "\\")) .Select(line => Path.Combine("mods", line) + "\\")
.ToList(); .ToList();
return source => return source =>
{ {
if (disabled_mods.FirstOrDefault(mod => source.Path.StartsWith(mod)) != null) if (!source.Path.StartsWith("mods") || all_enabled_mods.Any(mod => source.Path.StartsWith(mod))) return null;
{
var r = source.EvolveTo<IgnoredDirectly>(); var r = source.EvolveTo<IgnoredDirectly>();
r.Reason = "Disabled Mod"; r.Reason = "Disabled Mod";
return r; return r;
}
return null;
}; };
} }
@ -912,10 +924,11 @@ namespace Wabbajack
private Func<RawSourceFile, Directive> IncludeThisProfile() private Func<RawSourceFile, Directive> IncludeThisProfile()
{ {
var correct_profile = Path.Combine("profiles", MO2Profile) + "\\"; var correct_profiles = SelectedProfiles.Select(p => Path.Combine("profiles", p) + "\\").ToList();
return source => return source =>
{ {
if (source.Path.StartsWith(correct_profile)) if (correct_profiles.Any(p => source.Path.StartsWith(p)))
{ {
byte[] data; byte[] data;
if (source.Path.EndsWith("\\modlist.txt")) if (source.Path.EndsWith("\\modlist.txt"))
@ -942,13 +955,20 @@ namespace Wabbajack
private Func<RawSourceFile, Directive> IgnoreOtherProfiles() private Func<RawSourceFile, Directive> IgnoreOtherProfiles()
{ {
var correct_profile = Path.Combine("profiles", MO2Profile) + "\\"; var profiles = SelectedProfiles
.Select(p => Path.Combine("profiles", p) + "\\")
.ToList();
return source => return source =>
{ {
if (source.Path.StartsWith("profiles\\") && !source.Path.StartsWith(correct_profile)) if (source.Path.StartsWith("profiles\\"))
{ {
if (profiles.Any(profile => !source.Path.StartsWith(profile)))
{
return null;
}
var c = source.EvolveTo<IgnoredDirectly>(); var c = source.EvolveTo<IgnoredDirectly>();
c.Reason = "File not for this profile"; c.Reason = "File not for selected profiles";
return c; return c;
} }
return null; return null;