mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Merge pull request #212 from wabbajack-tools/better-progress-bars
Macro-level progress bar updates.
This commit is contained in:
commit
23a2f5e50f
@ -33,19 +33,27 @@ namespace Wabbajack.Common
|
|||||||
public void NextStep(string name)
|
public void NextStep(string name)
|
||||||
{
|
{
|
||||||
_internalCurrentStep += 1;
|
_internalCurrentStep += 1;
|
||||||
|
Utils.Log(name);
|
||||||
_step.OnNext(_internalCurrentStep);
|
_step.OnNext(_internalCurrentStep);
|
||||||
_stepName.OnNext(name);
|
_stepName.OnNext(name);
|
||||||
_progress.OnNext(0.0f);
|
MakeUpdate(0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
private float OverAllStatus(float sub_status)
|
||||||
|
{
|
||||||
|
var per_step = 1.0f / _internalMaxStep;
|
||||||
|
var macro = _internalCurrentStep * per_step;
|
||||||
|
return macro + (per_step * sub_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MakeUpdate(float progress)
|
public void MakeUpdate(float progress)
|
||||||
{
|
{
|
||||||
_progress.OnNext(progress);
|
_progress.OnNext(OverAllStatus(progress));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MakeUpdate(int max, int curr)
|
public void MakeUpdate(int max, int curr)
|
||||||
{
|
{
|
||||||
_progress.OnNext((float)curr / ((float) (max == 0 ? 1 : max)));
|
MakeUpdate((float)curr / (max == 0 ? 1 : max));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -473,6 +473,20 @@ namespace Wabbajack.Common
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void PMap<TI>(this IEnumerable<TI> coll, WorkQueue queue, StatusUpdateTracker updateTracker,
|
||||||
|
Action<TI> f)
|
||||||
|
{
|
||||||
|
var cnt = 0;
|
||||||
|
var collist = coll.ToList();
|
||||||
|
collist.PMap(queue, itm =>
|
||||||
|
{
|
||||||
|
updateTracker.MakeUpdate(collist.Count, Interlocked.Increment(ref cnt));
|
||||||
|
f(itm);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static List<TR> PMap<TI, TR>(this IEnumerable<TI> coll, WorkQueue queue,
|
public static List<TR> PMap<TI, TR>(this IEnumerable<TI> coll, WorkQueue queue,
|
||||||
Func<TI, TR> f)
|
Func<TI, TR> f)
|
||||||
{
|
{
|
||||||
|
@ -121,7 +121,7 @@ namespace Wabbajack.Lib
|
|||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
Info("Installing Archives");
|
Info("Installing Archives");
|
||||||
archives.PMap(Queue,a => InstallArchive(a.Archive, a.AbsolutePath, grouped[a.Archive.Hash]));
|
archives.PMap(Queue, UpdateTracker,a => InstallArchive(a.Archive, a.AbsolutePath, grouped[a.Archive.Hash]));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InstallArchive(Archive archive, string absolutePath, IGrouping<string, FromArchive> grouping)
|
private void InstallArchive(Archive archive, string absolutePath, IGrouping<string, FromArchive> grouping)
|
||||||
@ -334,8 +334,9 @@ namespace Wabbajack.Lib
|
|||||||
Utils.Log("Optimizing Modlist directives");
|
Utils.Log("Optimizing Modlist directives");
|
||||||
var indexed = ModList.Directives.ToDictionary(d => d.To);
|
var indexed = ModList.Directives.ToDictionary(d => d.To);
|
||||||
|
|
||||||
|
UpdateTracker.NextStep("Looking for files to delete");
|
||||||
Directory.EnumerateFiles(OutputFolder, "*", DirectoryEnumerationOptions.Recursive)
|
Directory.EnumerateFiles(OutputFolder, "*", DirectoryEnumerationOptions.Recursive)
|
||||||
.PMap(Queue, f =>
|
.PMap(Queue, UpdateTracker, f =>
|
||||||
{
|
{
|
||||||
var relative_to = f.RelativeTo(OutputFolder);
|
var relative_to = f.RelativeTo(OutputFolder);
|
||||||
Utils.Status($"Checking if modlist file {relative_to}");
|
Utils.Status($"Checking if modlist file {relative_to}");
|
||||||
@ -348,7 +349,8 @@ namespace Wabbajack.Lib
|
|||||||
File.Delete(f);
|
File.Delete(f);
|
||||||
});
|
});
|
||||||
|
|
||||||
indexed.Values.PMap(Queue, d =>
|
UpdateTracker.NextStep("Looking for unmodified files");
|
||||||
|
indexed.Values.PMap(Queue, UpdateTracker, d =>
|
||||||
{
|
{
|
||||||
// Bit backwards, but we want to return null for
|
// Bit backwards, but we want to return null for
|
||||||
// all files we *want* installed. We return the files
|
// all files we *want* installed. We return the files
|
||||||
@ -364,6 +366,7 @@ namespace Wabbajack.Lib
|
|||||||
}).Where(d => d != null)
|
}).Where(d => d != null)
|
||||||
.Do(d => indexed.Remove(d.To));
|
.Do(d => indexed.Remove(d.To));
|
||||||
|
|
||||||
|
UpdateTracker.NextStep("Updating Modlist");
|
||||||
Utils.Log($"Optimized {ModList.Directives.Count} directives to {indexed.Count} required");
|
Utils.Log($"Optimized {ModList.Directives.Count} directives to {indexed.Count} required");
|
||||||
var requiredArchives = indexed.Values.OfType<FromArchive>()
|
var requiredArchives = indexed.Values.OfType<FromArchive>()
|
||||||
.GroupBy(d => d.ArchiveHashPath[0])
|
.GroupBy(d => d.ArchiveHashPath[0])
|
||||||
|
@ -72,7 +72,7 @@ namespace Wabbajack.Lib
|
|||||||
|
|
||||||
protected override bool _Begin()
|
protected override bool _Begin()
|
||||||
{
|
{
|
||||||
ConfigureProcessor(10);
|
ConfigureProcessor(16);
|
||||||
UpdateTracker.Reset();
|
UpdateTracker.Reset();
|
||||||
UpdateTracker.NextStep("Gathering information");
|
UpdateTracker.NextStep("Gathering information");
|
||||||
Info("Looking for other profiles");
|
Info("Looking for other profiles");
|
||||||
@ -161,7 +161,8 @@ namespace Wabbajack.Lib
|
|||||||
|
|
||||||
Info($"Found {AllFiles.Count} files to build into mod list");
|
Info($"Found {AllFiles.Count} files to build into mod list");
|
||||||
|
|
||||||
Info("Verifying destinations");
|
UpdateTracker.NextStep("Verifying destinations");
|
||||||
|
|
||||||
var dups = AllFiles.GroupBy(f => f.Path)
|
var dups = AllFiles.GroupBy(f => f.Path)
|
||||||
.Where(fs => fs.Count() > 1)
|
.Where(fs => fs.Count() > 1)
|
||||||
.Select(fs =>
|
.Select(fs =>
|
||||||
@ -177,6 +178,9 @@ namespace Wabbajack.Lib
|
|||||||
|
|
||||||
ExtraFiles = new ConcurrentBag<Directive>();
|
ExtraFiles = new ConcurrentBag<Directive>();
|
||||||
|
|
||||||
|
|
||||||
|
UpdateTracker.NextStep("Loading INIs");
|
||||||
|
|
||||||
ModInis = Directory.EnumerateDirectories(Path.Combine(MO2Folder, "mods"))
|
ModInis = Directory.EnumerateDirectories(Path.Combine(MO2Folder, "mods"))
|
||||||
.Select(f =>
|
.Select(f =>
|
||||||
{
|
{
|
||||||
@ -191,12 +195,12 @@ namespace Wabbajack.Lib
|
|||||||
|
|
||||||
var stack = MakeStack();
|
var stack = MakeStack();
|
||||||
|
|
||||||
|
|
||||||
UpdateTracker.NextStep("Running Compilation Stack");
|
UpdateTracker.NextStep("Running Compilation Stack");
|
||||||
var results = AllFiles.PMap(Queue, UpdateTracker, f => RunStack(stack, f)).ToList();
|
var results = AllFiles.PMap(Queue, UpdateTracker, f => RunStack(stack, f)).ToList();
|
||||||
|
|
||||||
// Add the extra files that were generated by the stack
|
// Add the extra files that were generated by the stack
|
||||||
Info($"Adding {ExtraFiles.Count} that were generated by the stack");
|
|
||||||
|
UpdateTracker.NextStep($"Adding {ExtraFiles.Count} that were generated by the stack");
|
||||||
results = results.Concat(ExtraFiles).ToList();
|
results = results.Concat(ExtraFiles).ToList();
|
||||||
|
|
||||||
var nomatch = results.OfType<NoMatch>();
|
var nomatch = results.OfType<NoMatch>();
|
||||||
@ -227,10 +231,15 @@ namespace Wabbajack.Lib
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateTracker.NextStep("Verifying Files");
|
||||||
zEditIntegration.VerifyMerges(this);
|
zEditIntegration.VerifyMerges(this);
|
||||||
|
|
||||||
|
|
||||||
|
UpdateTracker.NextStep("Gathering Archives");
|
||||||
GatherArchives();
|
GatherArchives();
|
||||||
|
UpdateTracker.NextStep("Including Archive Metadata");
|
||||||
IncludeArchiveMetadata();
|
IncludeArchiveMetadata();
|
||||||
|
UpdateTracker.NextStep("Building Patches");
|
||||||
BuildPatches();
|
BuildPatches();
|
||||||
|
|
||||||
ModList = new ModList
|
ModList = new ModList
|
||||||
@ -248,16 +257,22 @@ namespace Wabbajack.Lib
|
|||||||
Website = ModListWebsite ?? ""
|
Website = ModListWebsite ?? ""
|
||||||
};
|
};
|
||||||
|
|
||||||
|
UpdateTracker.NextStep("Running Validation");
|
||||||
|
|
||||||
ValidateModlist.RunValidation(ModList);
|
ValidateModlist.RunValidation(ModList);
|
||||||
|
UpdateTracker.NextStep("Generating Report");
|
||||||
|
|
||||||
GenerateReport();
|
GenerateReport();
|
||||||
|
|
||||||
|
UpdateTracker.NextStep("Exporting Modlist");
|
||||||
ExportModList();
|
ExportModList();
|
||||||
|
|
||||||
ResetMembers();
|
ResetMembers();
|
||||||
|
|
||||||
ShowReport();
|
ShowReport();
|
||||||
|
|
||||||
Info("Done Building Modlist");
|
UpdateTracker.NextStep("Done Building Modlist");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,8 +30,7 @@ namespace Wabbajack.Lib
|
|||||||
|
|
||||||
protected override bool _Begin()
|
protected override bool _Begin()
|
||||||
{
|
{
|
||||||
ConfigureProcessor(RecommendQueueSize());
|
ConfigureProcessor(17, RecommendQueueSize());
|
||||||
ValidateFreeSpace();
|
|
||||||
var game = GameRegistry.Games[ModList.GameType];
|
var game = GameRegistry.Games[ModList.GameType];
|
||||||
|
|
||||||
if (GameFolder == null)
|
if (GameFolder == null)
|
||||||
@ -47,7 +46,10 @@ namespace Wabbajack.Lib
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateTracker.NextStep("Validating Game ESMs");
|
||||||
ValidateGameESMs();
|
ValidateGameESMs();
|
||||||
|
|
||||||
|
UpdateTracker.NextStep("Validating Modlist");
|
||||||
ValidateModlist.RunValidation(ModList);
|
ValidateModlist.RunValidation(ModList);
|
||||||
|
|
||||||
Directory.CreateDirectory(OutputFolder);
|
Directory.CreateDirectory(OutputFolder);
|
||||||
@ -67,10 +69,16 @@ namespace Wabbajack.Lib
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateTracker.NextStep("Optimizing Modlist");
|
||||||
OptimizeModlist();
|
OptimizeModlist();
|
||||||
|
|
||||||
|
UpdateTracker.NextStep("Hashing Archives");
|
||||||
HashArchives();
|
HashArchives();
|
||||||
|
|
||||||
|
UpdateTracker.NextStep("Downloading Missing Archives");
|
||||||
DownloadArchives();
|
DownloadArchives();
|
||||||
|
|
||||||
|
UpdateTracker.NextStep("Hashing Remaining Archives");
|
||||||
HashArchives();
|
HashArchives();
|
||||||
|
|
||||||
var missing = ModList.Archives.Where(a => !HashedArchives.ContainsKey(a.Hash)).ToList();
|
var missing = ModList.Archives.Where(a => !HashedArchives.ContainsKey(a.Hash)).ToList();
|
||||||
@ -84,20 +92,28 @@ namespace Wabbajack.Lib
|
|||||||
Error("Cannot continue, was unable to download one or more archives");
|
Error("Cannot continue, was unable to download one or more archives");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateTracker.NextStep("Priming VFS");
|
||||||
PrimeVFS();
|
PrimeVFS();
|
||||||
|
|
||||||
|
UpdateTracker.NextStep("Building Folder Structure");
|
||||||
BuildFolderStructure();
|
BuildFolderStructure();
|
||||||
|
|
||||||
|
UpdateTracker.NextStep("Installing Archives");
|
||||||
InstallArchives();
|
InstallArchives();
|
||||||
|
|
||||||
|
UpdateTracker.NextStep("Installing Included files");
|
||||||
InstallIncludedFiles();
|
InstallIncludedFiles();
|
||||||
|
|
||||||
|
UpdateTracker.NextStep("Installing Archive Metas");
|
||||||
InstallIncludedDownloadMetas();
|
InstallIncludedDownloadMetas();
|
||||||
|
|
||||||
|
UpdateTracker.NextStep("Building BSAs");
|
||||||
BuildBSAs();
|
BuildBSAs();
|
||||||
|
|
||||||
|
UpdateTracker.NextStep("Generating Merges");
|
||||||
zEditIntegration.GenerateMerges(this);
|
zEditIntegration.GenerateMerges(this);
|
||||||
|
|
||||||
Info("Installation complete! You may exit the program.");
|
UpdateTracker.NextStep("Installation complete! You may exit the program.");
|
||||||
// Removed until we decide if we want this functionality
|
|
||||||
// Nexus devs weren't sure this was a good idea, I (halgari) agree.
|
|
||||||
//AskToEndorse();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,8 +93,20 @@ namespace Wabbajack.VirtualFileSystem
|
|||||||
|
|
||||||
public bool IsNative => Parent == null;
|
public bool IsNative => Parent == null;
|
||||||
|
|
||||||
public IEnumerable<VirtualFile> ThisAndAllChildren =>
|
private IEnumerable<VirtualFile> _thisAndAllChildren = null;
|
||||||
Children.SelectMany(child => child.ThisAndAllChildren).Append(this);
|
|
||||||
|
public IEnumerable<VirtualFile> ThisAndAllChildren
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_thisAndAllChildren == null)
|
||||||
|
{
|
||||||
|
_thisAndAllChildren = Children.SelectMany(child => child.ThisAndAllChildren).Append(this).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return _thisAndAllChildren;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -267,4 +279,4 @@ namespace Wabbajack.VirtualFileSystem
|
|||||||
_fullPath = fullPath;
|
_fullPath = fullPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user