mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Fix how we deal with additional profiles
This commit is contained in:
parent
c84057ec22
commit
8d1810355b
@ -180,7 +180,7 @@ namespace Wabbajack
|
|||||||
DownloadLocation.TargetPath = settings.Downloads;
|
DownloadLocation.TargetPath = settings.Downloads;
|
||||||
OutputLocation.TargetPath = settings.OutputFile;
|
OutputLocation.TargetPath = settings.OutputFile;
|
||||||
SelectedProfile = settings.Profile;
|
SelectedProfile = settings.Profile;
|
||||||
OtherProfiles = settings.OtherProfiles;
|
OtherProfiles = settings.AdditionalProfiles;
|
||||||
AlwaysEnabled = settings.AlwaysEnabled;
|
AlwaysEnabled = settings.AlwaysEnabled;
|
||||||
NoMatchInclude = settings.NoMatchInclude;
|
NoMatchInclude = settings.NoMatchInclude;
|
||||||
}
|
}
|
||||||
@ -204,7 +204,7 @@ namespace Wabbajack
|
|||||||
Downloads = DownloadLocation.TargetPath,
|
Downloads = DownloadLocation.TargetPath,
|
||||||
OutputFile = OutputLocation.TargetPath,
|
OutputFile = OutputLocation.TargetPath,
|
||||||
Profile = SelectedProfile,
|
Profile = SelectedProfile,
|
||||||
OtherProfiles = OtherProfiles,
|
AdditionalProfiles = OtherProfiles,
|
||||||
AlwaysEnabled = AlwaysEnabled,
|
AlwaysEnabled = AlwaysEnabled,
|
||||||
NoMatchInclude = NoMatchInclude,
|
NoMatchInclude = NoMatchInclude,
|
||||||
UseGamePaths = true
|
UseGamePaths = true
|
||||||
@ -256,7 +256,7 @@ namespace Wabbajack
|
|||||||
UseGamePaths = true,
|
UseGamePaths = true,
|
||||||
OutputFile = OutputLocation.TargetPath.Combine(SelectedProfile).WithExtension(Ext.Wabbajack),
|
OutputFile = OutputLocation.TargetPath.Combine(SelectedProfile).WithExtension(Ext.Wabbajack),
|
||||||
AlwaysEnabled = AlwaysEnabled,
|
AlwaysEnabled = AlwaysEnabled,
|
||||||
OtherProfiles = OtherProfiles,
|
AdditionalProfiles = OtherProfiles,
|
||||||
NoMatchInclude = NoMatchInclude,
|
NoMatchInclude = NoMatchInclude,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -101,14 +101,61 @@ public class InstallCompileInstallVerify : IVerb
|
|||||||
|
|
||||||
var compiler = MO2Compiler.Create(_serviceProvider, inferedSettings);
|
var compiler = MO2Compiler.Create(_serviceProvider, inferedSettings);
|
||||||
result = await compiler.Begin(token);
|
result = await compiler.Begin(token);
|
||||||
|
if (!result)
|
||||||
|
return result ? 0 : 3;
|
||||||
|
|
||||||
|
|
||||||
|
var installPath2 = outputs.Combine("verify_list");
|
||||||
|
|
||||||
return result ? 0 : 3;
|
var comparison = await StandardInstaller.LoadFromFile(_dtos, wabbajackPath);
|
||||||
|
|
||||||
|
var modlist2 = await StandardInstaller.LoadFromFile(_dtos, inferedSettings.OutputFile);
|
||||||
|
if (CompareModlists(comparison, modlist2))
|
||||||
|
return 3;
|
||||||
|
|
||||||
|
var installer2 = StandardInstaller.Create(_serviceProvider, new InstallerConfiguration
|
||||||
|
{
|
||||||
|
Downloads = downloads,
|
||||||
|
Install = installPath2,
|
||||||
|
ModList = modlist2,
|
||||||
|
Game = modlist2.GameType,
|
||||||
|
ModlistArchive = inferedSettings.OutputFile,
|
||||||
|
GameFolder = _gameLocator.GameLocation(modlist2.GameType)
|
||||||
|
});
|
||||||
|
|
||||||
|
result = await installer2.Begin(token);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Error installing recompiled {MachineUrl}", machineUrl);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool CompareModlists(ModList a, ModList b)
|
||||||
|
{
|
||||||
|
var aDirectives = a.Directives.ToDictionary(d => d.To);
|
||||||
|
var bDirectives = b.Directives.ToDictionary(d => d.To);
|
||||||
|
|
||||||
|
var found = false;
|
||||||
|
foreach (var missing in aDirectives.Where(ad => !bDirectives.ContainsKey(ad.Key)))
|
||||||
|
{
|
||||||
|
_logger.LogWarning("File {To} is missing in recompiled list", missing.Key);
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var missing in bDirectives.Where(bd => !aDirectives.ContainsKey(bd.Key)))
|
||||||
|
{
|
||||||
|
_logger.LogWarning("File {To} is missing in original list", missing.Key);
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
private async Task<bool> DownloadMachineUrl(string machineUrl, AbsolutePath wabbajack, CancellationToken token)
|
private async Task<bool> DownloadMachineUrl(string machineUrl, AbsolutePath wabbajack, CancellationToken token)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Downloading {MachineUrl}", machineUrl);
|
_logger.LogInformation("Downloading {MachineUrl}", machineUrl);
|
||||||
|
@ -85,7 +85,6 @@ public class ModListHarness
|
|||||||
settings.Game = Game.SkyrimSpecialEdition;
|
settings.Game = Game.SkyrimSpecialEdition;
|
||||||
settings.Source = _source;
|
settings.Source = _source;
|
||||||
settings.ModListName = _profileName;
|
settings.ModListName = _profileName;
|
||||||
settings.SelectedProfiles = new[] {_profileName};
|
|
||||||
settings.Profile = _profileName;
|
settings.Profile = _profileName;
|
||||||
settings.OutputFile = _outputFile;
|
settings.OutputFile = _outputFile;
|
||||||
configureSettings(settings);
|
configureSettings(settings);
|
||||||
|
@ -21,7 +21,7 @@ public class IgnoreDisabledMods : ACompilationStep
|
|||||||
//var alwaysDisabled = _mo2Compiler.ModInis
|
//var alwaysDisabled = _mo2Compiler.ModInis
|
||||||
// .Where(f => HasFlagInNotes(f.Value, Consts.WABBAJACK_ALWAYS_DISABLE)).Select(f => f.Key).Distinct();
|
// .Where(f => HasFlagInNotes(f.Value, Consts.WABBAJACK_ALWAYS_DISABLE)).Select(f => f.Key).Distinct();
|
||||||
|
|
||||||
_allEnabledMods = _mo2Compiler._settings.SelectedProfiles
|
_allEnabledMods = _mo2Compiler._settings.AllProfiles
|
||||||
.SelectMany(p => _mo2Compiler._settings.Source.Combine("profiles", p, "modlist.txt").ReadAllLines())
|
.SelectMany(p => _mo2Compiler._settings.Source.Combine("profiles", p, "modlist.txt").ReadAllLines())
|
||||||
.Where(line => line.StartsWith("+") || line.EndsWith("_separator"))
|
.Where(line => line.StartsWith("+") || line.EndsWith("_separator"))
|
||||||
.Select(line => line[1..].ToRelativePath().RelativeTo(_mo2Compiler.MO2ModsFolder))
|
.Select(line => line[1..].ToRelativePath().RelativeTo(_mo2Compiler.MO2ModsFolder))
|
||||||
|
@ -18,7 +18,7 @@ public class IgnoreOtherProfiles : ACompilationStep
|
|||||||
_mo2Compiler = (MO2Compiler) compiler;
|
_mo2Compiler = (MO2Compiler) compiler;
|
||||||
_modProfilesFolder = _mo2Compiler._settings.Source.Combine("profiles");
|
_modProfilesFolder = _mo2Compiler._settings.Source.Combine("profiles");
|
||||||
|
|
||||||
_profiles = _mo2Compiler._settings.SelectedProfiles
|
_profiles = _mo2Compiler._settings.AllProfiles
|
||||||
.Select(p => _modProfilesFolder.Combine(p))
|
.Select(p => _modProfilesFolder.Combine(p))
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ public class IgnoreSaveFiles : MO2CompilationStep
|
|||||||
_includeSaves = _compiler._settings.Source.EnumerateFiles(_tag).FirstOrDefault() != default;
|
_includeSaves = _compiler._settings.Source.EnumerateFiles(_tag).FirstOrDefault() != default;
|
||||||
|
|
||||||
_profilePaths =
|
_profilePaths =
|
||||||
MO2Compiler._settings.SelectedProfiles
|
MO2Compiler._settings.AllProfiles
|
||||||
.Select(p => _compiler._settings.Source.Combine(Consts.MO2Profiles, p, Consts.MO2Saves)).ToArray();
|
.Select(p => _compiler._settings.Source.Combine(Consts.MO2Profiles, p, Consts.MO2Saves)).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ public class IncludeThisProfile : ACompilationStep
|
|||||||
public IncludeThisProfile(ACompiler compiler) : base(compiler)
|
public IncludeThisProfile(ACompiler compiler) : base(compiler)
|
||||||
{
|
{
|
||||||
_mo2Compiler = (MO2Compiler) compiler;
|
_mo2Compiler = (MO2Compiler) compiler;
|
||||||
_correctProfiles = _mo2Compiler._settings.SelectedProfiles
|
_correctProfiles = _mo2Compiler._settings.AllProfiles
|
||||||
.Select(p => _mo2Compiler.MO2ProfileDir.Parent.Combine(p)).ToList();
|
.Select(p => _mo2Compiler.MO2ProfileDir.Parent.Combine(p)).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,16 +38,18 @@ public class IncludeThisProfile : ACompilationStep
|
|||||||
|
|
||||||
private async Task<byte[]> ReadAndCleanModlist(AbsolutePath absolutePath)
|
private async Task<byte[]> ReadAndCleanModlist(AbsolutePath absolutePath)
|
||||||
{
|
{
|
||||||
var alwaysEnabled = _mo2Compiler.ModInis
|
var alwaysEnabledMods = _compiler._settings.AlwaysEnabled
|
||||||
.Where(f => IgnoreDisabledMods.HasFlagInNotes(f.Value, Consts.WABBAJACK_ALWAYS_ENABLE))
|
.Where(f => f.InFolder(Consts.MO2ModFolderName))
|
||||||
.Select(f => f.Key)
|
.Where(f => f.Level > 1)
|
||||||
.Select(f => f.FileName.ToString())
|
.Select(f => f.GetPart(1))
|
||||||
.Distinct();
|
.ToHashSet();
|
||||||
|
|
||||||
var lines = await absolutePath.ReadAllLinesAsync()
|
var lines = await absolutePath.ReadAllLinesAsync()
|
||||||
.Where(l =>
|
.Where(l =>
|
||||||
{
|
{
|
||||||
|
var modName = l[1..].Trim();
|
||||||
return l.StartsWith("+")
|
return l.StartsWith("+")
|
||||||
|| alwaysEnabled.Any(x => x.Equals(l.Substring(1)))
|
|| alwaysEnabledMods.Contains(modName)
|
||||||
|| l.EndsWith("_separator");
|
|| l.EndsWith("_separator");
|
||||||
}).ToList();
|
}).ToList();
|
||||||
return Encoding.UTF8.GetBytes(string.Join(Consts.LineSeparator, lines));
|
return Encoding.UTF8.GetBytes(string.Join(Consts.LineSeparator, lines));
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
using Wabbajack.DTOs;
|
using Wabbajack.DTOs;
|
||||||
using Wabbajack.Paths;
|
using Wabbajack.Paths;
|
||||||
|
|
||||||
@ -23,7 +26,24 @@ public class CompilerSettings
|
|||||||
public string ModlistReadme { get; set; } = "";
|
public string ModlistReadme { get; set; } = "";
|
||||||
public Uri? ModListWebsite { get; set; }
|
public Uri? ModListWebsite { get; set; }
|
||||||
public Version ModlistVersion { get; set; } = Version.Parse("0.0.1.0");
|
public Version ModlistVersion { get; set; } = Version.Parse("0.0.1.0");
|
||||||
public string[] SelectedProfiles { get; set; } = Array.Empty<string>();
|
|
||||||
|
/// <summary>
|
||||||
|
/// The main (default) profile
|
||||||
|
/// </summary>
|
||||||
|
public string Profile { get; set; } = "";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Secondary profiles to include in the modlist
|
||||||
|
/// </summary>
|
||||||
|
public string[] AdditionalProfiles { get; set; } = Array.Empty<string>();
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// All profiles to be added to the compiled modlist
|
||||||
|
/// </summary>
|
||||||
|
[JsonIgnore]
|
||||||
|
public IEnumerable<string> AllProfiles => AdditionalProfiles.Append(Profile);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -37,7 +57,6 @@ public class CompilerSettings
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public RelativePath[] Include { get; set; } = Array.Empty<RelativePath>();
|
public RelativePath[] Include { get; set; } = Array.Empty<RelativePath>();
|
||||||
|
|
||||||
public string Profile { get; set; } = "";
|
|
||||||
public RelativePath[] AlwaysEnabled { get; set; } = Array.Empty<RelativePath>();
|
public RelativePath[] AlwaysEnabled { get; set; } = Array.Empty<RelativePath>();
|
||||||
public string[] OtherProfiles { get; set; }
|
|
||||||
}
|
}
|
@ -53,8 +53,9 @@ public class CompilerSettingsInferencer
|
|||||||
var selectedProfile = general["selected_profile"].FromMO2Ini();
|
var selectedProfile = general["selected_profile"].FromMO2Ini();
|
||||||
//cs.GamePath = general["gamePath"].FromMO2Ini().ToAbsolutePath();
|
//cs.GamePath = general["gamePath"].FromMO2Ini().ToAbsolutePath();
|
||||||
cs.ModListName = selectedProfile;
|
cs.ModListName = selectedProfile;
|
||||||
|
cs.Profile = selectedProfile;
|
||||||
cs.OutputFile = cs.Source.Parent;
|
|
||||||
|
cs.OutputFile = cs.Source.Parent.Combine(selectedProfile).WithExtension(Ext.Wabbajack);
|
||||||
|
|
||||||
var settings = iniData["Settings"];
|
var settings = iniData["Settings"];
|
||||||
cs.Downloads = settings["download_directory"].FromMO2Ini().ToAbsolutePath();
|
cs.Downloads = settings["download_directory"].FromMO2Ini().ToAbsolutePath();
|
||||||
@ -88,7 +89,7 @@ public class CompilerSettingsInferencer
|
|||||||
var otherProfilesFile = settingsFile.Parent.Combine("otherprofiles.txt");
|
var otherProfilesFile = settingsFile.Parent.Combine("otherprofiles.txt");
|
||||||
if (otherProfilesFile.FileExists())
|
if (otherProfilesFile.FileExists())
|
||||||
{
|
{
|
||||||
cs.OtherProfiles = await otherProfilesFile.ReadAllLinesAsync().ToArray();
|
cs.AdditionalProfiles = await otherProfilesFile.ReadAllLinesAsync().ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
cs.OutputFile = cs.Source.Parent.Combine(cs.Profile).WithExtension(Ext.Wabbajack);
|
cs.OutputFile = cs.Source.Parent.Combine(cs.Profile).WithExtension(Ext.Wabbajack);
|
||||||
|
@ -173,6 +173,7 @@ public struct RelativePath : IPath, IEquatable<RelativePath>, IComparable<Relati
|
|||||||
|
|
||||||
public RelativePath TopParent => new(Parts[..1]);
|
public RelativePath TopParent => new(Parts[..1]);
|
||||||
public RelativePath FileNameWithoutExtension => Parts[^1][..Extension.ToString().Length].ToRelativePath();
|
public RelativePath FileNameWithoutExtension => Parts[^1][..Extension.ToString().Length].ToRelativePath();
|
||||||
|
public int Level => Parts.Length;
|
||||||
|
|
||||||
public bool EndsWith(string postfix)
|
public bool EndsWith(string postfix)
|
||||||
{
|
{
|
||||||
@ -188,4 +189,9 @@ public struct RelativePath : IPath, IEquatable<RelativePath>, IComparable<Relati
|
|||||||
{
|
{
|
||||||
return ToString().StartsWith(s);
|
return ToString().StartsWith(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetPart(int i)
|
||||||
|
{
|
||||||
|
return Parts[i];
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user