diff --git a/FModel/FModel.csproj b/FModel/FModel.csproj index 02b2ac90..8247097a 100644 --- a/FModel/FModel.csproj +++ b/FModel/FModel.csproj @@ -595,6 +595,12 @@ + + + + + + diff --git a/FModel/Forms/FModel_Settings.xaml b/FModel/Forms/FModel_Settings.xaml index ec7118a6..63e31c91 100644 --- a/FModel/Forms/FModel_Settings.xaml +++ b/FModel/Forms/FModel_Settings.xaml @@ -56,6 +56,7 @@ + diff --git a/FModel/Forms/FModel_Settings.xaml.cs b/FModel/Forms/FModel_Settings.xaml.cs index 576b7945..91b5f729 100644 --- a/FModel/Forms/FModel_Settings.xaml.cs +++ b/FModel/Forms/FModel_Settings.xaml.cs @@ -73,7 +73,9 @@ namespace FModel.Forms [Description("Flat")] Flat = 1, [Description("Minimalist")] - Minimalist = 2 + Minimalist = 2, + [Description("Accurate Colors")] + Accurate = 3 } public static T GetEnumValueFromDescription(string description) @@ -238,6 +240,9 @@ namespace FModel.Forms case "Minimalist": source = new BitmapImage(new Uri(isFeatured ? "pack://application:,,,/Resources/Template_M_F.png" : "pack://application:,,,/Resources/Template_M_N.png")); break; + case "Accurate Colors": + source = new BitmapImage(new Uri(isFeatured ? "pack://application:,,,/Resources/Template_AC_F.png" : "pack://application:,,,/Resources/Template_AC_N.png")); + break; } drawingContext.DrawImage(source, new Rect(new Point(0, 0), new Size(515, 515))); diff --git a/FModel/Forms/FModel_UpdateMode.xaml b/FModel/Forms/FModel_UpdateMode.xaml index 61d1de92..01466058 100644 --- a/FModel/Forms/FModel_UpdateMode.xaml +++ b/FModel/Forms/FModel_UpdateMode.xaml @@ -58,6 +58,7 @@ + diff --git a/FModel/Forms/FModel_UpdateMode.xaml.cs b/FModel/Forms/FModel_UpdateMode.xaml.cs index 72ff93ca..5601a214 100644 --- a/FModel/Forms/FModel_UpdateMode.xaml.cs +++ b/FModel/Forms/FModel_UpdateMode.xaml.cs @@ -108,7 +108,9 @@ namespace FModel.Forms [Description("Flat")] Flat = 1, [Description("Minimalist")] - Minimalist = 2 + Minimalist = 2, + [Description("Accurate Colors")] + Accurate = 3 } public static T GetEnumValueFromDescription(string description) @@ -199,6 +201,9 @@ namespace FModel.Forms case "Minimalist": source = new BitmapImage(new Uri(isFeatured ? "pack://application:,,,/Resources/Template_M_F.png" : "pack://application:,,,/Resources/Template_M_N.png")); break; + case "Accurate Colors": + source = new BitmapImage(new Uri(isFeatured ? "pack://application:,,,/Resources/Template_AC_F.png" : "pack://application:,,,/Resources/Template_AC_N.png")); + break; } drawingContext.DrawImage(source, new Rect(new Point(0, 0), new Size(515, 515))); diff --git a/FModel/Methods/Assets/IconCreator/IconImage.cs b/FModel/Methods/Assets/IconCreator/IconImage.cs index 58ec3080..e41bca41 100644 --- a/FModel/Methods/Assets/IconCreator/IconImage.cs +++ b/FModel/Methods/Assets/IconCreator/IconImage.cs @@ -1,9 +1,6 @@ using FModel.Methods.Utilities; -using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using PakReader; using System; -using System.Collections.Generic; using System.IO; using System.Linq; using System.Windows; diff --git a/FModel/Methods/Assets/IconCreator/IconText.cs b/FModel/Methods/Assets/IconCreator/IconText.cs index f30c3c5b..3b61e8fa 100644 --- a/FModel/Methods/Assets/IconCreator/IconText.cs +++ b/FModel/Methods/Assets/IconCreator/IconText.cs @@ -313,6 +313,7 @@ namespace FModel.Methods.Assets.IconCreator break; case "Default": case "Minimalist": + case "Accurate Colors": IconCreator.ICDrawingContext.DrawRectangle(new SolidColorBrush(Color.FromArgb(70, 0, 0, 50)), null, new Rect(3, 380, 509, 132)); break; default: diff --git a/FModel/Methods/Assets/IconCreator/Rarity.cs b/FModel/Methods/Assets/IconCreator/Rarity.cs index 72e2594e..8bc31674 100644 --- a/FModel/Methods/Assets/IconCreator/Rarity.cs +++ b/FModel/Methods/Assets/IconCreator/Rarity.cs @@ -1,9 +1,6 @@ using FModel.Methods.Utilities; -using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using PakReader; using System; -using System.Collections.Generic; using System.IO; using System.Linq; using System.Windows; @@ -13,6 +10,18 @@ using FProp = FModel.Properties.Settings; namespace FModel.Methods.Assets.IconCreator { + public enum RarityCollectionIndexes + { + Common = 0, + Uncommon = 1, + Rare = 2, + Epic = 3, + Legendary = 4, + Mythic = 5, + Transcendent = 6, + Impossible_T7 = 7, + } + static class Rarity { public static void DrawRarityBackground(JArray AssetProperties) @@ -28,6 +37,10 @@ namespace FModel.Methods.Assets.IconCreator { GetSerieAsset(serieToken, rarityToken); } + else if (string.Equals(FProp.Default.FRarity_Design, "Accurate Colors")) + { + GetRarityData(rarityToken); + } else { DrawNormalRarity(rarityToken); @@ -63,6 +76,99 @@ namespace FModel.Methods.Assets.IconCreator } } + private static void GetRarityData(JToken rarityToken) + { + string jsonData = AssetsUtility.GetAssetJsonDataByPath("/FortniteGame/Content/Balance/RarityData"); + if (jsonData != null) + { + if (AssetsUtility.IsValidJson(jsonData)) + { + JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData); + if (AssetMainToken != null) + { + JArray propertiesArray = AssetMainToken["properties"].Value(); + if (propertiesArray != null) + { + RarityCollectionIndexes rColor = RarityCollectionIndexes.Uncommon; + switch (rarityToken != null ? rarityToken.Value() : string.Empty) + { + /*case "EFortRarity::Legendary": OLD IMPOSSIBLE (T9) but its EFortRarity doesn't exist anymore and T9 is now T7 + rColor = RarityCollectionIndexes.Impossible_T7; + break;*/ + case "EFortRarity::Transcendent": + rColor = RarityCollectionIndexes.Transcendent; + break; + case "EFortRarity::Mythic": + rColor = RarityCollectionIndexes.Mythic; + break; + case "EFortRarity::Legendary": + rColor = RarityCollectionIndexes.Legendary; + break; + case "EFortRarity::Epic": + case "EFortRarity::Quality": + rColor = RarityCollectionIndexes.Epic; + break; + case "EFortRarity::Rare": + rColor = RarityCollectionIndexes.Rare; + break; + case "EFortRarity::Common": + rColor = RarityCollectionIndexes.Common; + break; + } + + JArray rarityCollectionArray = propertiesArray[(int)rColor]["tag_data"]["struct_type"]["properties"].Value(); + if (rarityCollectionArray != null) + { + DrawWithInGameColors(rarityCollectionArray, true); + } + } + } + } + } + else + DebugHelper.WriteLine("Rarity: This is kinda important because /FortniteGame/Content/Balance/RarityData.uasset couldn't be find"); + } + + private static void GetSerieAsset(JToken serieToken, JToken rarityToken) + { + //this will catch the full path if asset exists to be able to grab his PakReader and List + string seriesFullPath = AssetEntries.AssetEntriesDict.Where(x => x.Key.ToLowerInvariant().Contains("/" + serieToken.Value().ToLowerInvariant() + ".uasset")).Select(d => d.Key).FirstOrDefault(); + if (!string.IsNullOrEmpty(seriesFullPath)) + { + string jsonData = AssetsUtility.GetAssetJsonDataByPath(seriesFullPath.Substring(0, seriesFullPath.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase))); + if (jsonData != null) + { + if (AssetsUtility.IsValidJson(jsonData)) + { + JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData); + if (AssetMainToken != null) + { + JArray propertiesArray = AssetMainToken["properties"].Value(); + if (propertiesArray != null) + { + JArray colorsArray = AssetsUtility.GetPropertyTagStruct(propertiesArray, "Colors", "properties"); + if (colorsArray != null) + { + DrawWithInGameColors(colorsArray, + string.Equals(seriesFullPath, "/FortniteGame/Content/Athena/Items/Cosmetics/Series/MarvelSeries.uasset") ? true : false //REVERSE COLORS IF MARVEL + ); //BECAUSE IT LOOKS WEIRD + } + + JToken backgroundTextureToken = AssetsUtility.GetPropertyTagText(propertiesArray, "BackgroundTexture", "asset_path_name"); + if (backgroundTextureToken != null) + { + string imagePath = FoldersUtility.FixFortnitePath(backgroundTextureToken.Value()); + DrawSerieImage(imagePath); + } + } + } + } + } + else { DrawNormalRarity(rarityToken); } + } + else { DrawNormalRarity(rarityToken); } + } + private static void DrawBackground(Color background, Color backgroundUpDown, Color border, bool series = false) { switch (FProp.Default.FRarity_Design) @@ -105,13 +211,14 @@ namespace FModel.Methods.Assets.IconCreator //background IconCreator.ICDrawingContext.DrawRectangle(new SolidColorBrush(background), null, new Rect(3, 3, 509, 509)); - + //up & down IconCreator.ICDrawingContext.DrawGeometry(new SolidColorBrush(Color.FromArgb(125, backgroundUpDown.R, backgroundUpDown.G, backgroundUpDown.B)), null, uGeo); IconCreator.ICDrawingContext.DrawGeometry(new SolidColorBrush(Color.FromArgb(125, backgroundUpDown.R, backgroundUpDown.G, backgroundUpDown.B)), null, dGeo); break; case "Default": case "Minimalist": + case "Accurate Colors": RadialGradientBrush radialGradient = new RadialGradientBrush(); radialGradient.GradientOrigin = new Point(0.5, 0.5); radialGradient.Center = new Point(0.5, 0.5); @@ -148,64 +255,7 @@ namespace FModel.Methods.Assets.IconCreator } } - private static void GetSerieAsset(JToken serieToken, JToken rarityToken) - { - //this will catch the full path if asset exists to be able to grab his PakReader and List - string seriesFullPath = AssetEntries.AssetEntriesDict.Where(x => x.Key.ToLowerInvariant().Contains("/" + serieToken.Value().ToLowerInvariant() + ".uasset")).Select(d => d.Key).FirstOrDefault(); - if (!string.IsNullOrEmpty(seriesFullPath)) - { - string jsonData = AssetsUtility.GetAssetJsonDataByPath(seriesFullPath.Substring(0, seriesFullPath.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase))); - if (jsonData != null) - { - if (AssetsUtility.IsValidJson(jsonData)) - { - JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData); - if (AssetMainToken != null) - { - JArray propertiesArray = AssetMainToken["properties"].Value(); - if (propertiesArray != null) - { - JArray colorsArray = AssetsUtility.GetPropertyTagStruct(propertiesArray, "Colors", "properties"); - if (colorsArray != null) - { - DrawSerieBackground(colorsArray); - } - - JToken backgroundTextureToken = AssetsUtility.GetPropertyTagText(propertiesArray, "BackgroundTexture", "asset_path_name"); - if (backgroundTextureToken != null) - { - string imagePath = FoldersUtility.FixFortnitePath(backgroundTextureToken.Value()); - DrawSerieImage(imagePath); - } - } - } - } - } - else { DrawNormalRarity(rarityToken); } - } - else { DrawNormalRarity(rarityToken); } - } - - private static void DrawSerieImage(string AssetPath) - { - using (Stream image = AssetsUtility.GetStreamImageFromPath(AssetPath)) - { - if (image != null) - { - BitmapImage bmp = new BitmapImage(); - bmp.BeginInit(); - bmp.CacheOption = BitmapCacheOption.OnLoad; - bmp.StreamSource = image; - bmp.EndInit(); - bmp.Freeze(); - - IconCreator.ICDrawingContext.DrawImage(bmp, new Rect(3, 3, 509, 509)); - } - } - - } - - private static void DrawSerieBackground(JArray colorsArray) + private static void DrawWithInGameColors(JArray colorsArray, bool shouldBeReversed = false) { Color background = new Color(); Color backgroundupdown = new Color(); @@ -247,7 +297,7 @@ namespace FModel.Methods.Assets.IconCreator border = Color.FromRgb((byte)r, (byte)g, (byte)b); } - DrawBackground(background, backgroundupdown, ChangeColorBrightness(border, 0.25f), true); + DrawBackground(shouldBeReversed ? backgroundupdown : background, shouldBeReversed ? background : backgroundupdown, ChangeColorBrightness(border, 0.25f), true); } public static Color ChangeColorBrightness(Color color, float correctionFactor) @@ -272,5 +322,24 @@ namespace FModel.Methods.Assets.IconCreator return Color.FromRgb((byte)red, (byte)green, (byte)blue); } + + private static void DrawSerieImage(string AssetPath) + { + using (Stream image = AssetsUtility.GetStreamImageFromPath(AssetPath)) + { + if (image != null) + { + BitmapImage bmp = new BitmapImage(); + bmp.BeginInit(); + bmp.CacheOption = BitmapCacheOption.OnLoad; + bmp.StreamSource = image; + bmp.EndInit(); + bmp.Freeze(); + + IconCreator.ICDrawingContext.DrawImage(bmp, new Rect(3, 3, 509, 509)); + } + } + + } } } diff --git a/FModel/Methods/PAKs/RegisterFromPath.cs b/FModel/Methods/PAKs/RegisterFromPath.cs index d790a22c..514b6663 100644 --- a/FModel/Methods/PAKs/RegisterFromPath.cs +++ b/FModel/Methods/PAKs/RegisterFromPath.cs @@ -38,27 +38,18 @@ namespace FModel.Methods.PAKs { if (!PAKsUtility.IsPAKLocked(new FileInfo(Pak))) { - uint pVersion = PAKsUtility.GetPAKVersion(Pak); - if (pVersion == 8) - { - string PAKGuid = PAKsUtility.GetPAKGuid(Pak); - DebugHelper.WriteLine("Registering " + Pak + " with GUID " + PAKGuid + " (" + PAKsUtility.GetEpicGuid(PAKGuid) + ")"); + string PAKGuid = PAKsUtility.GetPAKGuid(Pak); + DebugHelper.WriteLine("Registering " + Pak + " with GUID " + PAKGuid + " (" + PAKsUtility.GetEpicGuid(PAKGuid) + ")"); - PAKEntries.PAKEntriesList.Add(new PAKInfosEntry(Pak, PAKGuid, string.Equals(PAKGuid, "0-0-0-0") ? false : true)); - FWindow.FMain.Dispatcher.InvokeAsync(() => - { - MenuItem MI_Pak = new MenuItem(); - MI_Pak.Header = Path.GetFileName(Pak); - MI_Pak.Click += new RoutedEventHandler(FWindow.FMain.MI_Pak_Click); - - FWindow.FMain.MI_LoadOnePAK.Items.Add(MI_Pak); - }); - } - else + PAKEntries.PAKEntriesList.Add(new PAKInfosEntry(Pak, PAKGuid, string.Equals(PAKGuid, "0-0-0-0") ? false : true)); + FWindow.FMain.Dispatcher.InvokeAsync(() => { - DebugHelper.WriteLine(Path.GetFileName(Pak) + " file version is " + pVersion + " instead of 8"); - new UpdateMyProcessEvents($"Unsupported .PAK Version for {Path.GetFileName(Pak)}", "Error").Update(); - } + MenuItem MI_Pak = new MenuItem(); + MI_Pak.Header = Path.GetFileName(Pak); + MI_Pak.Click += new RoutedEventHandler(FWindow.FMain.MI_Pak_Click); + + FWindow.FMain.MI_LoadOnePAK.Items.Add(MI_Pak); + }); } else { diff --git a/FModel/Methods/PakReader/PakReader.cs b/FModel/Methods/PakReader/PakReader.cs index c1b219ee..4892cf22 100644 --- a/FModel/Methods/PakReader/PakReader.cs +++ b/FModel/Methods/PakReader/PakReader.cs @@ -1,4 +1,5 @@ -using System; +using FModel.Methods.Utilities; +using System; using System.IO; namespace PakReader @@ -26,18 +27,20 @@ namespace PakReader FPakInfo info = new FPakInfo(Reader); if (info.Magic != FPakInfo.PAK_FILE_MAGIC) { + DebugHelper.WriteLine(".PAKs: The file magic is invalid"); throw new FileLoadException("The file magic is invalid"); } if (info.Version > (int)PAK_VERSION.PAK_LATEST) { - Console.Error.WriteLine($"WARNING: Pak file \"{Name}\" has unsupported version {info.Version}"); + DebugHelper.WriteLine($".PAKs: WARNING: Pak file \"{Name}\" has unsupported version {info.Version}"); } if (info.bEncryptedIndex != 0) { if (Aes == null) { + DebugHelper.WriteLine(".PAKs: The file has an encrypted index"); throw new FileLoadException("The file has an encrypted index"); } } @@ -58,6 +61,7 @@ namespace PakReader int stringLen = infoReader.ReadInt32(); if (stringLen > 512 || stringLen < -512) { + DebugHelper.WriteLine(".PAKs: The AES key is invalid"); throw new FileLoadException("The AES key is invalid"); } if (stringLen < 0) @@ -66,6 +70,7 @@ namespace PakReader ushort c = infoReader.ReadUInt16(); if (c != 0) { + DebugHelper.WriteLine(".PAKs: The AES key is invalid"); throw new FileLoadException("The AES key is invalid"); } } @@ -75,6 +80,7 @@ namespace PakReader byte c = infoReader.ReadByte(); if (c != 0) { + DebugHelper.WriteLine(".PAKs: The AES key is invalid"); throw new FileLoadException("The AES key is invalid"); } } @@ -102,7 +108,7 @@ namespace PakReader if (badMountPoint) { - Console.Error.WriteLine($"WARNING: Pak \"{Name}\" has strange mount point \"{MountPoint}\", mounting to root"); + DebugHelper.WriteLine($".PAKs: WARNING: Pak \"{Name}\" has strange mount point \"{MountPoint}\", mounting to root"); MountPoint = "/"; } @@ -144,7 +150,7 @@ namespace PakReader catch (IOException) { } catch (Exception e) { - Console.WriteLine(e); + DebugHelper.WriteException(e, "thrown in PakReader.cs by Export"); } } } diff --git a/FModel/Methods/Utilities/PAKsUtility.cs b/FModel/Methods/Utilities/PAKsUtility.cs index 5c49946f..771bf1ff 100644 --- a/FModel/Methods/Utilities/PAKsUtility.cs +++ b/FModel/Methods/Utilities/PAKsUtility.cs @@ -1,4 +1,5 @@ -using System; +using PakReader; +using System; using System.IO; using System.Linq; using System.Text; @@ -9,21 +10,15 @@ namespace FModel.Methods.Utilities { static class PAKsUtility { + private const int _SIZE = 4 * 2 + 8 * 2 + 20 + /* new fields */ 1 + 16; + public static string GetPAKGuid(string PAKPath) { using (BinaryReader reader = new BinaryReader(File.Open(PAKPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))) { - reader.BaseStream.Seek(reader.BaseStream.Length - 61 - 160, SeekOrigin.Begin); - uint g1 = reader.ReadUInt32(); - reader.BaseStream.Seek(reader.BaseStream.Length - 57 - 160, SeekOrigin.Begin); - uint g2 = reader.ReadUInt32(); - reader.BaseStream.Seek(reader.BaseStream.Length - 53 - 160, SeekOrigin.Begin); - uint g3 = reader.ReadUInt32(); - reader.BaseStream.Seek(reader.BaseStream.Length - 49 - 160, SeekOrigin.Begin); - uint g4 = reader.ReadUInt32(); - - string guid = g1 + "-" + g2 + "-" + g3 + "-" + g4; - return guid; + reader.BaseStream.Seek(-FPakInfo.Size, SeekOrigin.End); + FGuid gd = new FGuid(reader); + return gd.ToString(); } } @@ -37,17 +32,6 @@ namespace FModel.Methods.Utilities return sB.ToString(); } - public static uint GetPAKVersion(string PAKPath) - { - using (BinaryReader reader = new BinaryReader(File.Open(PAKPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))) - { - reader.BaseStream.Seek(reader.BaseStream.Length - 40 - 160, SeekOrigin.Begin); - uint version = reader.ReadUInt32(); - - return version; - } - } - public static bool IsPAKLocked(FileInfo PakFileInfo) { FileStream stream = null; diff --git a/FModel/Properties/Resources.Designer.cs b/FModel/Properties/Resources.Designer.cs index 2065d9d2..72eaec7b 100644 --- a/FModel/Properties/Resources.Designer.cs +++ b/FModel/Properties/Resources.Designer.cs @@ -631,6 +631,26 @@ namespace FModel.Properties { } } + /// + /// Recherche une ressource localisée de type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Template_AC_F { + get { + object obj = ResourceManager.GetObject("Template_AC_F", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Recherche une ressource localisée de type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Template_AC_N { + get { + object obj = ResourceManager.GetObject("Template_AC_N", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// diff --git a/FModel/Properties/Resources.resx b/FModel/Properties/Resources.resx index d045d62e..c4e288e3 100644 --- a/FModel/Properties/Resources.resx +++ b/FModel/Properties/Resources.resx @@ -288,4 +288,10 @@ Usually, this isn't filled in. ..\Resources\settings_16x.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\Template_AC_F.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Template_AC_N.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/FModel/Resources/Template_AC_F.png b/FModel/Resources/Template_AC_F.png new file mode 100644 index 00000000..b9093749 Binary files /dev/null and b/FModel/Resources/Template_AC_F.png differ diff --git a/FModel/Resources/Template_AC_N.png b/FModel/Resources/Template_AC_N.png new file mode 100644 index 00000000..bbb9a36e Binary files /dev/null and b/FModel/Resources/Template_AC_N.png differ