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