export directory

This commit is contained in:
iAmAsval
2020-06-02 23:06:34 +02:00
parent b1ff8917da
commit 343e93a88c
6 changed files with 69 additions and 3 deletions

View File

@@ -207,12 +207,17 @@
<TreeView x:Name="FModel_AssetsPathTree" SelectedItemChanged="OnSelectedPathChanged">
<TreeView.ContextMenu>
<ContextMenu>
<MenuItem x:Name="FModel_MI_Directory_Extract" Header="{x:Static properties:Resources.ExtractDirectory}" Click="FModel_MI_Directory_Extract_Click">
<MenuItem x:Name="FModel_MI_Directory_Extract" Header="{x:Static properties:Resources.Extract}" Click="FModel_MI_Directory_Extract_Click">
<MenuItem.Icon>
<Image Source="Resources/share-all.png"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem x:Name="FModel_MI_Directory_Save" Header="{x:Static properties:Resources.SaveDirectory}" Click="FModel_MI_Directory_Save_Click">
<MenuItem x:Name="FModel_MI_Directory_Export" Header="{x:Static properties:Resources.Export}" Click="FModel_MI_Directory_Export_Click">
<MenuItem.Icon>
<Image Source="Resources/file-export.png"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem x:Name="FModel_MI_Directory_Save" Header="{x:Static properties:Resources.Save}" Click="FModel_MI_Directory_Save_Click">
<MenuItem.Icon>
<Image Source="Resources/sign-direction-plus.png"/>
</MenuItem.Icon>

View File

@@ -389,6 +389,11 @@ namespace FModel
if (FModel_AssetsPathTree.HasItems && FModel_AssetsPathTree.SelectedItem is TreeviewViewModel treeItem)
await SortedTreeviewVm.ExtractFolder(treeItem).ConfigureAwait(false);
}
private async void FModel_MI_Directory_Export_Click(object sender, RoutedEventArgs e)
{
if (FModel_AssetsPathTree.HasItems && FModel_AssetsPathTree.SelectedItem is TreeviewViewModel treeItem)
await SortedTreeviewVm.ExportFolder(treeItem).ConfigureAwait(false);
}
private void FModel_MI_Directory_Save_Click(object sender, RoutedEventArgs e)
{
if (FModel_AssetsPathTree.HasItems && FModel_AssetsPathTree.SelectedItem is TreeviewViewModel treeItem)

View File

@@ -955,6 +955,15 @@ namespace FModel.Properties {
}
}
/// <summary>
/// Recherche une chaîne localisée semblable à Export Directory.
/// </summary>
public static string ExportDirectory {
get {
return ResourceManager.GetString("ExportDirectory", resourceCulture);
}
}
/// <summary>
/// Recherche une chaîne localisée semblable à Extract.
/// </summary>

View File

@@ -1103,4 +1103,7 @@ It's now the most used free software to leak on Fortnite.</value>
<data name="EIconDesign_NoBackground" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\EIconDesign_NoBackground.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="ExportDirectory" xml:space="preserve">
<value>Export Directory</value>
</data>
</root>

View File

@@ -213,7 +213,7 @@ namespace FModel.ViewModels.MenuItem
{
DiscordIntegration.Update(
$"{Globals.CachedPakFiles.Count}/{MenuItems.pakFiles.GetPakCount()} {Properties.Resources.PakFiles}",
string.Format("{0} - {1}", Globals.Game,
string.Format("{0} - {1}", Globals.Game.ActualGame,
mode == EPakLoader.All ? Properties.Resources.AllFiles :
mode == EPakLoader.New ? Properties.Resources.NewFiles :
mode == EPakLoader.Modified ? Properties.Resources.ModifiedFiles :

View File

@@ -1,13 +1,17 @@
using FModel.Utils;
using FModel.ViewModels.Buttons;
using FModel.ViewModels.DataGrid;
using FModel.ViewModels.ListBox;
using FModel.ViewModels.StatusBar;
using PakReader.Pak;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Data;
@@ -88,6 +92,46 @@ namespace FModel.ViewModels.Treeview
if (entriesToExtract.Any())
await Assets.GetUserSelection(entriesToExtract);
}
public static async Task ExportFolder(TreeviewViewModel treeItem)
{
string fullPath = treeItem.GetFullPath().Substring(1);
Stopwatch timer = Stopwatch.StartNew();
ExtractStopVm.stopViewModel.IsEnabled = true;
ExtractStopVm.extractViewModel.IsEnabled = false;
StatusBarVm.statusBarViewModel.Set(string.Empty, Properties.Resources.Loading);
Tasks.TokenSource = new CancellationTokenSource();
await Task.Run(() =>
{
foreach (var entry in DataGridVm.dataGridViewModel) // current loaded pak files
{
if (Tasks.TokenSource.IsCancellationRequested)
throw new TaskCanceledException(Properties.Resources.Canceled);
var m = Regex.Match(entry.Name, $"{fullPath}/*", RegexOptions.IgnoreCase);
if (m.Success)
{
if (Globals.CachedPakFiles.TryGetValue(entry.PakFile, out PakFileReader pak))
{
if (pak.TryGetValue("/" + entry.Name.Substring(0, entry.Name.LastIndexOf(".")), out var pakEntry)) // remove the extension to get the entry
{
Assets.Export(pakEntry, true);
}
}
}
}
}).ContinueWith(t =>
{
timer.Stop();
ExtractStopVm.stopViewModel.IsEnabled = false;
ExtractStopVm.extractViewModel.IsEnabled = true;
if (t.Exception != null) Tasks.TaskCompleted(t.Exception);
else StatusBarVm.statusBarViewModel.Set(string.Format(Properties.Resources.TimeElapsed, timer.ElapsedMilliseconds), Properties.Resources.Success);
},
TaskScheduler.FromCurrentSynchronizationContext());
}
}
public class SortedTreeviewViewModel : PropertyChangedBase