diff --git a/FModel/Forms/AESManager.xaml.cs b/FModel/Forms/AESManager.xaml.cs index 1333a3a3..0f80da78 100644 --- a/FModel/Forms/AESManager.xaml.cs +++ b/FModel/Forms/AESManager.xaml.cs @@ -51,7 +51,7 @@ namespace FModel.Forms if (AESEntries.AESEntriesList == null) { KeysManager.Deserialize(); } int yPos = 4; - foreach (PAKInfosEntry Pak in PAKEntries.PAKEntriesList.Where(x => x.bTheDynamicPAK == true)) + foreach (PAKInfosEntry Pak in PAKEntries.PAKEntriesList.Where(x => x.bTheDynamicPAK)) { Label PakLabel = new Label(); PakLabel.Content = Path.GetFileNameWithoutExtension(Pak.ThePAKPath); @@ -109,7 +109,7 @@ namespace FModel.Forms AESEntries.AESEntriesList = new List(); if (PAKEntries.PAKEntriesList != null && PAKEntries.PAKEntriesList.Any()) { - foreach (PAKInfosEntry Pak in PAKEntries.PAKEntriesList.Where(x => x.bTheDynamicPAK == true)) + foreach (PAKInfosEntry Pak in PAKEntries.PAKEntriesList.Where(x => x.bTheDynamicPAK)) { TextBox PakTextBox = UIHelper.FindChild(this, $"TxtBox_{Regex.Match(Path.GetFileNameWithoutExtension(Pak.ThePAKPath), @"\d+").Value}"); if (!string.IsNullOrEmpty(PakTextBox.Text)) diff --git a/FModel/Forms/FModel_CustomMB.xaml.cs b/FModel/Forms/FModel_CustomMB.xaml.cs index ca68b44d..9d248c40 100644 --- a/FModel/Forms/FModel_CustomMB.xaml.cs +++ b/FModel/Forms/FModel_CustomMB.xaml.cs @@ -90,7 +90,7 @@ namespace FModel.Forms this.SetValue(TextOptions.TextFormattingModeProperty, TextFormattingMode.Display); Message = message; - Image_MessageBox.Visibility = System.Windows.Visibility.Collapsed; + Image_MessageBox.Visibility = Visibility.Collapsed; DisplayButtons(MessageBoxButton.OK); } @@ -100,7 +100,7 @@ namespace FModel.Forms Message = message; Caption = caption; - Image_MessageBox.Visibility = System.Windows.Visibility.Collapsed; + Image_MessageBox.Visibility = Visibility.Collapsed; DisplayButtons(MessageBoxButton.OK); } @@ -110,7 +110,7 @@ namespace FModel.Forms Message = message; Caption = caption; - Image_MessageBox.Visibility = System.Windows.Visibility.Collapsed; + Image_MessageBox.Visibility = Visibility.Collapsed; DisplayButtons(button); } @@ -131,7 +131,7 @@ namespace FModel.Forms Message = message; Caption = caption; - Image_MessageBox.Visibility = System.Windows.Visibility.Collapsed; + Image_MessageBox.Visibility = Visibility.Collapsed; DisplayButtons(button); DisplayImage(image); @@ -143,39 +143,39 @@ namespace FModel.Forms { case MessageBoxButton.OKCancel: // Hide all but OK, Cancel - Button_OK.Visibility = System.Windows.Visibility.Visible; + Button_OK.Visibility = Visibility.Visible; Button_OK.Focus(); - Button_Cancel.Visibility = System.Windows.Visibility.Visible; + Button_Cancel.Visibility = Visibility.Visible; - Button_Yes.Visibility = System.Windows.Visibility.Collapsed; - Button_No.Visibility = System.Windows.Visibility.Collapsed; + Button_Yes.Visibility = Visibility.Collapsed; + Button_No.Visibility = Visibility.Collapsed; break; case MessageBoxButton.YesNo: // Hide all but Yes, No - Button_Yes.Visibility = System.Windows.Visibility.Visible; + Button_Yes.Visibility = Visibility.Visible; Button_Yes.Focus(); - Button_No.Visibility = System.Windows.Visibility.Visible; + Button_No.Visibility = Visibility.Visible; - Button_OK.Visibility = System.Windows.Visibility.Collapsed; - Button_Cancel.Visibility = System.Windows.Visibility.Collapsed; + Button_OK.Visibility = Visibility.Collapsed; + Button_Cancel.Visibility = Visibility.Collapsed; break; case MessageBoxButton.YesNoCancel: // Hide only OK - Button_Yes.Visibility = System.Windows.Visibility.Visible; + Button_Yes.Visibility = Visibility.Visible; Button_Yes.Focus(); - Button_No.Visibility = System.Windows.Visibility.Visible; - Button_Cancel.Visibility = System.Windows.Visibility.Visible; + Button_No.Visibility = Visibility.Visible; + Button_Cancel.Visibility = Visibility.Visible; - Button_OK.Visibility = System.Windows.Visibility.Collapsed; + Button_OK.Visibility = Visibility.Collapsed; break; default: // Hide all but OK - Button_OK.Visibility = System.Windows.Visibility.Visible; + Button_OK.Visibility = Visibility.Visible; Button_OK.Focus(); - Button_Yes.Visibility = System.Windows.Visibility.Collapsed; - Button_No.Visibility = System.Windows.Visibility.Collapsed; - Button_Cancel.Visibility = System.Windows.Visibility.Collapsed; + Button_Yes.Visibility = Visibility.Collapsed; + Button_No.Visibility = Visibility.Collapsed; + Button_Cancel.Visibility = Visibility.Collapsed; break; } } @@ -204,7 +204,7 @@ namespace FModel.Forms } Image_MessageBox.Source = icon.ToImageSource(); - Image_MessageBox.Visibility = System.Windows.Visibility.Visible; + Image_MessageBox.Visibility = Visibility.Visible; } private void Button_OK_Click(object sender, RoutedEventArgs e) diff --git a/FModel/Forms/FModel_ImagesMerger.xaml.cs b/FModel/Forms/FModel_ImagesMerger.xaml.cs index ea421350..3d7b1b3a 100644 --- a/FModel/Forms/FModel_ImagesMerger.xaml.cs +++ b/FModel/Forms/FModel_ImagesMerger.xaml.cs @@ -2,7 +2,6 @@ using Microsoft.Win32; using System; using System.Collections.Generic; -using System.Globalization; using System.IO; using System.Linq; using System.Threading.Tasks; @@ -69,14 +68,6 @@ namespace FModel.Forms //INITIALIZATION drawingContext.DrawRectangle(Brushes.Transparent, null, new Rect(new Point(0, 0), new Size(515, 515))); - var w = 520 * numperrow; - if (imageCount * 520 < 520 * numperrow) - { - w = imageCount * 520; - } - - int h = int.Parse(Math.Ceiling(double.Parse(imageCount.ToString()) / numperrow).ToString(CultureInfo.InvariantCulture)) * 520; - int num = 1; int curW = 0; int curH = 0; @@ -84,8 +75,6 @@ namespace FModel.Forms for (int i = 0; i < imageCount; i++) { - int percentage = (i + 1) * 100 / imageCount; - BitmapImage source = new BitmapImage(new Uri(_imagePath[i])); source.DecodePixelWidth = 515; @@ -110,17 +99,14 @@ namespace FModel.Forms } } - if (drawingVisual != null) - { - RenderTargetBitmap RTB = new RenderTargetBitmap((int)Math.Floor(drawingVisual.DescendantBounds.Width), (int)Math.Floor(drawingVisual.DescendantBounds.Height), 96, 96, PixelFormats.Pbgra32); - RTB.Render(drawingVisual); - RTB.Freeze(); //We freeze to apply the RTB to our imagesource from the UI Thread + RenderTargetBitmap RTB = new RenderTargetBitmap((int)Math.Floor(drawingVisual.DescendantBounds.Width), (int)Math.Floor(drawingVisual.DescendantBounds.Height), 96, 96, PixelFormats.Pbgra32); + RTB.Render(drawingVisual); + RTB.Freeze(); //We freeze to apply the RTB to our imagesource from the UI Thread - this.Dispatcher.InvokeAsync(() => - { - MergerPreview_Image.Source = BitmapFrame.Create(RTB); //thread safe and fast af - }); - } + this.Dispatcher.InvokeAsync(() => + { + MergerPreview_Image.Source = BitmapFrame.Create(RTB); //thread safe and fast af + }); }).ContinueWith(TheTask => { @@ -156,7 +142,7 @@ namespace FModel.Forms private void AddFiles(string[] files) { - if (files.Count() > 0) + if (files.Length > 0) { foreach (string file in files) { diff --git a/FModel/Forms/FModel_Settings.xaml.cs b/FModel/Forms/FModel_Settings.xaml.cs index 91b5f729..f9ff1a34 100644 --- a/FModel/Forms/FModel_Settings.xaml.cs +++ b/FModel/Forms/FModel_Settings.xaml.cs @@ -25,6 +25,16 @@ namespace FModel.Forms /// public partial class FModel_Settings : Window { + private const string CHALLENGE_TEMPLATE_ICON = "pack://application:,,,/Resources/Template_Challenge.png"; + private const string RARITY_DEFAULT_FEATURED = "pack://application:,,,/Resources/Template_D_F.png"; + private const string RARITY_DEFAULT_NORMAL = "pack://application:,,,/Resources/Template_D_N.png"; + private const string RARITY_FLAT_FEATURED = "pack://application:,,,/Resources/Template_F_F.png"; + private const string RARITY_FLAT_NORMAL = "pack://application:,,,/Resources/Template_F_N.png"; + private const string RARITY_MINIMALIST_FEATURED = "pack://application:,,,/Resources/Template_M_F.png"; + private const string RARITY_MINIMALIST_NORMAL = "pack://application:,,,/Resources/Template_M_N.png"; + private const string RARITY_ACCURATECOLORS_FEATURED = "pack://application:,,,/Resources/Template_AC_F.png"; + private const string RARITY_ACCURATECOLORS_NORMAL = "pack://application:,,,/Resources/Template_AC_N.png"; + public FModel_Settings() { InitializeComponent(); @@ -81,7 +91,7 @@ namespace FModel.Forms public static T GetEnumValueFromDescription(string description) { var type = typeof(T); - if (!type.IsEnum) { throw new ArgumentException(); } + if (!type.IsEnum) { throw new ArgumentException("Enum type is null, bruh"); } FieldInfo[] fields = type.GetFields(); var field = fields .SelectMany(f => f.GetCustomAttributes( @@ -232,16 +242,16 @@ namespace FModel.Forms switch (rarityDesign) { case "Default": - source = new BitmapImage(new Uri(isFeatured ? "pack://application:,,,/Resources/Template_D_F.png" : "pack://application:,,,/Resources/Template_D_N.png")); + source = new BitmapImage(new Uri(isFeatured ? RARITY_DEFAULT_FEATURED : RARITY_DEFAULT_NORMAL)); break; case "Flat": - source = new BitmapImage(new Uri(isFeatured ? "pack://application:,,,/Resources/Template_F_F.png" : "pack://application:,,,/Resources/Template_F_N.png")); + source = new BitmapImage(new Uri(isFeatured ? RARITY_FLAT_FEATURED : RARITY_FLAT_NORMAL)); break; case "Minimalist": - source = new BitmapImage(new Uri(isFeatured ? "pack://application:,,,/Resources/Template_M_F.png" : "pack://application:,,,/Resources/Template_M_N.png")); + source = new BitmapImage(new Uri(isFeatured ? RARITY_MINIMALIST_FEATURED : RARITY_MINIMALIST_NORMAL)); break; case "Accurate Colors": - source = new BitmapImage(new Uri(isFeatured ? "pack://application:,,,/Resources/Template_AC_F.png" : "pack://application:,,,/Resources/Template_AC_N.png")); + source = new BitmapImage(new Uri(isFeatured ? RARITY_ACCURATECOLORS_FEATURED : RARITY_ACCURATECOLORS_NORMAL)); break; } drawingContext.DrawImage(source, new Rect(new Point(0, 0), new Size(515, 515))); @@ -250,31 +260,25 @@ namespace FModel.Forms { using (StreamReader image = new StreamReader(FProp.Default.FWatermarkFilePath)) { - if (image != null) - { - BitmapImage bmp = new BitmapImage(); - bmp.BeginInit(); - bmp.CacheOption = BitmapCacheOption.OnLoad; - bmp.StreamSource = image.BaseStream; - bmp.EndInit(); + BitmapImage bmp = new BitmapImage(); + bmp.BeginInit(); + bmp.CacheOption = BitmapCacheOption.OnLoad; + bmp.StreamSource = image.BaseStream; + bmp.EndInit(); - drawingContext.DrawImage(ImagesUtility.CreateTransparency(bmp, opacity), new Rect(xPos, yPos, scale, scale)); - } + drawingContext.DrawImage(ImagesUtility.CreateTransparency(bmp, opacity), new Rect(xPos, yPos, scale, scale)); } } } - if (drawingVisual != null) - { - RenderTargetBitmap RTB = new RenderTargetBitmap(515, 515, 96, 96, PixelFormats.Pbgra32); - RTB.Render(drawingVisual); - RTB.Freeze(); //We freeze to apply the RTB to our imagesource from the UI Thread + RenderTargetBitmap RTB = new RenderTargetBitmap(515, 515, 96, 96, PixelFormats.Pbgra32); + RTB.Render(drawingVisual); + RTB.Freeze(); //We freeze to apply the RTB to our imagesource from the UI Thread - FWindow.FMain.Dispatcher.InvokeAsync(() => - { - ImageBox_RarityPreview.Source = BitmapFrame.Create(RTB); //thread safe and fast af - }); - } + FWindow.FMain.Dispatcher.InvokeAsync(() => + { + ImageBox_RarityPreview.Source = BitmapFrame.Create(RTB); //thread safe and fast af + }); }).ContinueWith(TheTask => { @@ -433,7 +437,7 @@ namespace FModel.Forms } else { - BitmapImage source = new BitmapImage(new Uri("pack://application:,,,/Resources/Template_Challenge.png")); + BitmapImage source = new BitmapImage(new Uri(CHALLENGE_TEMPLATE_ICON)); ImageBox_ChallengePreview.Source = source; } } diff --git a/FModel/Forms/FModel_UpdateMode.xaml.cs b/FModel/Forms/FModel_UpdateMode.xaml.cs index 5601a214..9497163b 100644 --- a/FModel/Forms/FModel_UpdateMode.xaml.cs +++ b/FModel/Forms/FModel_UpdateMode.xaml.cs @@ -25,6 +25,16 @@ namespace FModel.Forms /// public partial class FModel_UpdateMode : Window { + private const string CHALLENGE_TEMPLATE_ICON = "pack://application:,,,/Resources/Template_Challenge.png"; + private const string RARITY_DEFAULT_FEATURED = "pack://application:,,,/Resources/Template_D_F.png"; + private const string RARITY_DEFAULT_NORMAL = "pack://application:,,,/Resources/Template_D_N.png"; + private const string RARITY_FLAT_FEATURED = "pack://application:,,,/Resources/Template_F_F.png"; + private const string RARITY_FLAT_NORMAL = "pack://application:,,,/Resources/Template_F_N.png"; + private const string RARITY_MINIMALIST_FEATURED = "pack://application:,,,/Resources/Template_M_F.png"; + private const string RARITY_MINIMALIST_NORMAL = "pack://application:,,,/Resources/Template_M_N.png"; + private const string RARITY_ACCURATECOLORS_FEATURED = "pack://application:,,,/Resources/Template_AC_F.png"; + private const string RARITY_ACCURATECOLORS_NORMAL = "pack://application:,,,/Resources/Template_AC_N.png"; + #region CLASS public class AssetProperties : INotifyPropertyChanged { @@ -116,14 +126,14 @@ namespace FModel.Forms public static T GetEnumValueFromDescription(string description) { var type = typeof(T); - if (!type.IsEnum) { throw new ArgumentException(); } + if (!type.IsEnum) { throw new ArgumentException("Enum type is null, bruh"); } FieldInfo[] fields = type.GetFields(); var field = fields .SelectMany(f => f.GetCustomAttributes( typeof(DescriptionAttribute), false), ( f, a) => new { Field = f, Att = a }) - .Where(a => ((DescriptionAttribute)a.Att) - .Description == description).SingleOrDefault(); + .SingleOrDefault(a => ((DescriptionAttribute)a.Att) + .Description == description); return field == null ? default(T) : (T)field.Field.GetRawConstantValue(); } #endregion @@ -193,16 +203,16 @@ namespace FModel.Forms switch (rarityDesign) { case "Default": - source = new BitmapImage(new Uri(isFeatured ? "pack://application:,,,/Resources/Template_D_F.png" : "pack://application:,,,/Resources/Template_D_N.png")); + source = new BitmapImage(new Uri(isFeatured ? RARITY_DEFAULT_FEATURED : RARITY_DEFAULT_NORMAL)); break; case "Flat": - source = new BitmapImage(new Uri(isFeatured ? "pack://application:,,,/Resources/Template_F_F.png" : "pack://application:,,,/Resources/Template_F_N.png")); + source = new BitmapImage(new Uri(isFeatured ? RARITY_FLAT_FEATURED : RARITY_FLAT_NORMAL)); break; case "Minimalist": - source = new BitmapImage(new Uri(isFeatured ? "pack://application:,,,/Resources/Template_M_F.png" : "pack://application:,,,/Resources/Template_M_N.png")); + source = new BitmapImage(new Uri(isFeatured ? RARITY_MINIMALIST_FEATURED : RARITY_MINIMALIST_NORMAL)); break; case "Accurate Colors": - source = new BitmapImage(new Uri(isFeatured ? "pack://application:,,,/Resources/Template_AC_F.png" : "pack://application:,,,/Resources/Template_AC_N.png")); + source = new BitmapImage(new Uri(isFeatured ? RARITY_ACCURATECOLORS_FEATURED : RARITY_ACCURATECOLORS_NORMAL)); break; } drawingContext.DrawImage(source, new Rect(new Point(0, 0), new Size(515, 515))); @@ -211,31 +221,25 @@ namespace FModel.Forms { using (StreamReader image = new StreamReader(FProp.Default.FWatermarkFilePath)) { - if (image != null) - { - BitmapImage bmp = new BitmapImage(); - bmp.BeginInit(); - bmp.CacheOption = BitmapCacheOption.OnLoad; - bmp.StreamSource = image.BaseStream; - bmp.EndInit(); + BitmapImage bmp = new BitmapImage(); + bmp.BeginInit(); + bmp.CacheOption = BitmapCacheOption.OnLoad; + bmp.StreamSource = image.BaseStream; + bmp.EndInit(); - drawingContext.DrawImage(ImagesUtility.CreateTransparency(bmp, opacity), new Rect(FProp.Default.FWatermarkXPos, FProp.Default.FWatermarkYPos, scale, scale)); - } + drawingContext.DrawImage(ImagesUtility.CreateTransparency(bmp, opacity), new Rect(FProp.Default.FWatermarkXPos, FProp.Default.FWatermarkYPos, scale, scale)); } } } - if (drawingVisual != null) - { - RenderTargetBitmap RTB = new RenderTargetBitmap(515, 515, 96, 96, PixelFormats.Pbgra32); - RTB.Render(drawingVisual); - RTB.Freeze(); //We freeze to apply the RTB to our imagesource from the UI Thread + RenderTargetBitmap RTB = new RenderTargetBitmap(515, 515, 96, 96, PixelFormats.Pbgra32); + RTB.Render(drawingVisual); + RTB.Freeze(); //We freeze to apply the RTB to our imagesource from the UI Thread - FWindow.FMain.Dispatcher.InvokeAsync(() => - { - ImageBox_RarityPreview.Source = BitmapFrame.Create(RTB); //thread safe and fast af - }); - } + FWindow.FMain.Dispatcher.InvokeAsync(() => + { + ImageBox_RarityPreview.Source = BitmapFrame.Create(RTB); //thread safe and fast af + }); }).ContinueWith(TheTask => { diff --git a/FModel/Methods/AESManager/DynamicKeysChecker.cs b/FModel/Methods/AESManager/DynamicKeysChecker.cs index 46e432bb..75d4635d 100644 --- a/FModel/Methods/AESManager/DynamicKeysChecker.cs +++ b/FModel/Methods/AESManager/DynamicKeysChecker.cs @@ -37,8 +37,8 @@ namespace FModel.Methods.AESManager if (KeysDict != null) { AESEntries.AESEntriesList = new List(); - foreach (PAKInfosEntry Pak in PAKEntries.PAKEntriesList.Where(x => x.bTheDynamicPAK == true //DYNAMIC PAK ONLY - && !AESEntries.AESEntriesList.Where(w => string.Equals(w.ThePAKName, Path.GetFileNameWithoutExtension(x.ThePAKPath))).Any() //IS NOT ALREADY ADDED + foreach (PAKInfosEntry Pak in PAKEntries.PAKEntriesList.Where(x => x.bTheDynamicPAK //DYNAMIC PAK ONLY + && !AESEntries.AESEntriesList.Any(w => string.Equals(w.ThePAKName, Path.GetFileNameWithoutExtension(x.ThePAKPath))) //IS NOT ALREADY ADDED )) { if (KeysDict.ContainsKey(Path.GetFileName(Pak.ThePAKPath))) @@ -47,7 +47,7 @@ namespace FModel.Methods.AESManager if (_oldAESEntriesList != null) { - if (!_oldAESEntriesList.Where(x => string.Equals(x.ThePAKKey, KeysDict[Path.GetFileName(Pak.ThePAKPath)].ToUpperInvariant().Substring(2))).Any()) + if (!_oldAESEntriesList.Any(x => string.Equals(x.ThePAKKey, KeysDict[Path.GetFileName(Pak.ThePAKPath)].ToUpperInvariant().Substring(2)))) { new UpdateMyConsole(Path.GetFileName(Pak.ThePAKPath), CColors.Blue).Append(); new UpdateMyConsole(" can now be opened.", CColors.White, true).Append(); diff --git a/FModel/Methods/Assets/AssetTranslations.cs b/FModel/Methods/Assets/AssetTranslations.cs index 69314814..869ec093 100644 --- a/FModel/Methods/Assets/AssetTranslations.cs +++ b/FModel/Methods/Assets/AssetTranslations.cs @@ -118,7 +118,7 @@ namespace FModel.Methods.Assets } } } - return null; + return new Dictionary>(); } public static void SetHotfixedLocResDict() @@ -172,7 +172,7 @@ namespace FModel.Methods.Assets private static string GetValueFromParam(string fullLine, string startWith, string endWith) { int startIndex = fullLine.IndexOf(startWith, StringComparison.InvariantCultureIgnoreCase) + startWith.Length; - int endIndex = fullLine.Substring(startIndex).IndexOf(endWith, StringComparison.InvariantCultureIgnoreCase); + int endIndex = fullLine.Substring(startIndex).ToString().IndexOf(endWith, StringComparison.InvariantCultureIgnoreCase); return fullLine.Substring(startIndex, endIndex); } diff --git a/FModel/Methods/Assets/IconCreator/AthenaID/CosmeticSet.cs b/FModel/Methods/Assets/IconCreator/AthenaID/CosmeticSet.cs index f16dc4af..9ea8cf8b 100644 --- a/FModel/Methods/Assets/IconCreator/AthenaID/CosmeticSet.cs +++ b/FModel/Methods/Assets/IconCreator/AthenaID/CosmeticSet.cs @@ -1,8 +1,6 @@ using FModel.Methods.Utilities; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using PakReader; -using System.Collections.Generic; using System.Linq; using FProp = FModel.Properties.Settings; @@ -17,15 +15,12 @@ namespace FModel.Methods.Assets.IconCreator.AthenaID if (ItemSetsArray == null) { string jsonData = AssetsUtility.GetAssetJsonDataByPath("/FortniteGame/Content/Athena/Items/Cosmetics/Metadata/CosmeticSets", true); - if (jsonData != null) + if (jsonData != null && AssetsUtility.IsValidJson(jsonData)) { - if (AssetsUtility.IsValidJson(jsonData)) - { - dynamic AssetData = JsonConvert.DeserializeObject(jsonData); - JArray AssetArray = JArray.FromObject(AssetData); - ItemSetsArray = AssetArray[0]["rows"].Value(); - return SearchSetDisplayName(SetTagName); - } + dynamic AssetData = JsonConvert.DeserializeObject(jsonData); + JArray AssetArray = JArray.FromObject(AssetData); + ItemSetsArray = AssetArray[0]["rows"].Value(); + return SearchSetDisplayName(SetTagName); } } else diff --git a/FModel/Methods/Assets/IconCreator/AthenaID/IconUserFacingFlags.cs b/FModel/Methods/Assets/IconCreator/AthenaID/IconUserFacingFlags.cs index 2c959643..2159a510 100644 --- a/FModel/Methods/Assets/IconCreator/AthenaID/IconUserFacingFlags.cs +++ b/FModel/Methods/Assets/IconCreator/AthenaID/IconUserFacingFlags.cs @@ -1,9 +1,7 @@ using FModel.Methods.Utilities; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using PakReader; using System; -using System.Collections.Generic; using System.IO; using System.Windows; using System.Windows.Media.Imaging; @@ -14,26 +12,25 @@ namespace FModel.Methods.Assets.IconCreator.AthenaID { private static JArray ItemCategoriesArray { get; set; } public static int xCoords = 4 - 25; + private const string PET_CUSTOM_ICON = "pack://application:,,,/Resources/T-Icon-Pets-64.png"; + private const string QUEST_CUSTOM_ICON = "pack://application:,,,/Resources/T-Icon-Quests-64.png"; public static void DrawUserFacingFlag(JToken uFF) { if (ItemCategoriesArray == null) { string jsonData = AssetsUtility.GetAssetJsonDataByPath("/FortniteGame/Content/Items/ItemCategories", true); - if (jsonData != null) + if (jsonData != null && AssetsUtility.IsValidJson(jsonData)) { - if (AssetsUtility.IsValidJson(jsonData)) + dynamic AssetData = JsonConvert.DeserializeObject(jsonData); + JArray AssetArray = JArray.FromObject(AssetData); + JToken tertiaryCategoriesToken = AssetsUtility.GetPropertyTag(AssetArray[0]["properties"].Value(), "TertiaryCategories"); + if (tertiaryCategoriesToken != null) { - dynamic AssetData = JsonConvert.DeserializeObject(jsonData); - JArray AssetArray = JArray.FromObject(AssetData); - JToken tertiaryCategoriesToken = AssetsUtility.GetPropertyTag(AssetArray[0]["properties"].Value(), "TertiaryCategories"); - if (tertiaryCategoriesToken != null) - { - ItemCategoriesArray = tertiaryCategoriesToken["data"].Value(); + ItemCategoriesArray = tertiaryCategoriesToken["data"].Value(); - string uFFTargeted = uFF.Value().Substring("Cosmetics.UserFacingFlags.".Length); - SearchUserFacingFlag(uFFTargeted); - } + string uFFTargeted = uFF.Value().Substring("Cosmetics.UserFacingFlags.".Length); + SearchUserFacingFlag(uFFTargeted); } } } @@ -71,7 +68,7 @@ namespace FModel.Methods.Assets.IconCreator.AthenaID BitmapImage bmp = new BitmapImage(); bmp.BeginInit(); bmp.CacheOption = BitmapCacheOption.OnLoad; - bmp.UriSource = new Uri("pack://application:,,,/Resources/T-Icon-Pets-64.png"); + bmp.UriSource = new Uri(PET_CUSTOM_ICON); bmp.EndInit(); bmp.Freeze(); @@ -83,7 +80,7 @@ namespace FModel.Methods.Assets.IconCreator.AthenaID BitmapImage bmp = new BitmapImage(); bmp.BeginInit(); bmp.CacheOption = BitmapCacheOption.OnLoad; - bmp.UriSource = new Uri("pack://application:,,,/Resources/T-Icon-Quests-64.png"); + bmp.UriSource = new Uri(QUEST_CUSTOM_ICON); bmp.EndInit(); bmp.Freeze(); diff --git a/FModel/Methods/Assets/IconCreator/ChallengeID/ChallengeBundleInfos.cs b/FModel/Methods/Assets/IconCreator/ChallengeID/ChallengeBundleInfos.cs index 2d1f9cec..13810d45 100644 --- a/FModel/Methods/Assets/IconCreator/ChallengeID/ChallengeBundleInfos.cs +++ b/FModel/Methods/Assets/IconCreator/ChallengeID/ChallengeBundleInfos.cs @@ -1,14 +1,12 @@ using FModel.Methods.Utilities; -using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using PakReader; using System; using System.Collections.Generic; using System.Linq; namespace FModel.Methods.Assets.IconCreator.ChallengeID { - class ChallengeBundleInfos + static class ChallengeBundleInfos { public static List BundleData { get; set; } @@ -48,146 +46,197 @@ namespace FModel.Methods.Assets.IconCreator.ChallengeID private static void GetQuestData(JArray BundleProperties, string assetPath) { string jsonData = AssetsUtility.GetAssetJsonDataByPath(assetPath); - if (jsonData != null) + if (jsonData != null && AssetsUtility.IsValidJson(jsonData)) { - if (AssetsUtility.IsValidJson(jsonData)) + JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData); + if (AssetMainToken != null) { - JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData); - if (AssetMainToken != null) + JArray AssetProperties = AssetMainToken["properties"].Value(); + if (AssetProperties != null) { - JArray AssetProperties = AssetMainToken["properties"].Value(); - if (AssetProperties != null) - { - string questDescription = string.Empty; - long questCount = 0; - string unlockType = string.Empty; - string rewardPath = string.Empty; - string rewardQuantity = string.Empty; + string questDescription = string.Empty; + long questCount = 0; + string unlockType = string.Empty; + string rewardPath = string.Empty; + string rewardQuantity = string.Empty; - //this come from the bundle properties array not the quest properties array - JToken questUnlockTypeToken = AssetsUtility.GetPropertyTag(BundleProperties, "QuestUnlockType"); - if (questUnlockTypeToken != null) + //this come from the bundle properties array not the quest properties array + JToken questUnlockTypeToken = AssetsUtility.GetPropertyTag(BundleProperties, "QuestUnlockType"); + if (questUnlockTypeToken != null) + { + unlockType = questUnlockTypeToken.Value(); + } + + //objectives array to catch the quest description and quest count + JArray objectivesDataArray = AssetsUtility.GetPropertyTagText(AssetProperties, "Objectives", "data"); + if (objectivesDataArray != null && + objectivesDataArray[0]["struct_name"] != null && objectivesDataArray[0]["struct_type"] != null && string.Equals(objectivesDataArray[0]["struct_name"].Value(), "FortMcpQuestObjectiveInfo")) + { + JArray objectivesDataProperties = objectivesDataArray[0]["struct_type"]["properties"].Value(); + + //this description come from the main quest array (not the objectives array) + JToken description_namespace = AssetsUtility.GetPropertyTagText(AssetProperties, "Description", "namespace"); + JToken description_key = AssetsUtility.GetPropertyTagText(AssetProperties, "Description", "key"); + JToken description_source_string = AssetsUtility.GetPropertyTagText(AssetProperties, "Description", "source_string"); + if (description_namespace != null && description_key != null && description_source_string != null) { - unlockType = questUnlockTypeToken.Value(); + questDescription = AssetTranslations.SearchTranslation(description_namespace.Value(), description_key.Value(), description_source_string.Value()); + } + else + { + //this description come from the objectives quest array + description_namespace = AssetsUtility.GetPropertyTagText(objectivesDataProperties, "Description", "namespace"); + description_key = AssetsUtility.GetPropertyTagText(objectivesDataProperties, "Description", "key"); + description_source_string = AssetsUtility.GetPropertyTagText(objectivesDataProperties, "Description", "source_string"); + if (description_namespace != null && description_key != null && description_source_string != null) + { + questDescription = AssetTranslations.SearchTranslation(description_namespace.Value(), description_key.Value(), description_source_string.Value()); + } } - //objectives array to catch the quest description and quest count - JArray objectivesDataArray = AssetsUtility.GetPropertyTagText(AssetProperties, "Objectives", "data"); - if (objectivesDataArray != null) + if (objectivesDataProperties != null) { - if (objectivesDataArray[0]["struct_name"] != null && objectivesDataArray[0]["struct_type"] != null && string.Equals(objectivesDataArray[0]["struct_name"].Value(), "FortMcpQuestObjectiveInfo")) + JToken countToken = AssetsUtility.GetPropertyTag(objectivesDataProperties, "Count"); + if (countToken != null) { - JArray objectivesDataProperties = objectivesDataArray[0]["struct_type"]["properties"].Value(); - - //this description come from the main quest array (not the objectives array) - JToken description_namespace = AssetsUtility.GetPropertyTagText(AssetProperties, "Description", "namespace"); - JToken description_key = AssetsUtility.GetPropertyTagText(AssetProperties, "Description", "key"); - JToken description_source_string = AssetsUtility.GetPropertyTagText(AssetProperties, "Description", "source_string"); - if (description_namespace != null && description_key != null && description_source_string != null) + questCount = countToken.Value(); + JToken objectiveCompletionCountToken = AssetsUtility.GetPropertyTag(AssetProperties, "ObjectiveCompletionCount"); + if (objectiveCompletionCountToken != null) { - questDescription = AssetTranslations.SearchTranslation(description_namespace.Value(), description_key.Value(), description_source_string.Value()); + questCount = objectiveCompletionCountToken.Value(); + } + } + } + } + + //rewards array to catch the reward name (not path) and the quantity + JArray rewardsDataArray = AssetsUtility.GetPropertyTagText(AssetProperties, "Rewards", "data"); + JArray hiddenRewardsDataArray = AssetsUtility.GetPropertyTagText(AssetProperties, "HiddenRewards", "data"); + JToken rewardsTable = AssetsUtility.GetPropertyTagImport(AssetProperties, "RewardsTable"); + if (rewardsDataArray != null) + { + if (rewardsDataArray[0]["struct_name"] != null && rewardsDataArray[0]["struct_type"] != null && string.Equals(rewardsDataArray[0]["struct_name"].Value(), "FortItemQuantityPair")) + { + try + { + //checking the whole array for the reward + //ignoring all Quest and Token until he find the reward + JToken targetChecker = rewardsDataArray.FirstOrDefault(x => + !string.Equals(x["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][0]["tag_data"].Value(), "Quest") && + !string.Equals(x["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][0]["tag_data"].Value(), "Token")) + ["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][1]["tag_data"]; + + //checking the whole array for the reward quantity + //ignoring all Quest and Token until he find the reward quantity + JToken targetQuantity = rewardsDataArray.FirstOrDefault(x => + !string.Equals(x["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][0]["tag_data"].Value(), "Quest") && + !string.Equals(x["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][0]["tag_data"].Value(), "Token")) + ["struct_type"]["properties"][1]["tag_data"]; + + if (targetChecker != null) + { + //this will catch the full path if asset exists to be able to grab his PakReader and List + string primaryAssetNameFullPath = AssetEntries.AssetEntriesDict.Where(x => x.Key.ToLowerInvariant().Contains("/" + targetChecker.Value().ToLowerInvariant() + ".uasset")).Select(d => d.Key).FirstOrDefault(); + if (!string.IsNullOrEmpty(primaryAssetNameFullPath)) + { + rewardPath = primaryAssetNameFullPath.Substring(0, primaryAssetNameFullPath.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase)); + } + + if (targetQuantity != null) + { + rewardQuantity = targetQuantity.Value(); + } + + BundleInfosEntry currentData = new BundleInfosEntry(questDescription, questCount, unlockType, rewardPath, rewardQuantity); + if (!BundleData.Any(item => item.TheQuestDescription.Equals(currentData.TheQuestDescription, StringComparison.InvariantCultureIgnoreCase) && item.TheQuestCount == currentData.TheQuestCount)) + { + BundleData.Add(currentData); + } } else { - //this description come from the objectives quest array - description_namespace = AssetsUtility.GetPropertyTagText(objectivesDataProperties, "Description", "namespace"); - description_key = AssetsUtility.GetPropertyTagText(objectivesDataProperties, "Description", "key"); - description_source_string = AssetsUtility.GetPropertyTagText(objectivesDataProperties, "Description", "source_string"); - if (description_namespace != null && description_key != null && description_source_string != null) + BundleInfosEntry currentData = new BundleInfosEntry(questDescription, questCount, unlockType, "", ""); + if (!BundleData.Any(item => item.TheQuestDescription.Equals(currentData.TheQuestDescription, StringComparison.InvariantCultureIgnoreCase) && item.TheQuestCount == currentData.TheQuestCount)) { - questDescription = AssetTranslations.SearchTranslation(description_namespace.Value(), description_key.Value(), description_source_string.Value()); + BundleData.Add(currentData); } } - - if (objectivesDataProperties != null) + } + catch (Exception) + { + if (hiddenRewardsDataArray != null) { - JToken countToken = AssetsUtility.GetPropertyTag(objectivesDataProperties, "Count"); - if (countToken != null) + if (hiddenRewardsDataArray[0]["struct_name"] != null && hiddenRewardsDataArray[0]["struct_type"] != null && string.Equals(hiddenRewardsDataArray[0]["struct_name"].Value(), "FortHiddenRewardQuantityPair")) { - questCount = countToken.Value(); - JToken objectiveCompletionCountToken = AssetsUtility.GetPropertyTag(AssetProperties, "ObjectiveCompletionCount"); - if (objectiveCompletionCountToken != null) + JArray hiddenRewardPropertiesArray = hiddenRewardsDataArray[0]["struct_type"]["properties"].Value(); + if (hiddenRewardPropertiesArray != null) { - questCount = objectiveCompletionCountToken.Value(); + JToken templateIdToken = AssetsUtility.GetPropertyTag(hiddenRewardPropertiesArray, "TemplateId"); + if (templateIdToken != null) + { + rewardPath = templateIdToken.Value(); + } + + //reward quantity (if 1, this won't be displayed) + JToken hiddenQuantityToken = AssetsUtility.GetPropertyTag(hiddenRewardPropertiesArray, "Quantity"); + if (hiddenQuantityToken != null) + { + rewardQuantity = hiddenQuantityToken.Value(); + } + + BundleInfosEntry currentData = new BundleInfosEntry(questDescription, questCount, unlockType, rewardPath, rewardQuantity); + if (!BundleData.Any(item => item.TheQuestDescription.Equals(currentData.TheQuestDescription, StringComparison.InvariantCultureIgnoreCase) && item.TheQuestCount == currentData.TheQuestCount)) + { + BundleData.Add(currentData); + } } } } + else + { + BundleInfosEntry currentData = new BundleInfosEntry(questDescription, questCount, unlockType, "", ""); + if (!BundleData.Any(item => item.TheQuestDescription.Equals(currentData.TheQuestDescription, StringComparison.InvariantCultureIgnoreCase) && item.TheQuestCount == currentData.TheQuestCount)) + { + BundleData.Add(currentData); + } + } } } - - //rewards array to catch the reward name (not path) and the quantity - JArray rewardsDataArray = AssetsUtility.GetPropertyTagText(AssetProperties, "Rewards", "data"); - JArray hiddenRewardsDataArray = AssetsUtility.GetPropertyTagText(AssetProperties, "HiddenRewards", "data"); - JToken rewardsTable = AssetsUtility.GetPropertyTagImport(AssetProperties, "RewardsTable"); - if (rewardsDataArray != null) + } + else if (rewardsTable != null) + { + string rewardsTablePath = AssetEntries.AssetEntriesDict.Where(x => x.Key.ToLowerInvariant().Contains("/" + rewardsTable.Value().ToLowerInvariant() + ".uasset")).Select(d => d.Key).FirstOrDefault(); + if (!string.IsNullOrEmpty(rewardsTablePath)) { - if (rewardsDataArray[0]["struct_name"] != null && rewardsDataArray[0]["struct_type"] != null && string.Equals(rewardsDataArray[0]["struct_name"].Value(), "FortItemQuantityPair")) + jsonData = AssetsUtility.GetAssetJsonDataByPath(rewardsTablePath.Substring(0, rewardsTablePath.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase))); + if (jsonData != null && AssetsUtility.IsValidJson(jsonData)) { - try + JToken AssetRewarsTableMainToken = AssetsUtility.ConvertJson2Token(jsonData); + if (AssetRewarsTableMainToken != null) { - //checking the whole array for the reward - //ignoring all Quest and Token until he find the reward - JToken targetChecker = rewardsDataArray.Where(x => - !string.Equals(x["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][0]["tag_data"].Value(), "Quest") && - !string.Equals(x["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][0]["tag_data"].Value(), "Token")) - .FirstOrDefault()["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][1]["tag_data"]; - - //checking the whole array for the reward quantity - //ignoring all Quest and Token until he find the reward quantity - JToken targetQuantity = rewardsDataArray.Where(x => - !string.Equals(x["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][0]["tag_data"].Value(), "Quest") && - !string.Equals(x["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][0]["tag_data"].Value(), "Token")) - .FirstOrDefault()["struct_type"]["properties"][1]["tag_data"]; - - if (targetChecker != null) + JArray propertiesArray = AssetRewarsTableMainToken["rows"].Value(); + if (propertiesArray != null) { - //this will catch the full path if asset exists to be able to grab his PakReader and List - string primaryAssetNameFullPath = AssetEntries.AssetEntriesDict.Where(x => x.Key.ToLowerInvariant().Contains("/" + targetChecker.Value().ToLowerInvariant() + ".uasset")).Select(d => d.Key).FirstOrDefault(); - if (!string.IsNullOrEmpty(primaryAssetNameFullPath)) + JArray propertiesRewardTable = AssetsUtility.GetPropertyTagItemData(propertiesArray, "Default", "properties"); + if (propertiesRewardTable != null) { - rewardPath = primaryAssetNameFullPath.Substring(0, primaryAssetNameFullPath.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase)); - } - - if (targetQuantity != null) - { - rewardQuantity = targetQuantity.Value(); - } - - BundleInfosEntry currentData = new BundleInfosEntry(questDescription, questCount, unlockType, rewardPath, rewardQuantity); - if (!BundleData.Any(item => item.TheQuestDescription.Equals(currentData.TheQuestDescription, StringComparison.InvariantCultureIgnoreCase) && item.TheQuestCount == currentData.TheQuestCount)) - { - BundleData.Add(currentData); - } - } - else - { - BundleInfosEntry currentData = new BundleInfosEntry(questDescription, questCount, unlockType, "", ""); - if (!BundleData.Any(item => item.TheQuestDescription.Equals(currentData.TheQuestDescription, StringComparison.InvariantCultureIgnoreCase) && item.TheQuestCount == currentData.TheQuestCount)) - { - BundleData.Add(currentData); - } - } - } - catch (Exception) - { - if (hiddenRewardsDataArray != null) - { - if (hiddenRewardsDataArray[0]["struct_name"] != null && hiddenRewardsDataArray[0]["struct_type"] != null && string.Equals(hiddenRewardsDataArray[0]["struct_name"].Value(), "FortHiddenRewardQuantityPair")) - { - JArray hiddenRewardPropertiesArray = hiddenRewardsDataArray[0]["struct_type"]["properties"].Value(); - if (hiddenRewardPropertiesArray != null) + JToken templateIdToken = propertiesRewardTable.FirstOrDefault(item => string.Equals(item["name"].Value(), "TemplateId")); + if (templateIdToken != null) { - JToken templateIdToken = AssetsUtility.GetPropertyTag(hiddenRewardPropertiesArray, "TemplateId"); - if (templateIdToken != null) + string templateId = templateIdToken["tag_data"].Value(); + if (templateId.Contains(":")) + templateId = templateId.Split(':')[1]; + + string templateIdPath = AssetEntries.AssetEntriesDict.Where(x => x.Key.ToLowerInvariant().Contains("/" + templateId.ToLowerInvariant() + ".uasset")).Select(d => d.Key).FirstOrDefault(); + if (!string.IsNullOrEmpty(templateIdPath)) { - rewardPath = templateIdToken.Value(); + rewardPath = templateIdPath.Substring(0, templateIdPath.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase)); } - //reward quantity (if 1, this won't be displayed) - JToken hiddenQuantityToken = AssetsUtility.GetPropertyTag(hiddenRewardPropertiesArray, "Quantity"); - if (hiddenQuantityToken != null) + JToken quantityToken = propertiesRewardTable.FirstOrDefault(item => string.Equals(item["name"].Value(), "Quantity")); + if (quantityToken != null) { - rewardQuantity = hiddenQuantityToken.Value(); + rewardQuantity = quantityToken["tag_data"].Value(); } BundleInfosEntry currentData = new BundleInfosEntry(questDescription, questCount, unlockType, rewardPath, rewardQuantity); @@ -198,95 +247,36 @@ namespace FModel.Methods.Assets.IconCreator.ChallengeID } } } - else - { - BundleInfosEntry currentData = new BundleInfosEntry(questDescription, questCount, unlockType, "", ""); - if (!BundleData.Any(item => item.TheQuestDescription.Equals(currentData.TheQuestDescription, StringComparison.InvariantCultureIgnoreCase) && item.TheQuestCount == currentData.TheQuestCount)) - { - BundleData.Add(currentData); - } - } } } } - else if (rewardsTable != null) + } + else + { + BundleInfosEntry currentData = new BundleInfosEntry(questDescription, questCount, unlockType, "", ""); + if (!BundleData.Any(item => item.TheQuestDescription.Equals(currentData.TheQuestDescription, StringComparison.InvariantCultureIgnoreCase) && item.TheQuestCount == currentData.TheQuestCount)) { - string rewardsTablePath = AssetEntries.AssetEntriesDict.Where(x => x.Key.ToLowerInvariant().Contains("/" + rewardsTable.Value().ToLowerInvariant() + ".uasset")).Select(d => d.Key).FirstOrDefault(); - if (!string.IsNullOrEmpty(rewardsTablePath)) - { - jsonData = AssetsUtility.GetAssetJsonDataByPath(rewardsTablePath.Substring(0, rewardsTablePath.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase))); - if (jsonData != null) - { - if (AssetsUtility.IsValidJson(jsonData)) - { - JToken AssetRewarsTableMainToken = AssetsUtility.ConvertJson2Token(jsonData); - if (AssetRewarsTableMainToken != null) - { - JArray propertiesArray = AssetRewarsTableMainToken["rows"].Value(); - if (propertiesArray != null) - { - JArray propertiesRewardTable = AssetsUtility.GetPropertyTagItemData(propertiesArray, "Default", "properties"); - if (propertiesRewardTable != null) - { - JToken templateIdToken = propertiesRewardTable.Where(item => string.Equals(item["name"].Value(), "TemplateId")).FirstOrDefault(); - if (templateIdToken != null) - { - string templateId = templateIdToken["tag_data"].Value(); - if (templateId.Contains(":")) - templateId = templateId.Split(':')[1]; - - string templateIdPath = AssetEntries.AssetEntriesDict.Where(x => x.Key.ToLowerInvariant().Contains("/" + templateId.ToLowerInvariant() + ".uasset")).Select(d => d.Key).FirstOrDefault(); - if (!string.IsNullOrEmpty(templateIdPath)) - { - rewardPath = templateIdPath.Substring(0, templateIdPath.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase)); - } - - JToken quantityToken = propertiesRewardTable.Where(item => string.Equals(item["name"].Value(), "Quantity")).FirstOrDefault(); - if (quantityToken != null) - { - rewardQuantity = quantityToken["tag_data"].Value(); - } - - BundleInfosEntry currentData = new BundleInfosEntry(questDescription, questCount, unlockType, rewardPath, rewardQuantity); - if (!BundleData.Any(item => item.TheQuestDescription.Equals(currentData.TheQuestDescription, StringComparison.InvariantCultureIgnoreCase) && item.TheQuestCount == currentData.TheQuestCount)) - { - BundleData.Add(currentData); - } - } - } - } - } - } - } - } - } - else - { - BundleInfosEntry currentData = new BundleInfosEntry(questDescription, questCount, unlockType, "", ""); - if (!BundleData.Any(item => item.TheQuestDescription.Equals(currentData.TheQuestDescription, StringComparison.InvariantCultureIgnoreCase) && item.TheQuestCount == currentData.TheQuestCount)) - { - BundleData.Add(currentData); - } + BundleData.Add(currentData); } + } - //catch stage AFTER adding the current quest to the list - if (rewardsDataArray != null) + //catch stage AFTER adding the current quest to the list + if (rewardsDataArray != null) + { + foreach (JToken token in rewardsDataArray) { - foreach (JToken token in rewardsDataArray) + JToken targetChecker = token["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][0]["tag_data"]; + if (targetChecker != null && string.Equals(targetChecker.Value(), "Quest")) { - JToken targetChecker = token["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][0]["tag_data"]; - if (targetChecker != null && string.Equals(targetChecker.Value(), "Quest")) + JToken primaryAssetNameToken = token["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][1]["tag_data"]; + if (primaryAssetNameToken != null) { - JToken primaryAssetNameToken = token["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][1]["tag_data"]; - if (primaryAssetNameToken != null) + //this will catch the full path if asset exists to be able to grab his PakReader and List + string primaryAssetNameFullPath = AssetEntries.AssetEntriesDict.Where(x => x.Key.Contains("/" + primaryAssetNameToken.Value())).Select(d => d.Key).FirstOrDefault(); + if (!string.IsNullOrEmpty(primaryAssetNameFullPath)) { - //this will catch the full path if asset exists to be able to grab his PakReader and List - string primaryAssetNameFullPath = AssetEntries.AssetEntriesDict.Where(x => x.Key.Contains("/" + primaryAssetNameToken.Value())).Select(d => d.Key).FirstOrDefault(); - if (!string.IsNullOrEmpty(primaryAssetNameFullPath)) - { - new UpdateMyProcessEvents(System.IO.Path.GetFileNameWithoutExtension(primaryAssetNameFullPath), "Waiting").Update(); - GetQuestData(BundleProperties, primaryAssetNameFullPath.Substring(0, primaryAssetNameFullPath.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase))); - } + new UpdateMyProcessEvents(System.IO.Path.GetFileNameWithoutExtension(primaryAssetNameFullPath), "Waiting").Update(); + GetQuestData(BundleProperties, primaryAssetNameFullPath.Substring(0, primaryAssetNameFullPath.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase))); } } } diff --git a/FModel/Methods/Assets/IconCreator/ChallengeID/ChallengeCompletionRewards.cs b/FModel/Methods/Assets/IconCreator/ChallengeID/ChallengeCompletionRewards.cs index 0401bafe..6fac7c1d 100644 --- a/FModel/Methods/Assets/IconCreator/ChallengeID/ChallengeCompletionRewards.cs +++ b/FModel/Methods/Assets/IconCreator/ChallengeID/ChallengeCompletionRewards.cs @@ -9,7 +9,7 @@ using FProp = FModel.Properties.Settings; namespace FModel.Methods.Assets.IconCreator.ChallengeID { - class ChallengeCompletionRewards + static class ChallengeCompletionRewards { public static void DrawChallengeCompletion(JArray AssetProperties, SolidColorBrush PrimaryColor, SolidColorBrush SecondaryColor, int y) { diff --git a/FModel/Methods/Assets/IconCreator/ChallengeID/ChallengeIconDesign.cs b/FModel/Methods/Assets/IconCreator/ChallengeID/ChallengeIconDesign.cs index 0de1cdcc..5e28acf0 100644 --- a/FModel/Methods/Assets/IconCreator/ChallengeID/ChallengeIconDesign.cs +++ b/FModel/Methods/Assets/IconCreator/ChallengeID/ChallengeIconDesign.cs @@ -4,14 +4,13 @@ using System; using System.Globalization; using System.IO; using System.Windows; -using System.Windows.Controls; using System.Windows.Media; using System.Windows.Media.Imaging; using FProp = FModel.Properties.Settings; namespace FModel.Methods.Assets.IconCreator.ChallengeID { - class ChallengeIconDesign + static class ChallengeIconDesign { public static bool isBanner { get; set; } public static int y { get; set; } @@ -211,7 +210,7 @@ namespace FModel.Methods.Assets.IconCreator.ChallengeID if (!isBundleLevelup) { IconCreator.ICDrawingContext.DrawRectangle(ChallengesUtility.DarkBrush(PrimaryColor, 0.3f), null, new Rect(0, y, 1024, 40)); - DrawUnlockType(PrimaryColor, SecondaryColor, "/FortniteGame/Content/UI/Foundation/Textures/Icons/Items/T-FNBR-MissionIcon-L", y); + DrawUnlockType(PrimaryColor, "/FortniteGame/Content/UI/Foundation/Textures/Icons/Items/T-FNBR-MissionIcon-L", y); isBundleLevelup = true; y += 40; } @@ -220,7 +219,7 @@ namespace FModel.Methods.Assets.IconCreator.ChallengeID if (!isRequiresBattlePass) { IconCreator.ICDrawingContext.DrawRectangle(ChallengesUtility.DarkBrush(PrimaryColor, 0.3f), null, new Rect(0, y, 1024, 40)); - DrawUnlockType(PrimaryColor, SecondaryColor, "/FortniteGame/Content/UI/Foundation/Textures/Icons/Items/T-FNBR-BattlePass-L", y); + DrawUnlockType(PrimaryColor, "/FortniteGame/Content/UI/Foundation/Textures/Icons/Items/T-FNBR-BattlePass-L", y); isRequiresBattlePass = true; y += 40; } @@ -326,7 +325,7 @@ namespace FModel.Methods.Assets.IconCreator.ChallengeID new UpdateMyConsole("• ------------------------------ •", CColors.White, true).Append(); } - private static void DrawUnlockType(SolidColorBrush PrimaryColor, SolidColorBrush SecondaryColor, string path, int y) + private static void DrawUnlockType(SolidColorBrush PrimaryColor, string path, int y) { Stream image = AssetsUtility.GetStreamImageFromPath(path); if (image != null) diff --git a/FModel/Methods/Assets/IconCreator/ChallengeID/ChallengeRewards.cs b/FModel/Methods/Assets/IconCreator/ChallengeID/ChallengeRewards.cs index ec21b770..4583a89b 100644 --- a/FModel/Methods/Assets/IconCreator/ChallengeID/ChallengeRewards.cs +++ b/FModel/Methods/Assets/IconCreator/ChallengeID/ChallengeRewards.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.Globalization; using System.IO; using System.Linq; @@ -13,8 +10,10 @@ using System.Windows.Media.Imaging; namespace FModel.Methods.Assets.IconCreator.ChallengeID { - class ChallengeRewards + static class ChallengeRewards { + private const string UNKNOWN_ICON = "pack://application:,,,/Resources/unknown512.png"; + public static void DrawRewards(string path, string quantity, int y) { if (!string.IsNullOrEmpty(path)) @@ -64,43 +63,40 @@ namespace FModel.Methods.Assets.IconCreator.ChallengeID if (!string.IsNullOrEmpty(assetPath)) { string jsonData = AssetsUtility.GetAssetJsonDataByPath(assetPath.Substring(0, assetPath.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase))); - if (jsonData != null) + if (jsonData != null && AssetsUtility.IsValidJson(jsonData)) { - if (AssetsUtility.IsValidJson(jsonData)) + JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData); + if (AssetMainToken != null) { - JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData); - if (AssetMainToken != null) + JArray propertiesArray = AssetMainToken["rows"].Value(); + if (propertiesArray != null) { - JArray propertiesArray = AssetMainToken["rows"].Value(); - if (propertiesArray != null) + JArray target = AssetsUtility.GetPropertyTagItemData(propertiesArray, bannerName, "properties"); + if (target != null) { - JArray target = AssetsUtility.GetPropertyTagItemData(propertiesArray, bannerName, "properties"); - if (target != null) + JToken largeImage = target.FirstOrDefault(x => string.Equals(x["name"].Value(), "LargeImage")); + JToken smallImage = target.FirstOrDefault(x => string.Equals(x["name"].Value(), "SmallImage")); + if (largeImage != null || smallImage != null) { - JToken largeImage = target.Where(x => string.Equals(x["name"].Value(), "LargeImage")).FirstOrDefault(); - JToken smallImage = target.Where(x => string.Equals(x["name"].Value(), "SmallImage")).FirstOrDefault(); - if (largeImage != null || smallImage != null) + JToken assetPathName = + largeImage != null ? largeImage["tag_data"]["asset_path_name"] : + smallImage != null ? smallImage["tag_data"]["asset_path_name"] : null; + + if (assetPathName != null) { - JToken assetPathName = - largeImage != null ? largeImage["tag_data"]["asset_path_name"] : - smallImage != null ? smallImage["tag_data"]["asset_path_name"] : null; - - if (assetPathName != null) + string texturePath = FoldersUtility.FixFortnitePath(assetPathName.Value()); + using (Stream image = AssetsUtility.GetStreamImageFromPath(texturePath)) { - string texturePath = FoldersUtility.FixFortnitePath(assetPathName.Value()); - using (Stream image = AssetsUtility.GetStreamImageFromPath(texturePath)) + if (image != null) { - if (image != null) - { - BitmapImage bmp = new BitmapImage(); - bmp.BeginInit(); - bmp.CacheOption = BitmapCacheOption.OnLoad; - bmp.StreamSource = image; - bmp.EndInit(); - bmp.Freeze(); + BitmapImage bmp = new BitmapImage(); + bmp.BeginInit(); + bmp.CacheOption = BitmapCacheOption.OnLoad; + bmp.StreamSource = image; + bmp.EndInit(); + bmp.Freeze(); - IconCreator.ICDrawingContext.DrawImage(bmp, new Rect(902, y + 3, 64, 64)); - } + IconCreator.ICDrawingContext.DrawImage(bmp, new Rect(902, y + 3, 64, 64)); } } } @@ -115,7 +111,7 @@ namespace FModel.Methods.Assets.IconCreator.ChallengeID BitmapImage bmp = new BitmapImage(); bmp.BeginInit(); bmp.CacheOption = BitmapCacheOption.OnLoad; - bmp.StreamSource = Application.GetResourceStream(new Uri("pack://application:,,,/Resources/unknown512.png")).Stream; + bmp.StreamSource = Application.GetResourceStream(new Uri(UNKNOWN_ICON)).Stream; bmp.EndInit(); bmp.Freeze(); IconCreator.ICDrawingContext.DrawImage(bmp, new Rect(902, y + 3, 64, 64)); @@ -174,7 +170,7 @@ namespace FModel.Methods.Assets.IconCreator.ChallengeID BitmapImage bmp = new BitmapImage(); bmp.BeginInit(); bmp.CacheOption = BitmapCacheOption.OnLoad; - bmp.StreamSource = Application.GetResourceStream(new Uri("pack://application:,,,/Resources/unknown512.png")).Stream; + bmp.StreamSource = Application.GetResourceStream(new Uri(UNKNOWN_ICON)).Stream; bmp.EndInit(); bmp.Freeze(); IconCreator.ICDrawingContext.DrawImage(bmp, new Rect(902, y + 3, 64, 64)); @@ -184,24 +180,21 @@ namespace FModel.Methods.Assets.IconCreator.ChallengeID private static void DrawImageFromTagData(string assetPath, string quantity, int y, int mode = 0) { string jsonData = AssetsUtility.GetAssetJsonDataByPath(assetPath); - if (jsonData != null) + if (jsonData != null && AssetsUtility.IsValidJson(jsonData)) { - if (AssetsUtility.IsValidJson(jsonData)) + JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData); + if (AssetMainToken != null) { - JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData); - if (AssetMainToken != null) - { - JArray AssetProperties = AssetMainToken["properties"].Value(); - DrawLargeSmallImage(AssetProperties, quantity, y, mode); - } + JArray AssetProperties = AssetMainToken["properties"].Value(); + DrawLargeSmallImage(AssetProperties, quantity, y, mode); } } } private static void DrawLargeSmallImage(JArray propertiesArray, string quantity, int y, int mode = 0) { - JToken largePreviewImage = propertiesArray.Where(x => string.Equals(x["name"].Value(), "LargePreviewImage")).FirstOrDefault(); - JToken smallPreviewImage = propertiesArray.Where(x => string.Equals(x["name"].Value(), "SmallPreviewImage")).FirstOrDefault(); + JToken largePreviewImage = propertiesArray.FirstOrDefault(x => string.Equals(x["name"].Value(), "LargePreviewImage")); + JToken smallPreviewImage = propertiesArray.FirstOrDefault(x => string.Equals(x["name"].Value(), "SmallPreviewImage")); if (largePreviewImage != null || smallPreviewImage != null) { JToken assetPathName = diff --git a/FModel/Methods/Assets/IconCreator/HeroID/HeroGameplayDefinition.cs b/FModel/Methods/Assets/IconCreator/HeroID/HeroGameplayDefinition.cs index 1b8e2afd..ca21dc1f 100644 --- a/FModel/Methods/Assets/IconCreator/HeroID/HeroGameplayDefinition.cs +++ b/FModel/Methods/Assets/IconCreator/HeroID/HeroGameplayDefinition.cs @@ -1,8 +1,5 @@ using FModel.Methods.Utilities; -using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using PakReader; -using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; @@ -12,7 +9,7 @@ using System.Windows.Media.Imaging; namespace FModel.Methods.Assets.IconCreator.HeroID { - class HeroGameplayDefinition + static class HeroGameplayDefinition { private static int _borderY = 518; private static int _textY = 550; @@ -27,26 +24,23 @@ namespace FModel.Methods.Assets.IconCreator.HeroID if (!string.IsNullOrEmpty(assetPath)) { string jsonData = AssetsUtility.GetAssetJsonDataByPath(assetPath, false, assetPath.Substring(0, assetPath.LastIndexOf("."))); - if (jsonData != null) + if (jsonData != null && AssetsUtility.IsValidJson(jsonData)) { - if (AssetsUtility.IsValidJson(jsonData)) + JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData); + if (AssetMainToken != null) { - JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData); - if (AssetMainToken != null) + JArray heroGameplayProperties = AssetMainToken["properties"].Value(); + if (heroGameplayProperties != null) { - JArray heroGameplayProperties = AssetMainToken["properties"].Value(); - if (heroGameplayProperties != null) - { - _borderY = 518; - _textY = 550; - _imageY = 519; + _borderY = 518; + _textY = 550; + _imageY = 519; - DrawHeroPerk(heroGameplayProperties); - DrawTierAbilityKits(heroGameplayProperties); + DrawHeroPerk(heroGameplayProperties); + DrawTierAbilityKits(heroGameplayProperties); - //RESIZE - IconCreator.ICDrawingContext.DrawRectangle(Brushes.Transparent, null, new Rect(new Point(0, 0), new Size(515, 560 + 35 * 3))); - } + //RESIZE + IconCreator.ICDrawingContext.DrawRectangle(Brushes.Transparent, null, new Rect(new Point(0, 0), new Size(515, 560 + 35 * 3))); } } } @@ -123,72 +117,69 @@ namespace FModel.Methods.Assets.IconCreator.HeroID if (!string.IsNullOrEmpty(assetPath)) { string jsonData = AssetsUtility.GetAssetJsonDataByPath(assetPath); - if (jsonData != null) + if (jsonData != null && AssetsUtility.IsValidJson(jsonData)) { - if (AssetsUtility.IsValidJson(jsonData)) + JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData); + if (AssetMainToken != null) { - JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData); - if (AssetMainToken != null) + JArray abilityKitProperties = AssetMainToken["properties"].Value(); + if (abilityKitProperties != null) { - JArray abilityKitProperties = AssetMainToken["properties"].Value(); - if (abilityKitProperties != null) + JToken name_namespace = AssetsUtility.GetPropertyTagText(abilityKitProperties, "DisplayName", "namespace"); + JToken name_key = AssetsUtility.GetPropertyTagText(abilityKitProperties, "DisplayName", "key"); + JToken name_source_string = AssetsUtility.GetPropertyTagText(abilityKitProperties, "DisplayName", "source_string"); + + JArray iconBrushArray = AssetsUtility.GetPropertyTagStruct(abilityKitProperties, "IconBrush", "properties"); + if (iconBrushArray != null) { - JToken name_namespace = AssetsUtility.GetPropertyTagText(abilityKitProperties, "DisplayName", "namespace"); - JToken name_key = AssetsUtility.GetPropertyTagText(abilityKitProperties, "DisplayName", "key"); - JToken name_source_string = AssetsUtility.GetPropertyTagText(abilityKitProperties, "DisplayName", "source_string"); - - JArray iconBrushArray = AssetsUtility.GetPropertyTagStruct(abilityKitProperties, "IconBrush", "properties"); - if (iconBrushArray != null) + JToken resourceObjectToken = AssetsUtility.GetPropertyTagOuterImport(iconBrushArray, "ResourceObject"); + if (resourceObjectToken != null) { - JToken resourceObjectToken = AssetsUtility.GetPropertyTagOuterImport(iconBrushArray, "ResourceObject"); - if (resourceObjectToken != null) + string texturePath = FoldersUtility.FixFortnitePath(resourceObjectToken.Value()); + using (Stream image = AssetsUtility.GetStreamImageFromPath(texturePath)) { - string texturePath = FoldersUtility.FixFortnitePath(resourceObjectToken.Value()); - using (Stream image = AssetsUtility.GetStreamImageFromPath(texturePath)) + if (image != null) { - if (image != null) + BitmapImage bmp = new BitmapImage(); + bmp.BeginInit(); + bmp.CacheOption = BitmapCacheOption.OnLoad; + bmp.StreamSource = image; + bmp.EndInit(); + bmp.Freeze(); + + //background + IconCreator.ICDrawingContext.DrawRectangle(new SolidColorBrush(ImagesUtility.ParseColorFromHex("#6D6D6D")), null, new Rect(0, _borderY, 515, 34)); + + if (name_namespace != null && name_key != null && name_source_string != null) { - BitmapImage bmp = new BitmapImage(); - bmp.BeginInit(); - bmp.CacheOption = BitmapCacheOption.OnLoad; - bmp.StreamSource = image; - bmp.EndInit(); - bmp.Freeze(); + string displayName = AssetTranslations.SearchTranslation(name_namespace.Value(), name_key.Value(), name_source_string.Value()); - //background - IconCreator.ICDrawingContext.DrawRectangle(new SolidColorBrush(ImagesUtility.ParseColorFromHex("#6D6D6D")), null, new Rect(0, _borderY, 515, 34)); + Typeface typeface = new Typeface(TextsUtility.FBurbank, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal); - if (name_namespace != null && name_key != null && name_source_string != null) - { - string displayName = AssetTranslations.SearchTranslation(name_namespace.Value(), name_key.Value(), name_source_string.Value()); + FormattedText formattedText = + new FormattedText( + displayName.ToUpperInvariant(), + CultureInfo.CurrentUICulture, + FlowDirection.LeftToRight, + typeface, + 25, + Brushes.White, + IconCreator.PPD + ); + formattedText.TextAlignment = TextAlignment.Left; + formattedText.MaxTextWidth = 515; + formattedText.MaxLineCount = 1; - Typeface typeface = new Typeface(TextsUtility.FBurbank, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal); + Point textLocation = new Point(50, _textY - formattedText.Height); - FormattedText formattedText = - new FormattedText( - displayName.ToUpperInvariant(), - CultureInfo.CurrentUICulture, - FlowDirection.LeftToRight, - typeface, - 25, - Brushes.White, - IconCreator.PPD - ); - formattedText.TextAlignment = TextAlignment.Left; - formattedText.MaxTextWidth = 515; - formattedText.MaxLineCount = 1; - - Point textLocation = new Point(50, _textY - formattedText.Height); - - IconCreator.ICDrawingContext.DrawText(formattedText, textLocation); - } - - IconCreator.ICDrawingContext.DrawImage(bmp, new Rect(9, _imageY, 32, 32)); - - _borderY += 37; - _textY += 37; - _imageY += 37; + IconCreator.ICDrawingContext.DrawText(formattedText, textLocation); } + + IconCreator.ICDrawingContext.DrawImage(bmp, new Rect(9, _imageY, 32, 32)); + + _borderY += 37; + _textY += 37; + _imageY += 37; } } } diff --git a/FModel/Methods/Assets/IconCreator/IconImage.cs b/FModel/Methods/Assets/IconCreator/IconImage.cs index e41bca41..de791072 100644 --- a/FModel/Methods/Assets/IconCreator/IconImage.cs +++ b/FModel/Methods/Assets/IconCreator/IconImage.cs @@ -68,24 +68,21 @@ namespace FModel.Methods.Assets.IconCreator private static void DrawImageFromTagData(string assetPath) { string jsonData = AssetsUtility.GetAssetJsonDataByPath(assetPath); - if (jsonData != null) + if (jsonData != null && AssetsUtility.IsValidJson(jsonData)) { - if (AssetsUtility.IsValidJson(jsonData)) + JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData); + if (AssetMainToken != null) { - JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData); - if (AssetMainToken != null) - { - JArray AssetProperties = AssetMainToken["properties"].Value(); - DrawLargeSmallImage(AssetProperties); - } + JArray AssetProperties = AssetMainToken["properties"].Value(); + DrawLargeSmallImage(AssetProperties); } } } private static void DrawLargeSmallImage(JArray propertiesArray) { - JToken largePreviewImage = propertiesArray.Where(x => string.Equals(x["name"].Value(), "LargePreviewImage")).FirstOrDefault(); - JToken smallPreviewImage = propertiesArray.Where(x => string.Equals(x["name"].Value(), "SmallPreviewImage")).FirstOrDefault(); + JToken largePreviewImage = propertiesArray.FirstOrDefault(x => string.Equals(x["name"].Value(), "LargePreviewImage")); + JToken smallPreviewImage = propertiesArray.FirstOrDefault(x => string.Equals(x["name"].Value(), "SmallPreviewImage")); if (largePreviewImage != null || smallPreviewImage != null) { JToken assetPathName = @@ -138,34 +135,31 @@ namespace FModel.Methods.Assets.IconCreator private static void DrawFeaturedImage(JArray AssetProperties, string displayAssetPath) { string jsonData = AssetsUtility.GetAssetJsonDataByPath(displayAssetPath); - if (jsonData != null) + if (jsonData != null && AssetsUtility.IsValidJson(jsonData)) { - if (AssetsUtility.IsValidJson(jsonData)) - { - FWindow.FCurrentAsset = Path.GetFileName(displayAssetPath); + FWindow.FCurrentAsset = Path.GetFileName(displayAssetPath); - JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData); - if (AssetMainToken != null) + JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData); + if (AssetMainToken != null) + { + JArray displayAssetProperties = AssetMainToken["properties"].Value(); + switch (displayAssetPath.Substring(displayAssetPath.LastIndexOf("/", StringComparison.InvariantCultureIgnoreCase) + 1)) { - JArray displayAssetProperties = AssetMainToken["properties"].Value(); - switch (displayAssetPath.Substring(displayAssetPath.LastIndexOf("/", StringComparison.InvariantCultureIgnoreCase) + 1)) - { - case "DA_Featured_Glider_ID_070_DarkViking": - case "DA_Featured_CID_319_Athena_Commando_F_Nautilus": - JArray TileImageProperties = AssetsUtility.GetPropertyTagStruct(displayAssetProperties, "TileImage", "properties"); - if (TileImageProperties != null) - { - DrawFeaturedImageFromDisplayAssetProperty(AssetProperties, TileImageProperties); - } - break; - default: - JArray DetailsImageProperties = AssetsUtility.GetPropertyTagStruct(displayAssetProperties, "DetailsImage", "properties"); - if (DetailsImageProperties != null) - { - DrawFeaturedImageFromDisplayAssetProperty(AssetProperties, DetailsImageProperties); - } - break; - } + case "DA_Featured_Glider_ID_070_DarkViking": + case "DA_Featured_CID_319_Athena_Commando_F_Nautilus": + JArray TileImageProperties = AssetsUtility.GetPropertyTagStruct(displayAssetProperties, "TileImage", "properties"); + if (TileImageProperties != null) + { + DrawFeaturedImageFromDisplayAssetProperty(AssetProperties, TileImageProperties); + } + break; + default: + JArray DetailsImageProperties = AssetsUtility.GetPropertyTagStruct(displayAssetProperties, "DetailsImage", "properties"); + if (DetailsImageProperties != null) + { + DrawFeaturedImageFromDisplayAssetProperty(AssetProperties, DetailsImageProperties); + } + break; } } } @@ -209,52 +203,46 @@ namespace FModel.Methods.Assets.IconCreator { //this will catch the full path if asset exists to be able to grab his PakReader and List string renderSwitchPath = AssetEntries.AssetEntriesDict.Where(x => x.Key.Contains("/" + resourceObjectImportToken.Value())).Select(d => d.Key).FirstOrDefault(); - if (!string.IsNullOrEmpty(renderSwitchPath)) + if (!string.IsNullOrEmpty(renderSwitchPath) && (renderSwitchPath.Contains("MI_UI_FeaturedRenderSwitch_") || + renderSwitchPath.Contains("M-Wraps-StreetDemon") || + renderSwitchPath.Contains("/FortniteGame/Content/UI/Foundation/Textures/Icons/Wraps/FeaturedMaterials/"))) { - if (renderSwitchPath.Contains("MI_UI_FeaturedRenderSwitch_") || - renderSwitchPath.Contains("M-Wraps-StreetDemon") || - renderSwitchPath.Contains("/FortniteGame/Content/UI/Foundation/Textures/Icons/Wraps/FeaturedMaterials/")) + string jsonData = AssetsUtility.GetAssetJsonDataByPath(renderSwitchPath.Substring(0, renderSwitchPath.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase))); + if (jsonData != null && AssetsUtility.IsValidJson(jsonData)) { - string jsonData = AssetsUtility.GetAssetJsonDataByPath(renderSwitchPath.Substring(0, renderSwitchPath.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase))); - if (jsonData != null) + JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData); + if (AssetMainToken != null) { - if (AssetsUtility.IsValidJson(jsonData)) + JArray renderSwitchProperties = AssetMainToken["properties"].Value(); + if (renderSwitchProperties != null) { - JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData); - if (AssetMainToken != null) + JArray textureParameterArray = AssetsUtility.GetPropertyTagText(renderSwitchProperties, "TextureParameterValues", "data"); + textureParameterArray = textureParameterArray[textureParameterArray.Count() > 1 && !AssetsLoader.ExportType.Equals("AthenaItemWrapDefinition") ? 1 : 0]["struct_type"]["properties"].Value(); + if (textureParameterArray != null) { - JArray renderSwitchProperties = AssetMainToken["properties"].Value(); - if (renderSwitchProperties != null) + JToken parameterValueToken = AssetsUtility.GetPropertyTagOuterImport(textureParameterArray, "ParameterValue"); + if (parameterValueToken != null) { - JArray textureParameterArray = AssetsUtility.GetPropertyTagText(renderSwitchProperties, "TextureParameterValues", "data"); - textureParameterArray = textureParameterArray[textureParameterArray.Count() > 1 && !AssetsLoader.ExportType.Equals("AthenaItemWrapDefinition") ? 1 : 0]["struct_type"]["properties"].Value(); - if (textureParameterArray != null) + string texturePath = FoldersUtility.FixFortnitePath(parameterValueToken.Value()); + using (Stream image = AssetsUtility.GetStreamImageFromPath(texturePath)) { - JToken parameterValueToken = AssetsUtility.GetPropertyTagOuterImport(textureParameterArray, "ParameterValue"); - if (parameterValueToken != null) + if (image != null) { - string texturePath = FoldersUtility.FixFortnitePath(parameterValueToken.Value()); - using (Stream image = AssetsUtility.GetStreamImageFromPath(texturePath)) - { - if (image != null) - { - BitmapImage bmp = new BitmapImage(); - bmp.BeginInit(); - bmp.CacheOption = BitmapCacheOption.OnLoad; - bmp.StreamSource = image; - bmp.EndInit(); - bmp.Freeze(); + 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)); - } - } - - if (AssetsLoader.ExportType == "AthenaItemWrapDefinition" && texturePath.Contains("WeaponRenders")) - { - DrawAdditionalWrapImage(AssetProperties); - } + IconCreator.ICDrawingContext.DrawImage(bmp, new Rect(3, 3, 509, 509)); } } + + if (AssetsLoader.ExportType == "AthenaItemWrapDefinition" && texturePath.Contains("WeaponRenders")) + { + DrawAdditionalWrapImage(AssetProperties); + } } } } @@ -266,8 +254,8 @@ namespace FModel.Methods.Assets.IconCreator private static void DrawAdditionalWrapImage(JArray AssetProperties) { - JToken largePreviewImage = AssetProperties.Where(x => string.Equals(x["name"].Value(), "LargePreviewImage")).FirstOrDefault(); - JToken smallPreviewImage = AssetProperties.Where(x => string.Equals(x["name"].Value(), "SmallPreviewImage")).FirstOrDefault(); + JToken largePreviewImage = AssetProperties.FirstOrDefault(x => string.Equals(x["name"].Value(), "LargePreviewImage")); + JToken smallPreviewImage = AssetProperties.FirstOrDefault(x => string.Equals(x["name"].Value(), "SmallPreviewImage")); if (largePreviewImage != null || smallPreviewImage != null) { JToken assetPathName = diff --git a/FModel/Methods/Assets/IconCreator/Rarity.cs b/FModel/Methods/Assets/IconCreator/Rarity.cs index 003b01da..1e7e490b 100644 --- a/FModel/Methods/Assets/IconCreator/Rarity.cs +++ b/FModel/Methods/Assets/IconCreator/Rarity.cs @@ -152,9 +152,7 @@ namespace FModel.Methods.Assets.IconCreator 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 + DrawWithInGameColors(colorsArray, string.Equals(seriesFullPath, "/FortniteGame/Content/Athena/Items/Cosmetics/Series/MarvelSeries.uasset")); //REVERSE COLORS IF MARVEL BECAUSE IT LOOKS WEIRD } JToken backgroundTextureToken = AssetsUtility.GetPropertyTagText(propertiesArray, "BackgroundTexture", "asset_path_name"); diff --git a/FModel/Methods/Assets/IconCreator/WeaponID/IconAmmoData.cs b/FModel/Methods/Assets/IconCreator/WeaponID/IconAmmoData.cs index c47753f7..25dd593b 100644 --- a/FModel/Methods/Assets/IconCreator/WeaponID/IconAmmoData.cs +++ b/FModel/Methods/Assets/IconCreator/WeaponID/IconAmmoData.cs @@ -1,8 +1,6 @@ using FModel.Methods.Utilities; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using PakReader; -using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; @@ -12,76 +10,73 @@ using System.Windows.Media.Imaging; namespace FModel.Methods.Assets.IconCreator.WeaponID { - class IconAmmoData + static class IconAmmoData { public static void DrawIconAmmoData(string path) { string jsonData = AssetsUtility.GetAssetJsonDataByPath(path); - if (jsonData != null) + if (jsonData != null && AssetsUtility.IsValidJson(jsonData)) { - if (AssetsUtility.IsValidJson(jsonData)) + dynamic AssetData = JsonConvert.DeserializeObject(jsonData); + JToken AssetAmmo = JArray.FromObject(AssetData)[0]; + + JToken largePreviewImage = AssetAmmo["properties"].Value().FirstOrDefault(x => string.Equals(x["name"].Value(), "LargePreviewImage")); + JToken smallPreviewImage = AssetAmmo["properties"].Value().FirstOrDefault(x => string.Equals(x["name"].Value(), "SmallPreviewImage")); + if (largePreviewImage != null || smallPreviewImage != null) { - dynamic AssetData = JsonConvert.DeserializeObject(jsonData); - JToken AssetAmmo = JArray.FromObject(AssetData)[0]; + JToken assetPathName = + largePreviewImage != null ? largePreviewImage["tag_data"]["asset_path_name"] : + smallPreviewImage != null ? smallPreviewImage["tag_data"]["asset_path_name"] : null; - JToken largePreviewImage = AssetAmmo["properties"].Value().Where(x => string.Equals(x["name"].Value(), "LargePreviewImage")).FirstOrDefault(); - JToken smallPreviewImage = AssetAmmo["properties"].Value().Where(x => string.Equals(x["name"].Value(), "SmallPreviewImage")).FirstOrDefault(); - if (largePreviewImage != null || smallPreviewImage != null) + if (assetPathName != null) { - JToken assetPathName = - largePreviewImage != null ? largePreviewImage["tag_data"]["asset_path_name"] : - smallPreviewImage != null ? smallPreviewImage["tag_data"]["asset_path_name"] : null; - - if (assetPathName != null) + string texturePath = FoldersUtility.FixFortnitePath(assetPathName.Value()); + using (Stream image = AssetsUtility.GetStreamImageFromPath(texturePath)) { - string texturePath = FoldersUtility.FixFortnitePath(assetPathName.Value()); - using (Stream image = AssetsUtility.GetStreamImageFromPath(texturePath)) + if (image != null) { - if (image != null) + BitmapImage bmp = new BitmapImage(); + bmp.BeginInit(); + bmp.CacheOption = BitmapCacheOption.OnLoad; + bmp.StreamSource = image; + bmp.EndInit(); + bmp.Freeze(); + + //RESIZE + IconCreator.ICDrawingContext.DrawRectangle(Brushes.Transparent, null, new Rect(new Point(0, 0), new Size(515, 560))); + + //background + IconCreator.ICDrawingContext.DrawRectangle(new SolidColorBrush(ImagesUtility.ParseColorFromHex("#6D6D6D")), null, new Rect(0, 518, 515, 34)); + + JToken name_namespace = AssetsUtility.GetPropertyTagText(AssetAmmo["properties"].Value(), "DisplayName", "namespace"); + JToken name_key = AssetsUtility.GetPropertyTagText(AssetAmmo["properties"].Value(), "DisplayName", "key"); + JToken name_source_string = AssetsUtility.GetPropertyTagText(AssetAmmo["properties"].Value(), "DisplayName", "source_string"); + if (name_namespace != null && name_key != null && name_source_string != null) { - BitmapImage bmp = new BitmapImage(); - bmp.BeginInit(); - bmp.CacheOption = BitmapCacheOption.OnLoad; - bmp.StreamSource = image; - bmp.EndInit(); - bmp.Freeze(); + string displayName = AssetTranslations.SearchTranslation(name_namespace.Value(), name_key.Value(), name_source_string.Value()); - //RESIZE - IconCreator.ICDrawingContext.DrawRectangle(Brushes.Transparent, null, new Rect(new Point(0, 0), new Size(515, 560))); + Typeface typeface = new Typeface(TextsUtility.FBurbank, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal); - //background - IconCreator.ICDrawingContext.DrawRectangle(new SolidColorBrush(ImagesUtility.ParseColorFromHex("#6D6D6D")), null, new Rect(0, 518, 515, 34)); + FormattedText formattedText = + new FormattedText( + displayName.ToUpperInvariant(), + CultureInfo.CurrentUICulture, + FlowDirection.LeftToRight, + typeface, + 25, + Brushes.White, + IconCreator.PPD + ); + formattedText.TextAlignment = TextAlignment.Center; + formattedText.MaxTextWidth = 515; + formattedText.MaxLineCount = 1; - JToken name_namespace = AssetsUtility.GetPropertyTagText(AssetAmmo["properties"].Value(), "DisplayName", "namespace"); - JToken name_key = AssetsUtility.GetPropertyTagText(AssetAmmo["properties"].Value(), "DisplayName", "key"); - JToken name_source_string = AssetsUtility.GetPropertyTagText(AssetAmmo["properties"].Value(), "DisplayName", "source_string"); - if (name_namespace != null && name_key != null && name_source_string != null) - { - string displayName = AssetTranslations.SearchTranslation(name_namespace.Value(), name_key.Value(), name_source_string.Value()); + Point textLocation = new Point(0, 550 - formattedText.Height); - Typeface typeface = new Typeface(TextsUtility.FBurbank, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal); - - FormattedText formattedText = - new FormattedText( - displayName.ToUpperInvariant(), - CultureInfo.CurrentUICulture, - FlowDirection.LeftToRight, - typeface, - 25, - Brushes.White, - IconCreator.PPD - ); - formattedText.TextAlignment = TextAlignment.Center; - formattedText.MaxTextWidth = 515; - formattedText.MaxLineCount = 1; - - Point textLocation = new Point(0, 550 - formattedText.Height); - - IconCreator.ICDrawingContext.DrawText(formattedText, textLocation); - } - - IconCreator.ICDrawingContext.DrawImage(bmp, new Rect(9, 519, 32, 32)); + IconCreator.ICDrawingContext.DrawText(formattedText, textLocation); } + + IconCreator.ICDrawingContext.DrawImage(bmp, new Rect(9, 519, 32, 32)); } } } diff --git a/FModel/Methods/Assets/IconCreator/WeaponID/WeaponStats.cs b/FModel/Methods/Assets/IconCreator/WeaponID/WeaponStats.cs index 8378412f..934d51b7 100644 --- a/FModel/Methods/Assets/IconCreator/WeaponID/WeaponStats.cs +++ b/FModel/Methods/Assets/IconCreator/WeaponID/WeaponStats.cs @@ -1,9 +1,7 @@ using FModel.Methods.Utilities; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using PakReader; using System; -using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Windows; @@ -12,9 +10,12 @@ using System.Windows.Media.Imaging; namespace FModel.Methods.Assets.IconCreator.WeaponID { - class WeaponStats + static class WeaponStats { private static JArray WeaponsStatsArray { get; set; } + private const string RELOAD_CUSTOM_ICON = "pack://application:,,,/Resources/reload64.png"; + private const string MAGSIZE_CUSTOM_ICON = "pack://application:,,,/Resources/clipSize64.png"; + private const string DAMAGE_CUSTOM_ICON = "pack://application:,,,/Resources/dmg64.png"; public static void DrawWeaponStats(string file, string rowname) { @@ -25,15 +26,12 @@ namespace FModel.Methods.Assets.IconCreator.WeaponID if (!string.IsNullOrEmpty(filepath)) { string jsonData = AssetsUtility.GetAssetJsonDataByPath(filepath.Substring(0, filepath.LastIndexOf(".")), true); - if (jsonData != null) + if (jsonData != null && AssetsUtility.IsValidJson(jsonData)) { - if (AssetsUtility.IsValidJson(jsonData)) - { - dynamic AssetData = JsonConvert.DeserializeObject(jsonData); - JArray AssetArray = JArray.FromObject(AssetData); - WeaponsStatsArray = AssetArray[0]["rows"].Value(); - SearchWeaponStats(rowname); - } + dynamic AssetData = JsonConvert.DeserializeObject(jsonData); + JArray AssetArray = JArray.FromObject(AssetData); + WeaponsStatsArray = AssetArray[0]["rows"].Value(); + SearchWeaponStats(rowname); } } } @@ -63,7 +61,7 @@ namespace FModel.Methods.Assets.IconCreator.WeaponID BitmapImage bmp = new BitmapImage(); bmp.BeginInit(); bmp.CacheOption = BitmapCacheOption.OnLoad; - bmp.UriSource = new Uri("pack://application:,,,/Resources/reload64.png"); + bmp.UriSource = new Uri(RELOAD_CUSTOM_ICON); bmp.EndInit(); bmp.Freeze(); @@ -97,7 +95,7 @@ namespace FModel.Methods.Assets.IconCreator.WeaponID BitmapImage bmp = new BitmapImage(); bmp.BeginInit(); bmp.CacheOption = BitmapCacheOption.OnLoad; - bmp.UriSource = new Uri("pack://application:,,,/Resources/clipSize64.png"); + bmp.UriSource = new Uri(MAGSIZE_CUSTOM_ICON); bmp.EndInit(); bmp.Freeze(); @@ -131,7 +129,7 @@ namespace FModel.Methods.Assets.IconCreator.WeaponID BitmapImage bmp = new BitmapImage(); bmp.BeginInit(); bmp.CacheOption = BitmapCacheOption.OnLoad; - bmp.UriSource = new Uri("pack://application:,,,/Resources/dmg64.png"); + bmp.UriSource = new Uri(DAMAGE_CUSTOM_ICON); bmp.EndInit(); bmp.Freeze(); diff --git a/FModel/Methods/PAKs/PAKsLoader.cs b/FModel/Methods/PAKs/PAKsLoader.cs index 15f7867d..2be8358a 100644 --- a/FModel/Methods/PAKs/PAKsLoader.cs +++ b/FModel/Methods/PAKs/PAKsLoader.cs @@ -301,7 +301,7 @@ namespace FModel.Methods.PAKs //FILTER WITH THE OVERRIDED EQUALS METHOD (CHECKING FILE NAME AND FILE UNCOMPRESSED SIZE) DebugHelper.WriteLine($".PAKs: Comparing...\t File Size Check: {FProp.Default.FDiffFileSize}"); - IEnumerable newAssets = LocalEntries.ToArray().Except(BackupEntries); + IEnumerable newAssets = LocalEntries.Except(BackupEntries); DebugHelper.WriteLine(".PAKs: Compared"); //ADD TO TREE diff --git a/FModel/Methods/PAKs/RegisterFromPath.cs b/FModel/Methods/PAKs/RegisterFromPath.cs index c250be8b..1d8ccb65 100644 --- a/FModel/Methods/PAKs/RegisterFromPath.cs +++ b/FModel/Methods/PAKs/RegisterFromPath.cs @@ -12,12 +12,9 @@ namespace FModel.Methods.PAKs { static class RegisterFromPath { - public static string PAK_PATH = FProp.Default.FPak_Path; - private static string datFilePath = string.Empty; - public static void FilterPAKs() { - if (string.IsNullOrEmpty(FProp.Default.FPak_Path) && !string.IsNullOrEmpty(datFilePath)) + if (string.IsNullOrEmpty(FProp.Default.FPak_Path)) { string AutoPath = GetGameInstallLocation(); if (!string.IsNullOrEmpty(AutoPath)) @@ -28,12 +25,10 @@ namespace FModel.Methods.PAKs FProp.Default.FPak_Path = AutoPath; FProp.Default.Save(); - - PAK_PATH = FProp.Default.FPak_Path; } } - if (Directory.Exists(PAK_PATH)) + if (Directory.Exists(FProp.Default.FPak_Path)) { PAKEntries.PAKEntriesList = new List(); foreach (string Pak in GetPAKsFromPath()) @@ -43,7 +38,7 @@ namespace FModel.Methods.PAKs 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)); + PAKEntries.PAKEntriesList.Add(new PAKInfosEntry(Pak, PAKGuid, !string.Equals(PAKGuid, "0-0-0-0"))); FWindow.FMain.Dispatcher.InvokeAsync(() => { MenuItem MI_Pak = new MenuItem(); @@ -74,24 +69,34 @@ namespace FModel.Methods.PAKs private static IEnumerable GetPAKsFromPath() { - return Directory.GetFiles(PAK_PATH, "*.pak", SearchOption.AllDirectories); + return Directory.GetFiles(FProp.Default.FPak_Path, "*.pak", SearchOption.AllDirectories); + } + + private static string GetEpicDirectory() + { + foreach (DriveInfo drive in DriveInfo.GetDrives()) + { + string path = $"{drive.Name}ProgramData\\Epic"; + if (Directory.Exists(path)) + { + return path; + } + } + return string.Empty; } - private static string GetEpicDirectory() => Directory.Exists(@"C:\ProgramData\Epic") ? @"C:\ProgramData\Epic" : Directory.Exists(@"D:\ProgramData\Epic") ? @"D:\ProgramData\Epic" : @"E:\ProgramData\Epic"; private static string GetDatFile() { - if (!string.IsNullOrEmpty(datFilePath)) - return datFilePath; - - if (File.Exists($@"{GetEpicDirectory()}\UnrealEngineLauncher\LauncherInstalled.dat")) + string ePath = $"{GetEpicDirectory()}\\UnrealEngineLauncher\\LauncherInstalled.dat"; + if (File.Exists(ePath)) { - datFilePath = $@"{GetEpicDirectory()}\UnrealEngineLauncher\LauncherInstalled.dat"; - DebugHelper.WriteLine("EPIC .dat file at " + datFilePath); + DebugHelper.WriteLine("EPIC .dat file at " + ePath); + return ePath; } else DebugHelper.WriteLine("EPIC .dat file not found"); - return datFilePath; + return string.Empty; } private static string GetGameInstallLocation() @@ -105,8 +110,8 @@ namespace FModel.Methods.PAKs private static JToken GetGameData() { - GetDatFile(); - if (!string.IsNullOrEmpty(datFilePath)) + string datFilePath = GetDatFile(); + if (!string.IsNullOrEmpty(datFilePath) && File.Exists(datFilePath)) { string jsonData = File.ReadAllText(datFilePath); if (AssetsUtility.IsValidJson(jsonData)) @@ -116,7 +121,7 @@ namespace FModel.Methods.PAKs { JArray installationListArray = games["InstallationList"].Value(); if (installationListArray != null) - return installationListArray.Where(game => string.Equals(game["AppName"].Value(), "Fortnite")).FirstOrDefault(); + return installationListArray.FirstOrDefault(game => string.Equals(game["AppName"].Value(), "Fortnite")); DebugHelper.WriteLine("Fortnite not found in .dat file"); } diff --git a/FModel/Methods/TreeViewModel/TreeViewItemBehavior.cs b/FModel/Methods/TreeViewModel/TreeViewItemBehavior.cs index 8b34d215..c54927d0 100644 --- a/FModel/Methods/TreeViewModel/TreeViewItemBehavior.cs +++ b/FModel/Methods/TreeViewModel/TreeViewItemBehavior.cs @@ -30,7 +30,7 @@ namespace FModel.Methods.TreeViewModel if (item == null) return; - if (e.NewValue is bool == false) + if (!(e.NewValue is bool)) return; if ((bool)e.NewValue) diff --git a/FModel/Methods/Utilities/AssetsUtility.cs b/FModel/Methods/Utilities/AssetsUtility.cs index 815ada86..55f6020c 100644 --- a/FModel/Methods/Utilities/AssetsUtility.cs +++ b/FModel/Methods/Utilities/AssetsUtility.cs @@ -104,7 +104,7 @@ namespace FModel.Methods.Utilities } return toReturn; } - return null; + return new List(); } public static AssetReader GetAssetReader(Stream[] AssetStreamList) @@ -328,7 +328,7 @@ namespace FModel.Methods.Utilities } return bytes.ToArray(); } - return null; + return new byte[0]; } public static Stream GetStreamImageFromPath(string AssetFullPath) @@ -369,7 +369,7 @@ namespace FModel.Methods.Utilities AssetReader ar = GetAssetReader(AssetStreamArray); if (ar != null) { - ExportObject eo = ar.Exports.Where(x => x is Texture2D).FirstOrDefault(); + ExportObject eo = ar.Exports.FirstOrDefault(x => x is Texture2D); if (eo != null) { SKImage image = ((Texture2D)eo).GetImage(); @@ -466,7 +466,7 @@ namespace FModel.Methods.Utilities { try { - JToken obj = JToken.Parse(strInput); + JToken.Parse(strInput); return true; } catch (Exception) diff --git a/FModel/Methods/Utilities/ChallengesUtility.cs b/FModel/Methods/Utilities/ChallengesUtility.cs index 1d09080e..d5174034 100644 --- a/FModel/Methods/Utilities/ChallengesUtility.cs +++ b/FModel/Methods/Utilities/ChallengesUtility.cs @@ -1,18 +1,16 @@ using FModel.Methods.Assets.IconCreator.ChallengeID; -using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using PakReader; using System; -using System.Collections.Generic; using System.IO; using System.Windows; using System.Windows.Media; namespace FModel.Methods.Utilities { - class ChallengesUtility + static class ChallengesUtility { private static readonly Random _Random = new Random(Environment.TickCount); + private const string UNKNOWN_ICON = "pack://application:,,,/Resources/unknown512.png"; private static int RandomNext(int minValue, int maxValue) { @@ -126,25 +124,22 @@ namespace FModel.Methods.Utilities if (string.Equals(path, "/FortniteGame/Content/Athena/UI/Challenges/Art/TileImages/M_UI_ChallengeTile_PCB")) { string jsonData = AssetsUtility.GetAssetJsonDataByPath(path); - if (jsonData != null) + if (jsonData != null && AssetsUtility.IsValidJson(jsonData)) { - if (AssetsUtility.IsValidJson(jsonData)) + JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData); + if (AssetMainToken != null) { - JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData); - if (AssetMainToken != null) + JArray renderSwitchProperties = AssetMainToken["properties"].Value(); + if (renderSwitchProperties != null) { - JArray renderSwitchProperties = AssetMainToken["properties"].Value(); - if (renderSwitchProperties != null) + JArray textureParameterArray = AssetsUtility.GetPropertyTagText(renderSwitchProperties, "TextureParameterValues", "data")[0]["struct_type"]["properties"].Value(); + if (textureParameterArray != null) { - JArray textureParameterArray = AssetsUtility.GetPropertyTagText(renderSwitchProperties, "TextureParameterValues", "data")[0]["struct_type"]["properties"].Value(); - if (textureParameterArray != null) + JToken parameterValueToken = AssetsUtility.GetPropertyTagOuterImport(textureParameterArray, "ParameterValue"); + if (parameterValueToken != null) { - JToken parameterValueToken = AssetsUtility.GetPropertyTagOuterImport(textureParameterArray, "ParameterValue"); - if (parameterValueToken != null) - { - string texturePath = FoldersUtility.FixFortnitePath(parameterValueToken.Value()); - return AssetsUtility.GetStreamImageFromPath(texturePath); - } + string texturePath = FoldersUtility.FixFortnitePath(parameterValueToken.Value()); + return AssetsUtility.GetStreamImageFromPath(texturePath); } } } @@ -156,7 +151,7 @@ namespace FModel.Methods.Utilities return AssetsUtility.GetStreamImageFromPath(path); } } - return Application.GetResourceStream(new Uri("pack://application:,,,/Resources/unknown512.png")).Stream; + return Application.GetResourceStream(new Uri(UNKNOWN_ICON)).Stream; } } } diff --git a/FModel/Methods/Utilities/DebugHelper.cs b/FModel/Methods/Utilities/DebugHelper.cs index a8cda23c..6ac09565 100644 --- a/FModel/Methods/Utilities/DebugHelper.cs +++ b/FModel/Methods/Utilities/DebugHelper.cs @@ -4,7 +4,7 @@ using FProp = FModel.Properties.Settings; namespace FModel.Methods.Utilities { - class DebugHelper + static class DebugHelper { public static Logger Logger { get; private set; } diff --git a/FModel/Methods/Utilities/EndpointsUtility.cs b/FModel/Methods/Utilities/EndpointsUtility.cs index 5745d341..6af4da91 100644 --- a/FModel/Methods/Utilities/EndpointsUtility.cs +++ b/FModel/Methods/Utilities/EndpointsUtility.cs @@ -9,6 +9,9 @@ namespace FModel.Methods.Utilities { static class EndpointsUtility { + private const string DROPBOX_JSON = "https://dl.dropbox.com/s/0ykcue03qweb98r/FModel.json?dl=0"; + private const string BENBOT_AES = "http://benbotfn.tk:8080/api/aes"; + public static string GetEndpoint(string url) { DebugHelper.WriteLine("Sending GET request to " + url); @@ -25,7 +28,7 @@ namespace FModel.Methods.Utilities { if (DLLImport.IsInternetAvailable()) { - string EndpointContent = GetEndpoint("https://dl.dropbox.com/s/0ykcue03qweb98r/FModel.json?dl=0"); + string EndpointContent = GetEndpoint(DROPBOX_JSON); if (!string.IsNullOrEmpty(EndpointContent)) { List ListToReturn = new List(); @@ -62,14 +65,14 @@ namespace FModel.Methods.Utilities { DebugHelper.WriteLine("Dropbox: Error while checking for backup files"); new UpdateMyConsole("Error while checking for backup files", CColors.Red, true).Append(); - return null; + return new List(); } } else { DebugHelper.WriteLine("Dropbox: Your internet connection is currently unavailable, can't check for backup files at the moment."); new UpdateMyConsole("Your internet connection is currently unavailable, can't check for backup files at the moment.", CColors.Blue, true).Append(); - return null; + return new List(); } } @@ -77,7 +80,7 @@ namespace FModel.Methods.Utilities { if (DLLImport.IsInternetAvailable()) { - string EndpointContent = GetEndpoint("http://benbotfn.tk:8080/api/aes"); + string EndpointContent = GetEndpoint(BENBOT_AES); if (!string.IsNullOrEmpty(EndpointContent)) { if (string.IsNullOrEmpty(FProp.Default.FPak_MainAES)) diff --git a/FModel/Methods/Utilities/FormsUtility.cs b/FModel/Methods/Utilities/FormsUtility.cs index 934ecde5..ba74a8ec 100644 --- a/FModel/Methods/Utilities/FormsUtility.cs +++ b/FModel/Methods/Utilities/FormsUtility.cs @@ -14,7 +14,7 @@ namespace FModel.Methods.Utilities public static Window GetOpenedWindow(string name) where T : Window { - return Application.Current.Windows.OfType().Where(w => w.Title.Equals(name)).FirstOrDefault(); + return Application.Current.Windows.OfType().FirstOrDefault(w => w.Title.Equals(name)); } } } diff --git a/FModel/Methods/Utilities/Logger.cs b/FModel/Methods/Utilities/Logger.cs index 147ba85c..40e65fa5 100644 --- a/FModel/Methods/Utilities/Logger.cs +++ b/FModel/Methods/Utilities/Logger.cs @@ -24,8 +24,8 @@ namespace FModel.Methods.Utilities public string LogFilePath { get; private set; } private readonly object loggerLock = new object(); - private ConcurrentQueue messageQueue = new ConcurrentQueue(); - private StringBuilder sbMessages = new StringBuilder(); + private readonly ConcurrentQueue messageQueue = new ConcurrentQueue(); + private readonly StringBuilder sbMessages = new StringBuilder(); public Logger() { @@ -142,7 +142,7 @@ namespace FModel.Methods.Utilities return sbMessages.ToString(); } - return null; + return string.Empty; } } @@ -181,6 +181,7 @@ namespace FModel.Methods.Utilities } catch { + //hello world :) } if (string.IsNullOrEmpty(productName)) diff --git a/FModel/Methods/Utilities/PAKsUtility.cs b/FModel/Methods/Utilities/PAKsUtility.cs index 9d139452..a39e277d 100644 --- a/FModel/Methods/Utilities/PAKsUtility.cs +++ b/FModel/Methods/Utilities/PAKsUtility.cs @@ -72,13 +72,10 @@ namespace FModel.Methods.Utilities { if (AESEntries.AESEntriesList != null && AESEntries.AESEntriesList.Any()) { - AESInfosEntry AESFromManager = AESEntries.AESEntriesList.Where(x => string.Equals(x.ThePAKName, Path.GetFileNameWithoutExtension(Pak.ThePAKPath))).FirstOrDefault(); - if (!string.IsNullOrEmpty(AESFromManager.ThePAKKey)) + AESInfosEntry AESFromManager = AESEntries.AESEntriesList.FirstOrDefault(x => string.Equals(x.ThePAKName, Path.GetFileNameWithoutExtension(Pak.ThePAKPath))); + if (!string.IsNullOrEmpty(AESFromManager.ThePAKKey) && string.Equals(AESFromManager.ThePAKName, Path.GetFileNameWithoutExtension(MI_Pak.Header.ToString()))) { - if (string.Equals(AESFromManager.ThePAKName, Path.GetFileNameWithoutExtension(MI_Pak.Header.ToString()))) - { - MI_Pak.IsEnabled = true; - } + MI_Pak.IsEnabled = true; } } } diff --git a/FModel/Methods/Utilities/TextsUtility.cs b/FModel/Methods/Utilities/TextsUtility.cs index ee3216c3..c40724de 100644 --- a/FModel/Methods/Utilities/TextsUtility.cs +++ b/FModel/Methods/Utilities/TextsUtility.cs @@ -5,7 +5,8 @@ namespace FModel.Methods.Utilities { static class TextsUtility { - public static readonly FontFamily FBurbank = new FontFamily(new Uri("pack://application:,,,/"), "./Resources/#Burbank Big Cd Bd"); - public static readonly FontFamily Burbank = new FontFamily(new Uri("pack://application:,,,/"), "./Resources/#Burbank Big Cd Bk"); + private const string BASE = "pack://application:,,,/"; + public static readonly FontFamily FBurbank = new FontFamily(new Uri(BASE), "./Resources/#Burbank Big Cd Bd"); + public static readonly FontFamily Burbank = new FontFamily(new Uri(BASE), "./Resources/#Burbank Big Cd Bk"); } } diff --git a/FModel/Methods/Utilities/TreeViewUtility.cs b/FModel/Methods/Utilities/TreeViewUtility.cs index 56a55285..bf040abc 100644 --- a/FModel/Methods/Utilities/TreeViewUtility.cs +++ b/FModel/Methods/Utilities/TreeViewUtility.cs @@ -1,5 +1,4 @@ -using FModel.Methods.TreeViewModel; -using System.ComponentModel; +using System.ComponentModel; using System.Text; using System.Windows; using System.Windows.Controls; @@ -99,7 +98,7 @@ namespace FModel.Methods.Utilities } } - done = (found == false && done == false); + done = !found && !done; } } }