From 1e905ae7c2b8cb03a6ab594f03085bc447f56f82 Mon Sep 17 00:00:00 2001 From: iAmAsval Date: Sun, 30 Aug 2020 23:32:09 +0200 Subject: [PATCH] added /Plugins/GameFeatures/ icon detection support --- FModel/Creator/Creator.cs | 1 + FModel/PakReader/Pak/PakFileReader.cs | 6 ++---- FModel/PakReader/Pak/PakPackage.cs | 11 +++++++++++ FModel/PakReader/Parsers/Class/UTexture2D.cs | 16 ++++++++++++---- FModel/Utils/Assets.cs | 1 - FModel/Utils/Strings.cs | 18 ++++++++++++++++-- README.md | 3 +-- 7 files changed, 43 insertions(+), 13 deletions(-) diff --git a/FModel/Creator/Creator.cs b/FModel/Creator/Creator.cs index c13600e8..82b90eda 100644 --- a/FModel/Creator/Creator.cs +++ b/FModel/Creator/Creator.cs @@ -82,6 +82,7 @@ namespace FModel.Creator case "FortHomebaseNodeItemDefinition": case "FortWeaponRangedItemDefinition": case "FortNeverPersistItemDefinition": + case "RadioContentSourceItemDefinition": case "FortPlaysetGrenadeItemDefinition": case "FortPersonalVehicleItemDefinition": case "FortHardcoreModifierItemDefinition": diff --git a/FModel/PakReader/Pak/PakFileReader.cs b/FModel/PakReader/Pak/PakFileReader.cs index ef49c62d..d93a5d7a 100644 --- a/FModel/PakReader/Pak/PakFileReader.cs +++ b/FModel/PakReader/Pak/PakFileReader.cs @@ -65,7 +65,7 @@ namespace PakReader.Pak } public bool TestAesKey(byte[] bytes, byte[] key) { - BinaryReader IndexReader = new BinaryReader(new MemoryStream(AESDecryptor.DecryptAES(bytes, key))); + using BinaryReader IndexReader = new BinaryReader(new MemoryStream(AESDecryptor.DecryptAES(bytes, key))); int stringLen = IndexReader.ReadInt32(); if (stringLen > 128 || stringLen < -128) { @@ -190,9 +190,7 @@ namespace PakReader.Pak } } - Paks.Merge(tempFiles, out var files, MountPoint); - Entries = files; - + Paks.Merge(tempFiles, out Entries, MountPoint); DebugHelper.WriteLine("{0} {1} {2} {3}", "[FModel]", "[PakFileReader]", "[ReadIndexInternal]", $"{FileName} contains {Entries.Count} files, mount point: \"{this.MountPoint}\", version: {(int)this.Info.Version}"); if (Info.bEncryptedIndex) diff --git a/FModel/PakReader/Pak/PakPackage.cs b/FModel/PakReader/Pak/PakPackage.cs index a4bdf625..c5731ddc 100644 --- a/FModel/PakReader/Pak/PakPackage.cs +++ b/FModel/PakReader/Pak/PakPackage.cs @@ -114,6 +114,17 @@ namespace PakReader.Pak } return default; } + public T GetTypedExport(string exportType) where T : IUExport + { + int index = 0; + var exportTypes = ExportTypes; + for (int i = 0; i < exportTypes.Length; i++) + { + if (exportTypes[i].String == exportType) + index = i; + } + return (T)Exports[index]; + } public bool HasExport() => exports != null; diff --git a/FModel/PakReader/Parsers/Class/UTexture2D.cs b/FModel/PakReader/Parsers/Class/UTexture2D.cs index 2409d40b..f7862d4d 100644 --- a/FModel/PakReader/Parsers/Class/UTexture2D.cs +++ b/FModel/PakReader/Parsers/Class/UTexture2D.cs @@ -23,10 +23,18 @@ namespace PakReader.Parsers.Class List data = new List(); if (PlatformDatas[0].Mips.Length > 0) { - sizeX = PlatformDatas[0].Mips[0].SizeX; - sizeY = PlatformDatas[0].Mips[0].SizeY; - sizeZ = PlatformDatas[0].Mips[0].SizeZ; - data.AddRange(PlatformDatas[0].Mips[0].BulkData.Data); + int i = 0; + byte[] d = PlatformDatas[0].Mips[i].BulkData.Data; + while (d == null) + { + i++; + d = PlatformDatas[0].Mips[i].BulkData.Data; + } + + sizeX = PlatformDatas[0].Mips[i].SizeX; + sizeY = PlatformDatas[0].Mips[i].SizeY; + sizeZ = PlatformDatas[0].Mips[i].SizeZ; + data.AddRange(d); } //if (PlatformDatas[0].bIsVirtual) diff --git a/FModel/Utils/Assets.cs b/FModel/Utils/Assets.cs index 2ec179d0..59f50fb5 100644 --- a/FModel/Utils/Assets.cs +++ b/FModel/Utils/Assets.cs @@ -23,7 +23,6 @@ using System.Threading; using SkiaSharp; using System.Text; using FModel.ViewModels.DataGrid; -using FModel.PakReader; using ICSharpCode.AvalonEdit.Highlighting; using static FModel.Creator.Creator; diff --git a/FModel/Utils/Strings.cs b/FModel/Utils/Strings.cs index a47777d6..0bb0a0da 100644 --- a/FModel/Utils/Strings.cs +++ b/FModel/Utils/Strings.cs @@ -21,8 +21,22 @@ namespace FModel.Utils if (string.IsNullOrWhiteSpace(path)) return string.Empty; - Regex regexGame = new Regex(Regex.Escape("Game")); - string fixedPath = regexGame.Replace(path, $"{Folders.GetGameName()}/Content", 1); + string trigger; + { + string tempPath = path.Substring(1); + trigger = tempPath.Substring(0, tempPath.IndexOf("/")); + + if (trigger.Equals("SrirachaRanch")) + trigger = $"{trigger}/{trigger}Core"; + } + + Regex regex = new Regex(Regex.Escape(trigger)); + string fixedPath = trigger switch + { + "Game" => regex.Replace(path, $"{Folders.GetGameName()}/Content", 1), + _ => regex.Replace(path, $"{Folders.GetGameName()}/Plugins/GameFeatures/{trigger}/Content", 1) + }; + int sep = fixedPath.LastIndexOf('.'); return fixedPath.Substring(0, sep > 0 ? sep : fixedPath.Length); } diff --git a/README.md b/README.md index ab059355..76fbb119 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,6 @@ Created in March 2019, FModel is a .PAK file explorer fully dedicated to Fortnite but also work with some other Unreal Engine's games. It quickly became popular to quickly generate images of new cosmetics added to the game. Over time, new features got added and new users discovered the program. -Friendly reminder, using FModel for Fortnite doesn't make you a leaker so please don't call yourself a leaker. - ## Table of Contents - [Introduction](#introduction) @@ -145,6 +143,7 @@ To use FModel, you need to have [.NET Core 3.1](https://dotnet.microsoft.com/dow This software uses the following open source packages: +- [ASTCDecoder](https://github.com/Ryujinx/Ryujinx/tree/master/Ryujinx.Graphics.Texture/Astc) - [Audion.CSCore](https://github.com/tjscience/audion.cscore) - [Autoupdater.NET.Official](https://github.com/ravibpatel/AutoUpdater.NET) - [AvalonEdit](https://github.com/icsharpcode/AvalonEdit)