From 5c1b235c139c63922aa89bea20265e10d15d1f74 Mon Sep 17 00:00:00 2001 From: iAmAsval Date: Mon, 6 Jan 2020 23:27:43 +0100 Subject: [PATCH] Added Heroes & Weapons' Categories Mini-Icon --- FModel/FModel_Main.xaml | 2 + FModel/FModel_Main.xaml.cs | 8 ++++ .../AthenaID/IconUserFacingFlags.cs | 47 +++++++++++++++++++ FModel/Methods/Assets/IconCreator/IconText.cs | 42 +++++++++++++++++ 4 files changed, 99 insertions(+) diff --git a/FModel/FModel_Main.xaml b/FModel/FModel_Main.xaml index 82f938a4..33ae36c4 100644 --- a/FModel/FModel_Main.xaml +++ b/FModel/FModel_Main.xaml @@ -91,6 +91,8 @@ + + diff --git a/FModel/FModel_Main.xaml.cs b/FModel/FModel_Main.xaml.cs index bda08dd4..8f15354c 100644 --- a/FModel/FModel_Main.xaml.cs +++ b/FModel/FModel_Main.xaml.cs @@ -220,6 +220,14 @@ namespace FModel } else { FormsUtility.GetOpenedWindow("Images Merger").Focus(); } } + private void MI_Changelog_Click(object sender, RoutedEventArgs e) + { + System.Diagnostics.Process.Start("https://github.com/iAmAsval/FModel/releases/latest"); + } + private void MI_BugReports_Click(object sender, RoutedEventArgs e) + { + System.Diagnostics.Process.Start("https://github.com/iAmAsval/FModel/issues/new"); + } private void MI_About_Click(object sender, RoutedEventArgs e) { DebugHelper.WriteLine("FWindow: About"); diff --git a/FModel/Methods/Assets/IconCreator/AthenaID/IconUserFacingFlags.cs b/FModel/Methods/Assets/IconCreator/AthenaID/IconUserFacingFlags.cs index 2159a510..70ef066c 100644 --- a/FModel/Methods/Assets/IconCreator/AthenaID/IconUserFacingFlags.cs +++ b/FModel/Methods/Assets/IconCreator/AthenaID/IconUserFacingFlags.cs @@ -11,6 +11,7 @@ namespace FModel.Methods.Assets.IconCreator.AthenaID static class IconUserFacingFlags { private static JArray ItemCategoriesArray { get; set; } + private static JArray HeroItemCategoriesArray { 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"; @@ -41,6 +42,52 @@ namespace FModel.Methods.Assets.IconCreator.AthenaID } } + public static void DrawHeroFacingFlag(JToken uFF) + { + if (HeroItemCategoriesArray == null) + { + string jsonData = AssetsUtility.GetAssetJsonDataByPath("/FortniteGame/Content/Items/ItemCategories", true); + if (jsonData != null && AssetsUtility.IsValidJson(jsonData)) + { + dynamic AssetData = JsonConvert.DeserializeObject(jsonData); + JArray AssetArray = JArray.FromObject(AssetData); + JToken secondaryCategoriesToken = AssetsUtility.GetPropertyTag(AssetArray[0]["properties"].Value(), "SecondaryCategories"); + if (secondaryCategoriesToken != null) + { + HeroItemCategoriesArray = secondaryCategoriesToken["data"].Value(); + + string uFFTargeted = uFF.Value().Substring("Unlocks.Class.".Length); + SearchHeroFacingFlag(uFFTargeted); + } + } + } + else + { + string uFFTargeted = uFF.Value().Substring("Unlocks.Class.".Length); + SearchHeroFacingFlag(uFFTargeted); + } + } + + private static void SearchHeroFacingFlag(string uFFTarget) + { + foreach (JToken data in HeroItemCategoriesArray) + { + JArray propertiesArray = data["struct_type"]["properties"].Value(); + if (propertiesArray != null) + { + JToken categoryNameToken = AssetsUtility.GetPropertyTagText(propertiesArray, "CategoryName", "source_string"); + if (categoryNameToken != null) + { + if (uFFTarget.Equals("Commando") && categoryNameToken.Value() == "Soldier" || + categoryNameToken.Value().Equals(uFFTarget, StringComparison.InvariantCultureIgnoreCase)) + { + GetUFFImage(propertiesArray); + } + } + } + } + } + private static void SearchUserFacingFlag(string uFFTarget) { foreach (JToken data in ItemCategoriesArray) diff --git a/FModel/Methods/Assets/IconCreator/IconText.cs b/FModel/Methods/Assets/IconCreator/IconText.cs index 3b61e8fa..42de7fa9 100644 --- a/FModel/Methods/Assets/IconCreator/IconText.cs +++ b/FModel/Methods/Assets/IconCreator/IconText.cs @@ -21,7 +21,9 @@ namespace FModel.Methods.Assets.IconCreator private static string _cosmeticItemDefinition; private static string _itemAction; private static string _maxStackSize; + private static string _miniMapIconBrushPath; private static IEnumerable _userFacingFlagsToken; + private static IEnumerable _userHeroFlagsToken; public static void DrawIconText(JArray AssetProperties) { @@ -41,6 +43,7 @@ namespace FModel.Methods.Assets.IconCreator _itemAction = string.Empty; _maxStackSize = string.Empty; _userFacingFlagsToken = null; + _userHeroFlagsToken = null; JToken name_namespace = AssetsUtility.GetPropertyTagText(AssetProperties, "DisplayName", "namespace"); JToken name_key = AssetsUtility.GetPropertyTagText(AssetProperties, "DisplayName", "key"); @@ -59,6 +62,8 @@ namespace FModel.Methods.Assets.IconCreator JToken ammo_data = AssetsUtility.GetPropertyTagText(AssetProperties, "AmmoData", "asset_path_name"); JArray gTagsArray = AssetsUtility.GetPropertyTagStruct(AssetProperties, "GameplayTags", "gameplay_tags"); + JArray hTagsArray = AssetsUtility.GetPropertyTagStruct(AssetProperties, "RequiredGPTags", "gameplay_tags"); + JArray wTagsArray = AssetsUtility.GetPropertyTagStruct(AssetProperties, "MiniMapIconBrush", "properties"); if (name_namespace != null && name_key != null && name_source_string != null) { @@ -134,6 +139,16 @@ namespace FModel.Methods.Assets.IconCreator _userFacingFlagsToken = gTagsArray.Children().Where(x => x.ToString().StartsWith("Cosmetics.UserFacingFlags.")); } + + if (hTagsArray != null) + _userHeroFlagsToken = hTagsArray.Children().Where(x => x.ToString().StartsWith("Unlocks.Class.")); + + if (wTagsArray != null) + { + JToken resourceObjectToken = AssetsUtility.GetPropertyTagOuterImport(wTagsArray, "ResourceObject"); + if (resourceObjectToken != null) + _miniMapIconBrushPath = FoldersUtility.FixFortnitePath(resourceObjectToken.Value()); + } } private static void DrawTextVariables(JArray AssetProperties) @@ -185,6 +200,33 @@ namespace FModel.Methods.Assets.IconCreator } IconUserFacingFlags.xCoords = 4 - 25; //reset uFF coords } + + if (_userHeroFlagsToken != null) + { + foreach (JToken uFF in _userHeroFlagsToken) + { + IconUserFacingFlags.DrawHeroFacingFlag(uFF); + } + IconUserFacingFlags.xCoords = 4 - 25; //reset uFF coords + } + + if (!string.IsNullOrEmpty(_miniMapIconBrushPath)) + using (System.IO.Stream image = AssetsUtility.GetStreamImageFromPath(_miniMapIconBrushPath)) + { + if (image != null) + { + System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage(); + bmp.BeginInit(); + bmp.CacheOption = System.Windows.Media.Imaging.BitmapCacheOption.OnLoad; + bmp.StreamSource = image; + bmp.EndInit(); + bmp.Freeze(); + + IconUserFacingFlags.xCoords += 25; + IconCreator.ICDrawingContext.DrawImage(bmp, new Rect(IconUserFacingFlags.xCoords, 4, 25, 25)); + IconUserFacingFlags.xCoords = 4 - 25; //reset uFF coords + } + } } private static void DrawDisplayName(string DisplayName)