mirror of
https://github.com/4sval/FModel.git
synced 2026-08-07 11:36:03 -05:00
Merge 1cbec07803 into 7c86ee47ec
This commit is contained in:
commit
d377374ca9
|
|
@ -211,7 +211,7 @@ public class AssetsFolderViewModel
|
|||
|
||||
public void BulkPopulate(IReadOnlyCollection<GameFile> entries)
|
||||
{
|
||||
if (entries == null || entries.Count == 0)
|
||||
if (entries == null)
|
||||
return;
|
||||
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
|||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using CUE4Parse.FileProvider.Objects;
|
||||
using CUE4Parse.UE4.VirtualFileSystem;
|
||||
using FModel.Framework;
|
||||
using FModel.Services;
|
||||
using FModel.Settings;
|
||||
|
|
@ -21,6 +22,7 @@ namespace FModel.ViewModels;
|
|||
public class BackupManagerViewModel : ViewModel
|
||||
{
|
||||
public const uint FBKP_MAGIC = 0x504B4246;
|
||||
public const string FBKP_NONVFS = "nonvfs";
|
||||
|
||||
private ThreadWorkerViewModel _threadWorkerView => ApplicationService.ThreadWorkerView;
|
||||
private ApiEndpointViewModel _apiEndpointView => ApplicationService.ApiEndpointView;
|
||||
|
|
@ -81,6 +83,11 @@ public class BackupManagerViewModel : ViewModel
|
|||
writer.Write(asset.Size);
|
||||
writer.Write(asset.IsEncrypted);
|
||||
writer.Write(asset.Path);
|
||||
|
||||
if (asset is VfsEntry vfsAsset)
|
||||
writer.Write(vfsAsset.Vfs.Name);
|
||||
else
|
||||
writer.Write(FBKP_NONVFS);
|
||||
}
|
||||
|
||||
SaveCheck(fullPath, fileName, "created", "create");
|
||||
|
|
@ -122,6 +129,7 @@ public enum EBackupVersion : byte
|
|||
BeforeVersionWasAdded = 0,
|
||||
Initial,
|
||||
PerfectPath, // no more leading slash and ToLower
|
||||
Vfs, // added vfs name
|
||||
|
||||
LatestPlusOne,
|
||||
Latest = LatestPlusOne - 1
|
||||
|
|
|
|||
|
|
@ -229,8 +229,14 @@ public class LoadCommand : ViewModelCommand<LoadingModesViewModel>
|
|||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
archive.Position += sizeof(long) + sizeof(byte);
|
||||
var fullPath = archive.ReadString();
|
||||
var fullPath = archive.ReadFUtf8String(archive.Read7BitEncodedInt());
|
||||
if (version < EBackupVersion.PerfectPath) fullPath = fullPath[1..];
|
||||
if (version >= EBackupVersion.Vfs)
|
||||
{
|
||||
//readint advances Position, directly doing += overrides it
|
||||
var length = archive.Read7BitEncodedInt();
|
||||
archive.Position += length;
|
||||
}
|
||||
|
||||
paths.Add(fullPath);
|
||||
}
|
||||
|
|
@ -276,10 +282,11 @@ public class LoadCommand : ViewModelCommand<LoadingModesViewModel>
|
|||
|
||||
var uncompressedSize = archive.Read<long>();
|
||||
var isEncrypted = archive.ReadFlag();
|
||||
var fullPath = archive.ReadString();
|
||||
var fullPath = archive.ReadFUtf8String(archive.Read7BitEncodedInt());
|
||||
if (version < EBackupVersion.PerfectPath) fullPath = fullPath[1..];
|
||||
var vfsName = version >= EBackupVersion.Vfs ? archive.ReadString() : null;
|
||||
|
||||
AddEntry(fullPath, uncompressedSize, isEncrypted, entries);
|
||||
AddEntry(fullPath, uncompressedSize, isEncrypted, entries, vfsName);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -289,10 +296,15 @@ public class LoadCommand : ViewModelCommand<LoadingModesViewModel>
|
|||
return entries;
|
||||
}
|
||||
|
||||
private void AddEntry(string path, long uncompressedSize, bool isEncrypted, List<GameFile> entries)
|
||||
private void AddEntry(string path, long uncompressedSize, bool isEncrypted, List<GameFile> entries, string vfsName = null)
|
||||
{
|
||||
if (!_applicationView.CUE4Parse.Provider.Files.TryGetValue(path, out var asset) ||
|
||||
asset.IsUePackagePayload || asset.Size == uncompressedSize && asset.IsEncrypted == isEncrypted)
|
||||
if (!_applicationView.CUE4Parse.Provider.Files.TryGetValues(path, out var assets))
|
||||
return;
|
||||
|
||||
GameFile asset = vfsName is null || vfsName == BackupManagerViewModel.FBKP_NONVFS ?
|
||||
assets[0] : assets.Find(x => (x as VfsEntry).Vfs.Name == vfsName);
|
||||
|
||||
if (asset is null || asset.IsUePackagePayload || asset.Size == uncompressedSize && asset.IsEncrypted == isEncrypted)
|
||||
return;
|
||||
|
||||
entries.Add(asset);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user