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)
|
||||
{
|
||||
_internalCurrentStep += 1;
|
||||
Utils.Log(name);
|
||||
_step.OnNext(_internalCurrentStep);
|
||||
_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)
|
||||
{
|
||||
_progress.OnNext(progress);
|
||||
_progress.OnNext(OverAllStatus(progress));
|
||||
}
|
||||
|
||||
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,
|
||||
Func<TI, TR> f)
|
||||
{
|
||||
|
@ -121,7 +121,7 @@ namespace Wabbajack.Lib
|
||||
.ToList();
|
||||
|
||||
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)
|
||||
@ -334,8 +334,9 @@ namespace Wabbajack.Lib
|
||||
Utils.Log("Optimizing Modlist directives");
|
||||
var indexed = ModList.Directives.ToDictionary(d => d.To);
|
||||
|
||||
UpdateTracker.NextStep("Looking for files to delete");
|
||||
Directory.EnumerateFiles(OutputFolder, "*", DirectoryEnumerationOptions.Recursive)
|
||||
.PMap(Queue, f =>
|
||||
.PMap(Queue, UpdateTracker, f =>
|
||||
{
|
||||
var relative_to = f.RelativeTo(OutputFolder);
|
||||
Utils.Status($"Checking if modlist file {relative_to}");
|
||||
@ -348,7 +349,8 @@ namespace Wabbajack.Lib
|
||||
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
|
||||
// all files we *want* installed. We return the files
|
||||
@ -364,6 +366,7 @@ namespace Wabbajack.Lib
|
||||
}).Where(d => d != null)
|
||||
.Do(d => indexed.Remove(d.To));
|
||||
|
||||
UpdateTracker.NextStep("Updating Modlist");
|
||||
Utils.Log($"Optimized {ModList.Directives.Count} directives to {indexed.Count} required");
|
||||
var requiredArchives = indexed.Values.OfType<FromArchive>()
|
||||
.GroupBy(d => d.ArchiveHashPath[0])
|
||||
|
@ -72,7 +72,7 @@ namespace Wabbajack.Lib
|
||||
|
||||
protected override bool _Begin()
|
||||
{
|
||||
ConfigureProcessor(10);
|
||||
ConfigureProcessor(16);
|
||||
UpdateTracker.Reset();
|
||||
UpdateTracker.NextStep("Gathering information");
|
||||
Info("Looking for other profiles");
|
||||
@ -161,7 +161,8 @@ namespace Wabbajack.Lib
|
||||
|
||||
Info($"Found {AllFiles.Count} files to build into mod list");
|
||||
|
||||
Info("Verifying destinations");
|
||||
UpdateTracker.NextStep("Verifying destinations");
|
||||
|
||||
var dups = AllFiles.GroupBy(f => f.Path)
|
||||
.Where(fs => fs.Count() > 1)
|
||||
.Select(fs =>
|
||||
@ -177,6 +178,9 @@ namespace Wabbajack.Lib
|
||||
|
||||
ExtraFiles = new ConcurrentBag<Directive>();
|
||||
|
||||
|
||||
UpdateTracker.NextStep("Loading INIs");
|
||||
|
||||
ModInis = Directory.EnumerateDirectories(Path.Combine(MO2Folder, "mods"))
|
||||
.Select(f =>
|
||||
{
|
||||
@ -191,12 +195,12 @@ namespace Wabbajack.Lib
|
||||
|
||||
var stack = MakeStack();
|
||||
|
||||
|
||||
UpdateTracker.NextStep("Running Compilation Stack");
|
||||
var results = AllFiles.PMap(Queue, UpdateTracker, f => RunStack(stack, f)).ToList();
|
||||
|
||||
// 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();
|
||||
|
||||
var nomatch = results.OfType<NoMatch>();
|
||||
@ -227,10 +231,15 @@ namespace Wabbajack.Lib
|
||||
|
||||
}
|
||||
|
||||
UpdateTracker.NextStep("Verifying Files");
|
||||
zEditIntegration.VerifyMerges(this);
|
||||
|
||||
|
||||
UpdateTracker.NextStep("Gathering Archives");
|
||||
GatherArchives();
|
||||
UpdateTracker.NextStep("Including Archive Metadata");
|
||||
IncludeArchiveMetadata();
|
||||
UpdateTracker.NextStep("Building Patches");
|
||||
BuildPatches();
|
||||
|
||||
ModList = new ModList
|
||||
@ -248,16 +257,22 @@ namespace Wabbajack.Lib
|
||||
Website = ModListWebsite ?? ""
|
||||
};
|
||||
|
||||
UpdateTracker.NextStep("Running Validation");
|
||||
|
||||
ValidateModlist.RunValidation(ModList);
|
||||
UpdateTracker.NextStep("Generating Report");
|
||||
|
||||
GenerateReport();
|
||||
|
||||
UpdateTracker.NextStep("Exporting Modlist");
|
||||
ExportModList();
|
||||
|
||||
ResetMembers();
|
||||
|
||||
ShowReport();
|
||||
|
||||
Info("Done Building Modlist");
|
||||
UpdateTracker.NextStep("Done Building Modlist");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -30,8 +30,7 @@ namespace Wabbajack.Lib
|
||||
|
||||
protected override bool _Begin()
|
||||
{
|
||||
ConfigureProcessor(RecommendQueueSize());
|
||||
ValidateFreeSpace();
|
||||
ConfigureProcessor(17, RecommendQueueSize());
|
||||
var game = GameRegistry.Games[ModList.GameType];
|
||||
|
||||
if (GameFolder == null)
|
||||
@ -47,7 +46,10 @@ namespace Wabbajack.Lib
|
||||
return false;
|
||||
}
|
||||
|
||||
UpdateTracker.NextStep("Validating Game ESMs");
|
||||
ValidateGameESMs();
|
||||
|
||||
UpdateTracker.NextStep("Validating Modlist");
|
||||
ValidateModlist.RunValidation(ModList);
|
||||
|
||||
Directory.CreateDirectory(OutputFolder);
|
||||
@ -67,10 +69,16 @@ namespace Wabbajack.Lib
|
||||
}
|
||||
}
|
||||
|
||||
UpdateTracker.NextStep("Optimizing Modlist");
|
||||
OptimizeModlist();
|
||||
|
||||
UpdateTracker.NextStep("Hashing Archives");
|
||||
HashArchives();
|
||||
|
||||
UpdateTracker.NextStep("Downloading Missing Archives");
|
||||
DownloadArchives();
|
||||
|
||||
UpdateTracker.NextStep("Hashing Remaining Archives");
|
||||
HashArchives();
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
UpdateTracker.NextStep("Priming VFS");
|
||||
PrimeVFS();
|
||||
|
||||
UpdateTracker.NextStep("Building Folder Structure");
|
||||
BuildFolderStructure();
|
||||
|
||||
UpdateTracker.NextStep("Installing Archives");
|
||||
InstallArchives();
|
||||
|
||||
UpdateTracker.NextStep("Installing Included files");
|
||||
InstallIncludedFiles();
|
||||
|
||||
UpdateTracker.NextStep("Installing Archive Metas");
|
||||
InstallIncludedDownloadMetas();
|
||||
|
||||
UpdateTracker.NextStep("Building BSAs");
|
||||
BuildBSAs();
|
||||
|
||||
UpdateTracker.NextStep("Generating Merges");
|
||||
zEditIntegration.GenerateMerges(this);
|
||||
|
||||
Info("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();
|
||||
UpdateTracker.NextStep("Installation complete! You may exit the program.");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -93,8 +93,20 @@ namespace Wabbajack.VirtualFileSystem
|
||||
|
||||
public bool IsNative => Parent == null;
|
||||
|
||||
public IEnumerable<VirtualFile> ThisAndAllChildren =>
|
||||
Children.SelectMany(child => child.ThisAndAllChildren).Append(this);
|
||||
private IEnumerable<VirtualFile> _thisAndAllChildren = null;
|
||||
|
||||
public IEnumerable<VirtualFile> ThisAndAllChildren
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_thisAndAllChildren == null)
|
||||
{
|
||||
_thisAndAllChildren = Children.SelectMany(child => child.ThisAndAllChildren).Append(this).ToList();
|
||||
}
|
||||
|
||||
return _thisAndAllChildren;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
@ -267,4 +279,4 @@ namespace Wabbajack.VirtualFileSystem
|
||||
_fullPath = fullPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user