mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
added an overall progress bar
This commit is contained in:
parent
81a51265b0
commit
873bb47e35
@ -8,6 +8,7 @@ using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Wabbajack.Common
|
||||
@ -163,6 +164,10 @@ namespace Wabbajack.Common
|
||||
|
||||
public static List<TR> PMap<TI, TR>(this IEnumerable<TI> coll, Func<TI, TR> f)
|
||||
{
|
||||
var colllst = coll.ToList();
|
||||
WorkQueue.MaxQueueSize = colllst.Count;
|
||||
WorkQueue.CurrentQueueSize = 0;
|
||||
|
||||
var tasks = coll.Select(i =>
|
||||
{
|
||||
TaskCompletionSource<TR> tc = new TaskCompletionSource<TR>();
|
||||
@ -176,6 +181,8 @@ namespace Wabbajack.Common
|
||||
{
|
||||
tc.SetException(ex);
|
||||
}
|
||||
Interlocked.Increment(ref WorkQueue.CurrentQueueSize);
|
||||
WorkQueue.ReportNow();
|
||||
});
|
||||
return tc.Task;
|
||||
}).ToList();
|
||||
|
@ -15,9 +15,10 @@ namespace Wabbajack.Common
|
||||
[ThreadStatic]
|
||||
private static int CpuId;
|
||||
|
||||
public static void Init(Action<int, string, int> report_function)
|
||||
public static void Init(Action<int, string, int> report_function, Action<int, int> report_queue_size)
|
||||
{
|
||||
ReportFunction = report_function;
|
||||
ReportQueueSize = report_queue_size;
|
||||
ThreadCount = Environment.ProcessorCount;
|
||||
StartThreads();
|
||||
}
|
||||
@ -59,7 +60,15 @@ namespace Wabbajack.Common
|
||||
}
|
||||
|
||||
public static Action<int, string, int> ReportFunction { get; private set; }
|
||||
public static Action<int, int> ReportQueueSize { get; private set; }
|
||||
public static int ThreadCount { get; private set; }
|
||||
public static List<Thread> Threads { get; private set; }
|
||||
public static int MaxQueueSize;
|
||||
public static int CurrentQueueSize;
|
||||
|
||||
internal static void ReportNow()
|
||||
{
|
||||
ReportQueueSize(MaxQueueSize, CurrentQueueSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -81,6 +81,23 @@ namespace Wabbajack
|
||||
}
|
||||
}
|
||||
|
||||
private int _queueProgress;
|
||||
public int QueueProgress
|
||||
{
|
||||
get
|
||||
{
|
||||
return _queueProgress;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != _queueProgress)
|
||||
{
|
||||
_queueProgress = value;
|
||||
OnPropertyChanged("QueueProgress");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private List<CPUStatus> InternalStatus { get; }
|
||||
public string LogFile { get; private set; }
|
||||
@ -162,6 +179,12 @@ namespace Wabbajack
|
||||
}
|
||||
}
|
||||
|
||||
public void SetQueueSize(int max, int current)
|
||||
{
|
||||
var total = current * 100 / max;
|
||||
QueueProgress = total;
|
||||
}
|
||||
|
||||
private ICommand _changePath;
|
||||
public ICommand ChangePath
|
||||
{
|
||||
|
@ -159,6 +159,7 @@ namespace Wabbajack
|
||||
.Where(p => p.FileExists())
|
||||
.Select(p => new RawSourceFile() { Path = Path.Combine(Consts.GameFolderFilesDir, p.RelativeTo(GamePath)), AbsolutePath = p });
|
||||
|
||||
Info("Searching for mod files");
|
||||
AllFiles = mo2_files.Concat(game_files).ToList();
|
||||
|
||||
Info("Found {0} files to build into mod list", AllFiles.Count);
|
||||
@ -192,7 +193,8 @@ namespace Wabbajack
|
||||
ModList = new ModList()
|
||||
{
|
||||
Archives = SelectedArchives,
|
||||
Directives = InstallDirectives
|
||||
Directives = InstallDirectives,
|
||||
Name = MO2Profile
|
||||
};
|
||||
|
||||
PatchExecutable();
|
||||
|
@ -12,6 +12,7 @@
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
<RowDefinition></RowDefinition>
|
||||
<RowDefinition Height="10"></RowDefinition>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
<RowDefinition></RowDefinition>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
@ -62,9 +63,10 @@
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
<TextBlock Text="Log:" Grid.Row="3" FontSize="14" Margin="0, 16, 0, 8"></TextBlock>
|
||||
<ListBox local:AutoScrollBehavior.ScrollOnNewItem="True" Grid.Row ="4" ItemsSource="{Binding Log}">
|
||||
<ProgressBar Grid.Row="3" Value="{Binding QueueProgress}" Minimum="0" Maximum="100" Background="#444444"></ProgressBar>
|
||||
<TextBlock Text="Log:" Grid.Row="4" FontSize="14" Margin="0, 16, 0, 8"></TextBlock>
|
||||
<ListBox local:AutoScrollBehavior.ScrollOnNewItem="True" Grid.Row ="5" ItemsSource="{Binding Log}">
|
||||
</ListBox>
|
||||
<Button Content="Begin" Grid.Row="5" Height="30" Command="{Binding Begin}"></Button>
|
||||
<Button Content="Begin" Grid.Row="6" Height="30" Command="{Binding Begin}"></Button>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
@ -41,7 +41,8 @@ namespace Wabbajack
|
||||
|
||||
var context = new AppState(Dispatcher, "Building");
|
||||
this.DataContext = context;
|
||||
WorkQueue.Init((id, msg, progress) => context.SetProgress(id, msg, progress));
|
||||
WorkQueue.Init((id, msg, progress) => context.SetProgress(id, msg, progress),
|
||||
(max, current) => context.SetQueueSize(max, current));
|
||||
|
||||
|
||||
if (DebugMode)
|
||||
@ -69,8 +70,6 @@ namespace Wabbajack
|
||||
new Thread(() =>
|
||||
{
|
||||
var modlist = Installer.CheckForModPack();
|
||||
context.LogMsg($"Modlist returned {modlist != null}");
|
||||
|
||||
if (modlist == null)
|
||||
{
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user