mirror of
https://github.com/sp-tarkov/assembly-tool.git
synced 2025-02-12 20:30:43 -05:00
Add threading to publicizer
This commit is contained in:
parent
533ab39f30
commit
dca2d61edb
@ -9,16 +9,25 @@ internal static class SPTPublicizer
|
||||
{
|
||||
var types = definition.GetTypes();
|
||||
|
||||
var typeCount = types.Where(t => !t.IsNested).Count();
|
||||
var count = 0;
|
||||
var publicizeTasks = new List<Task>();
|
||||
foreach (var type in types)
|
||||
{
|
||||
if (type.IsNested) continue; // Nested types are handled when publicizing the parent type
|
||||
|
||||
PublicizeType(type, isLauncher);
|
||||
Logger.DrawProgressBar(count, typeCount - 1, 50);
|
||||
count++;
|
||||
publicizeTasks.Add(
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
PublicizeType(type, isLauncher);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
while (!publicizeTasks.TrueForAll(t => t.Status == TaskStatus.RanToCompletion))
|
||||
{
|
||||
Logger.DrawProgressBar(publicizeTasks.Where(t => t.IsCompleted)!.Count() + 1, publicizeTasks.Count, 50);
|
||||
}
|
||||
|
||||
Task.WaitAll(publicizeTasks.ToArray());
|
||||
}
|
||||
|
||||
private static void PublicizeType(TypeDef type, bool isLauncher)
|
||||
|
@ -75,6 +75,7 @@ public class ReMapper
|
||||
}
|
||||
|
||||
RenameMatches(types);
|
||||
|
||||
Publicize();
|
||||
|
||||
// We are done, write the assembly
|
||||
@ -100,7 +101,7 @@ public class ReMapper
|
||||
{
|
||||
while (!tasks.TrueForAll(t => t.Status == TaskStatus.RanToCompletion))
|
||||
{
|
||||
Logger.DrawProgressBar(tasks.Where(t => t.IsCompleted)!.Count(), tasks.Count, 50);
|
||||
Logger.DrawProgressBar(tasks.Where(t => t.IsCompleted)!.Count() + 1, tasks.Count, 50);
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,7 +125,7 @@ public class ReMapper
|
||||
|
||||
while (!renameTasks.TrueForAll(t => t.Status == TaskStatus.RanToCompletion))
|
||||
{
|
||||
Logger.DrawProgressBar(renameTasks.Where(t => t.IsCompleted)!.Count(), renameTasks.Count, 50);
|
||||
Logger.DrawProgressBar(renameTasks.Where(t => t.IsCompleted)!.Count() + 1, renameTasks.Count, 50);
|
||||
}
|
||||
|
||||
Task.WaitAll(renameTasks.ToArray());
|
||||
|
@ -89,8 +89,8 @@ public static class Logger
|
||||
Console.CursorVisible = false;
|
||||
Console.SetCursorPosition(0, Console.CursorTop);
|
||||
|
||||
double percentage = (double)progress / total;
|
||||
int completed = (int)(percentage * width);
|
||||
var percentage = (double)progress / total;
|
||||
var completed = (int)(percentage * width);
|
||||
|
||||
Console.Write("[");
|
||||
Console.Write(new string('=', completed)); // Completed part
|
||||
|
Loading…
x
Reference in New Issue
Block a user