Example #1
0
        public static void GetHeroPerk(JArray AssetProperties)
        {
            JToken heroGameplayDefinitionToken = AssetsUtility.GetPropertyTagImport <JToken>(AssetProperties, "HeroGameplayDefinition");

            if (heroGameplayDefinitionToken != null)
            {
                string assetPath = AssetEntries.AssetEntriesDict.Where(x => x.Key.ToLowerInvariant().Contains("/" + heroGameplayDefinitionToken.Value <string>().ToLowerInvariant() + ".")).Select(d => d.Key).FirstOrDefault();
                if (!string.IsNullOrEmpty(assetPath))
                {
                    string jsonData = AssetsUtility.GetAssetJsonDataByPath(assetPath, false, assetPath.Substring(0, assetPath.LastIndexOf(".")));
                    if (jsonData != null && AssetsUtility.IsValidJson(jsonData))
                    {
                        JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData);
                        if (AssetMainToken != null)
                        {
                            JArray heroGameplayProperties = AssetMainToken["properties"].Value <JArray>();
                            if (heroGameplayProperties != null)
                            {
                                _borderY = 518;
                                _textY   = 550;
                                _imageY  = 519;

                                DrawHeroPerk(heroGameplayProperties);
                                DrawTierAbilityKits(heroGameplayProperties);

                                //RESIZE
                                IconCreator.ICDrawingContext.DrawRectangle(Brushes.Transparent, null, new Rect(new Point(0, 0), new Size(515, 560 + 35 * 3)));
                            }
                        }
                    }
                }
            }
        }
Example #2
0
        private static void DrawNormalIcon(string path, string quantity, int y, int mode = 0)
        {
            string jsonData = AssetsUtility.GetAssetJsonDataByPath(path);

            if (jsonData != null)
            {
                if (AssetsUtility.IsValidJson(jsonData))
                {
                    JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData);
                    if (AssetMainToken != null)
                    {
                        JArray propertiesArray = AssetMainToken["properties"].Value <JArray>();
                        if (propertiesArray != null)
                        {
                            JToken heroToken   = AssetsUtility.GetPropertyTagImport <JToken>(propertiesArray, "HeroDefinition");
                            JToken weaponToken = AssetsUtility.GetPropertyTagImport <JToken>(propertiesArray, "WeaponDefinition");
                            if (heroToken != null)
                            {
                                //this will catch the full path if asset exists to be able to grab his PakReader and List<FPakEntry>
                                string assetPath = AssetEntries.AssetEntriesDict.Where(x => x.Key.ToLowerInvariant().Contains("/" + heroToken.Value <string>().ToLowerInvariant() + ".uasset")).Select(d => d.Key).FirstOrDefault();
                                if (!string.IsNullOrEmpty(assetPath))
                                {
                                    DrawImageFromTagData(assetPath.Substring(0, assetPath.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase)), quantity, y, mode);
                                }
                            }
                            else if (weaponToken != null)
                            {
                                string weaponName = weaponToken.Value <string>();
                                if (weaponToken.Value <string>().Equals("WID_Harvest_Pickaxe_STWCosmetic_Tier")) //STW PICKAXES MANUAL FIX
                                {
                                    weaponName = "WID_Harvest_Pickaxe_STWCosmetic_Tier_" + FWindow.FCurrentAsset.Substring(FWindow.FCurrentAsset.Length - 1);
                                }

                                //this will catch the full path if asset exists to be able to grab his PakReader and List<FPakEntry>
                                string assetPath = AssetEntries.AssetEntriesDict.Where(x => x.Key.ToLowerInvariant().Contains("/" + weaponName.ToLowerInvariant() + ".uasset")).Select(d => d.Key).FirstOrDefault();
                                if (!string.IsNullOrEmpty(assetPath))
                                {
                                    DrawImageFromTagData(assetPath.Substring(0, assetPath.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase)), quantity, y, mode);
                                }
                            }
                            else
                            {
                                DrawLargeSmallImage(propertiesArray, quantity, y, mode);
                            }
                        }
                    }
                }
            }
            else
            {
                BitmapImage bmp = new BitmapImage();
                bmp.BeginInit();
                bmp.CacheOption  = BitmapCacheOption.OnLoad;
                bmp.StreamSource = Application.GetResourceStream(new Uri(UNKNOWN_ICON)).Stream;
                bmp.EndInit();
                bmp.Freeze();
                IconCreator.ICDrawingContext.DrawImage(bmp, new Rect(902, y + 3, 64, 64));
            }
        }
Example #3
0
        public static void DrawIconImage(JArray AssetProperties, bool isFeatured)
        {
            if (isFeatured)
            {
                JToken displayAssetPathToken = AssetsUtility.GetPropertyTagStruct <JToken>(AssetProperties, "DisplayAssetPath", "asset_path_name");
                if (displayAssetPathToken != null)
                {
                    string displayAssetPath = FoldersUtility.FixFortnitePath(displayAssetPathToken.Value <string>());
                    DrawFeaturedImageFromTagData(AssetProperties, displayAssetPath);
                }
                else if (AssetEntries.AssetEntriesDict.ContainsKey("/FortniteGame/Content/Catalog/DisplayAssets/DA_Featured_" + FWindow.FCurrentAsset + ".uasset"))
                {
                    string displayAssetPath = "/FortniteGame/Content/Catalog/DisplayAssets/DA_Featured_" + FWindow.FCurrentAsset;
                    DrawFeaturedImageFromTagData(AssetProperties, displayAssetPath);
                }
                else
                {
                    DrawIconImage(AssetProperties, false);
                }
            }
            else
            {
                JToken heroToken   = AssetsUtility.GetPropertyTagImport <JToken>(AssetProperties, "HeroDefinition");
                JToken weaponToken = AssetsUtility.GetPropertyTagImport <JToken>(AssetProperties, "WeaponDefinition");
                if (heroToken != null)
                {
                    //this will catch the full path if asset exists to be able to grab his PakReader and List<FPakEntry>
                    string assetPath = AssetEntries.AssetEntriesDict.Where(x => x.Key.ToLowerInvariant().Contains("/" + heroToken.Value <string>().ToLowerInvariant() + ".uasset")).Select(d => d.Key).FirstOrDefault();
                    if (!string.IsNullOrEmpty(assetPath))
                    {
                        DrawImageFromTagData(assetPath.Substring(0, assetPath.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase)));
                    }
                }
                else if (weaponToken != null)
                {
                    string weaponName = weaponToken.Value <string>();
                    if (weaponToken.Value <string>().Equals("WID_Harvest_Pickaxe_STWCosmetic_Tier")) //STW PICKAXES MANUAL FIX
                    {
                        weaponName = "WID_Harvest_Pickaxe_STWCosmetic_Tier_" + FWindow.FCurrentAsset.Substring(FWindow.FCurrentAsset.Length - 1);
                    }

                    //this will catch the full path if asset exists to be able to grab his PakReader and List<FPakEntry>
                    string assetPath = AssetEntries.AssetEntriesDict.Where(x => x.Key.ToLowerInvariant().Contains("/" + weaponName.ToLowerInvariant() + ".uasset")).Select(d => d.Key).FirstOrDefault();
                    if (!string.IsNullOrEmpty(assetPath))
                    {
                        DrawImageFromTagData(assetPath.Substring(0, assetPath.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase)));
                    }
                }
                else
                {
                    DrawLargeSmallImage(AssetProperties);
                }
            }
        }
Example #4
0
        public static void GetHeroPerk(JArray AssetProperties)
        {
            JToken heroGameplayDefinitionToken = AssetsUtility.GetPropertyTagImport <JToken>(AssetProperties, "HeroGameplayDefinition");

            if (heroGameplayDefinitionToken != null)
            {
                string assetPath = AssetEntries.AssetEntriesDict.Where(x => x.Key.ToLowerInvariant().Contains("/" + heroGameplayDefinitionToken.Value <string>().ToLowerInvariant() + ".")).Select(d => d.Key).FirstOrDefault();
                if (!string.IsNullOrEmpty(assetPath))
                {
                    PakReader.PakReader reader = AssetsUtility.GetPakReader(assetPath);
                    if (reader != null)
                    {
                        List <FPakEntry> entriesList = AssetsUtility.GetPakEntries(assetPath.Substring(0, assetPath.Length - ".uasset".Length));
                        string           jsonData    = AssetsUtility.GetAssetJsonData(reader, entriesList);

                        if (AssetsUtility.IsValidJson(jsonData))
                        {
                            dynamic AssetData      = JsonConvert.DeserializeObject(jsonData);
                            JToken  AssetMainToken = null;
                            if (jsonData.StartsWith("[") && jsonData.EndsWith("]"))
                            {
                                JArray AssetArray = JArray.FromObject(AssetData);
                                AssetMainToken = AssetArray[0];
                            }
                            else if (jsonData.StartsWith("{") && jsonData.EndsWith("}"))
                            {
                                AssetMainToken = AssetData;
                            }

                            if (AssetMainToken != null)
                            {
                                JArray heroGameplayProperties = AssetMainToken["properties"].Value <JArray>();
                                if (heroGameplayProperties != null)
                                {
                                    _borderY = 518;
                                    _textY   = 550;
                                    _imageY  = 519;

                                    DrawHeroPerk(heroGameplayProperties);
                                    DrawTierAbilityKits(heroGameplayProperties);

                                    //RESIZE
                                    IconCreator.ICDrawingContext.DrawRectangle(Brushes.Transparent, null, new Rect(new Point(0, 0), new Size(515, 560 + 35 * 3)));
                                }
                            }
                        }
                    }
                }
            }
        }
Example #5
0
        public static void DrawRarityBackground(JArray AssetProperties)
        {
            JToken serieToken  = AssetsUtility.GetPropertyTagImport <JToken>(AssetProperties, "Series");
            JToken rarityToken = AssetsUtility.GetPropertyTag <JToken>(AssetProperties, "Rarity");

            if (AssetsLoader.ExportType == "FortAmmoItemDefinition")
            {
                DrawBackground(ImagesUtility.ParseColorFromHex("#6D6D6D"), ImagesUtility.ParseColorFromHex("#464646"), ImagesUtility.ParseColorFromHex("#9E9E9E"));
            }
            else if (serieToken != null)
            {
                GetSerieAsset(serieToken, rarityToken);
            }
            else
            {
                DrawNormalRarity(rarityToken);
            }
        }
Example #6
0
        private static void SetTextVariables(JArray AssetProperties)
        {
            _displayName            = string.Empty;
            _description            = string.Empty;
            _shortDescription       = string.Empty;
            _cosmeticSource         = string.Empty;
            _cosmeticItemDefinition = string.Empty;
            _itemAction             = string.Empty;
            _maxStackSize           = string.Empty;
            _userFacingFlagsToken   = null;

            JToken name_namespace     = AssetsUtility.GetPropertyTagText <JToken>(AssetProperties, "DisplayName", "namespace");
            JToken name_key           = AssetsUtility.GetPropertyTagText <JToken>(AssetProperties, "DisplayName", "key");
            JToken name_source_string = AssetsUtility.GetPropertyTagText <JToken>(AssetProperties, "DisplayName", "source_string");

            JToken description_namespace     = AssetsUtility.GetPropertyTagText <JToken>(AssetProperties, "Description", "namespace");
            JToken description_key           = AssetsUtility.GetPropertyTagText <JToken>(AssetProperties, "Description", "key");
            JToken description_source_string = AssetsUtility.GetPropertyTagText <JToken>(AssetProperties, "Description", "source_string");

            JToken short_description_namespace     = AssetsUtility.GetPropertyTagText <JToken>(AssetProperties, "ShortDescription", "namespace");
            JToken short_description_key           = AssetsUtility.GetPropertyTagText <JToken>(AssetProperties, "ShortDescription", "key");
            JToken short_description_source_string = AssetsUtility.GetPropertyTagText <JToken>(AssetProperties, "ShortDescription", "source_string");

            JToken cosmetic_item  = AssetsUtility.GetPropertyTagImport <JToken>(AssetProperties, "cosmetic_item");
            JToken max_stack_size = AssetsUtility.GetPropertyTag <JToken>(AssetProperties, "MaxStackSize");
            JToken ammo_data      = AssetsUtility.GetPropertyTagText <JToken>(AssetProperties, "AmmoData", "asset_path_name");

            JArray gTagsArray = AssetsUtility.GetPropertyTagStruct <JArray>(AssetProperties, "GameplayTags", "gameplay_tags");

            if (name_namespace != null && name_key != null && name_source_string != null)
            {
                _displayName = AssetTranslations.SearchTranslation(name_namespace.Value <string>(), name_key.Value <string>(), name_source_string.Value <string>());
            }

            if (description_namespace != null && description_key != null && description_source_string != null)
            {
                _description = AssetTranslations.SearchTranslation(description_namespace.Value <string>(), description_key.Value <string>(), description_source_string.Value <string>());
            }

            if (short_description_namespace != null && short_description_key != null && short_description_source_string != null)
            {
                _shortDescription = AssetTranslations.SearchTranslation(short_description_namespace.Value <string>(), short_description_key.Value <string>(), short_description_source_string.Value <string>());
            }
            else if (AssetsLoader.ExportType == "AthenaItemWrapDefinition")
            {
                _shortDescription = AssetTranslations.SearchTranslation("Fort.Cosmetics", "ItemWrapShortDescription", "Wrap");
            }

            if (cosmetic_item != null)
            {
                _cosmeticItemDefinition = cosmetic_item.Value <string>();
            }
            if (max_stack_size != null)
            {
                _maxStackSize = "Max Stack Size: " + max_stack_size.Value <string>();
            }
            if (ammo_data != null && ammo_data.Value <string>().Contains("Ammo"))
            {
                string path = FoldersUtility.FixFortnitePath(ammo_data.Value <string>());
                IconAmmoData.DrawIconAmmoData(path);

                JArray weapon_stat_handle = AssetsUtility.GetPropertyTagStruct <JArray>(AssetProperties, "WeaponStatHandle", "properties");
                if (weapon_stat_handle != null)
                {
                    JToken stats_file = AssetsUtility.GetPropertyTagImport <JToken>(weapon_stat_handle, "DataTable");
                    JToken row_name   = AssetsUtility.GetPropertyTag <JToken>(weapon_stat_handle, "RowName");
                    if (stats_file != null && row_name != null)
                    {
                        WeaponStats.DrawWeaponStats(stats_file.Value <string>(), row_name.Value <string>());
                    }
                }
            }

            if (gTagsArray != null)
            {
                JToken cSetToken = gTagsArray.Children <JToken>().FirstOrDefault(x => x.ToString().StartsWith("Cosmetics.Set."));
                if (cSetToken != null)
                {
                    string cosmeticSet = CosmeticSet.GetCosmeticSet(cSetToken.Value <string>());
                    if (!string.IsNullOrEmpty(cosmeticSet))
                    {
                        _description += cosmeticSet;
                    }
                }

                JToken cSourceToken = gTagsArray.Children <JToken>().FirstOrDefault(x => x.ToString().StartsWith("Cosmetics.Source."));
                if (cSourceToken != null)
                {
                    _cosmeticSource = cSourceToken.Value <string>().Substring("Cosmetics.Source.".Length);
                }

                JToken cActionToken = gTagsArray.Children <JToken>().FirstOrDefault(x => x.ToString().StartsWith("Athena.ItemAction."));
                if (cActionToken != null)
                {
                    _itemAction = cActionToken.Value <string>().Substring("Athena.ItemAction.".Length);
                }

                _userFacingFlagsToken = gTagsArray.Children <JToken>().Where(x => x.ToString().StartsWith("Cosmetics.UserFacingFlags."));
            }
        }
Example #7
0
        private static void SetTextVariables(JArray AssetProperties)
        {
            _displayName            = string.Empty;
            _description            = string.Empty;
            _shortDescription       = string.Empty;
            _cosmeticSource         = string.Empty;
            _cosmeticItemDefinition = string.Empty;
            _itemAction             = string.Empty;
            _maxStackSize           = string.Empty;
            _miniMapIconBrushPath   = string.Empty;
            _userFacingFlagsToken   = null;
            _userHeroFlagsToken     = null;
            _userWeaponFlagsToken   = null;

            JToken name_namespace     = AssetsUtility.GetPropertyTagText <JToken>(AssetProperties, "DisplayName", "namespace");
            JToken name_key           = AssetsUtility.GetPropertyTagText <JToken>(AssetProperties, "DisplayName", "key");
            JToken name_source_string = AssetsUtility.GetPropertyTagText <JToken>(AssetProperties, "DisplayName", "source_string");

            JToken description_namespace     = AssetsUtility.GetPropertyTagText <JToken>(AssetProperties, "Description", "namespace");
            JToken description_key           = AssetsUtility.GetPropertyTagText <JToken>(AssetProperties, "Description", "key");
            JToken description_source_string = AssetsUtility.GetPropertyTagText <JToken>(AssetProperties, "Description", "source_string");

            JToken short_description_namespace     = AssetsUtility.GetPropertyTagText <JToken>(AssetProperties, "ShortDescription", "namespace");
            JToken short_description_key           = AssetsUtility.GetPropertyTagText <JToken>(AssetProperties, "ShortDescription", "key");
            JToken short_description_source_string = AssetsUtility.GetPropertyTagText <JToken>(AssetProperties, "ShortDescription", "source_string");

            JToken cosmetic_item  = AssetsUtility.GetPropertyTagImport <JToken>(AssetProperties, "cosmetic_item");
            JToken max_stack_size = AssetsUtility.GetPropertyTag <JToken>(AssetProperties, "MaxStackSize");
            JToken ammo_data      = AssetsUtility.GetPropertyTagText <JToken>(AssetProperties, "AmmoData", "asset_path_name");

            JArray gTagsArray       = AssetsUtility.GetPropertyTagStruct <JArray>(AssetProperties, "GameplayTags", "gameplay_tags");
            JArray hTagsArray       = AssetsUtility.GetPropertyTagStruct <JArray>(AssetProperties, "RequiredGPTags", "gameplay_tags");
            JArray wTagsArray       = AssetsUtility.GetPropertyTagStruct <JArray>(AssetProperties, "AnalyticTags", "gameplay_tags");
            JArray MiniMapIconArray = AssetsUtility.GetPropertyTagStruct <JArray>(AssetProperties, "MiniMapIconBrush", "properties");

            if (name_namespace != null && name_key != null && name_source_string != null)
            {
                _displayName = AssetTranslations.SearchTranslation(name_namespace.Value <string>(), name_key.Value <string>(), name_source_string.Value <string>());
            }

            if (description_namespace != null && description_key != null && description_source_string != null)
            {
                _description = AssetTranslations.SearchTranslation(description_namespace.Value <string>(), description_key.Value <string>(), description_source_string.Value <string>());
            }

            if (short_description_namespace != null && short_description_key != null && short_description_source_string != null)
            {
                _shortDescription = AssetTranslations.SearchTranslation(short_description_namespace.Value <string>(), short_description_key.Value <string>(), short_description_source_string.Value <string>());
            }
            else if (AssetsLoader.ExportType == "AthenaItemWrapDefinition")
            {
                _shortDescription = AssetTranslations.SearchTranslation("Fort.Cosmetics", "ItemWrapShortDescription", "Wrap");
            }

            if (cosmetic_item != null)
            {
                _cosmeticItemDefinition = cosmetic_item.Value <string>();
            }
            if (max_stack_size != null)
            {
                _maxStackSize = "Max Stack Size: " + max_stack_size["struct_type"]["properties"][0]["tag_data"].Value <string>();
            }
            if (ammo_data != null && ammo_data.Value <string>().Contains("Ammo"))
            {
                string path = FoldersUtility.FixFortnitePath(ammo_data.Value <string>());
                IconAmmoData.DrawIconAmmoData(path);

                JArray weapon_stat_handle = AssetsUtility.GetPropertyTagStruct <JArray>(AssetProperties, "WeaponStatHandle", "properties");
                if (weapon_stat_handle != null)
                {
                    JToken stats_file = AssetsUtility.GetPropertyTagImport <JToken>(weapon_stat_handle, "DataTable");
                    JToken row_name   = AssetsUtility.GetPropertyTag <JToken>(weapon_stat_handle, "RowName");
                    if (stats_file != null && row_name != null)
                    {
                        WeaponStats.DrawWeaponStats(stats_file.Value <string>(), row_name.Value <string>());
                    }
                }
            }

            if (gTagsArray != null)
            {
                JToken cSetToken = gTagsArray.Children <JToken>().FirstOrDefault(x => x.ToString().StartsWith("Cosmetics.Set."));
                if (cSetToken != null)
                {
                    string cosmeticSet = CosmeticSet.GetCosmeticSet(cSetToken.Value <string>());
                    if (!string.IsNullOrEmpty(cosmeticSet))
                    {
                        _description += cosmeticSet;
                    }
                }

                JToken cFilterToken = gTagsArray.Children <JToken>().FirstOrDefault(x => x.ToString().StartsWith("Cosmetics.Filter.Season."));
                if (cFilterToken != null)
                {
                    string cosmeticFilter = CosmeticSeason.GetCosmeticSeason(cFilterToken.Value <string>().Substring("Cosmetics.Filter.Season.".Length));
                    if (!string.IsNullOrEmpty(cosmeticFilter))
                    {
                        _description += cosmeticFilter;
                    }
                }

                JToken cSourceToken = gTagsArray.Children <JToken>().FirstOrDefault(x => x.ToString().StartsWith("Cosmetics.Source."));
                if (cSourceToken != null)
                {
                    _cosmeticSource = cSourceToken.Value <string>().Substring("Cosmetics.Source.".Length);
                }

                JToken cActionToken = gTagsArray.Children <JToken>().FirstOrDefault(x => x.ToString().StartsWith("Athena.ItemAction."));
                if (cActionToken != null)
                {
                    _itemAction = cActionToken.Value <string>().Substring("Athena.ItemAction.".Length);
                }

                _userFacingFlagsToken = gTagsArray.Children <JToken>().Where(x => x.ToString().StartsWith("Cosmetics.UserFacingFlags."));
            }

            if (hTagsArray != null)
            {
                _userHeroFlagsToken = hTagsArray.Children <JToken>().Where(x => x.ToString().StartsWith("Unlocks.Class."));
            }

            if (wTagsArray != null)
            {
                _userWeaponFlagsToken = wTagsArray.Children <JToken>().Where(x => x.ToString().StartsWith("Weapon.Ranged.", StringComparison.InvariantCultureIgnoreCase));
            }
            else if (MiniMapIconArray != null)
            {
                JToken resourceObjectToken = AssetsUtility.GetPropertyTagOuterImport <JToken>(MiniMapIconArray, "ResourceObject");
                if (resourceObjectToken != null)
                {
                    _miniMapIconBrushPath = FoldersUtility.FixFortnitePath(resourceObjectToken.Value <string>());
                }
            }
        }
Example #8
0
        private static void DrawFeaturedImageFromDisplayAssetProperty(JArray AssetProperties, JArray displayAssetProperties)
        {
            JToken resourceObjectOuterImportToken = AssetsUtility.GetPropertyTagOuterImport <JToken>(displayAssetProperties, "ResourceObject");
            JToken resourceObjectImportToken      = AssetsUtility.GetPropertyTagImport <JToken>(displayAssetProperties, "ResourceObject");

            if (resourceObjectOuterImportToken != null && resourceObjectOuterImportToken.Value <string>() != null)
            {
                string texturePath = FoldersUtility.FixFortnitePath(resourceObjectOuterImportToken.Value <string>());
                if (texturePath.Contains("/FortniteGame/Content/Athena/Prototype/Textures/"))
                {
                    DrawIconImage(AssetProperties, false);
                }
                else
                {
                    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();

                            IconCreator.ICDrawingContext.DrawImage(bmp, new Rect(3, 3, 509, 509));
                        }
                    }

                    if (AssetsLoader.ExportType == "AthenaItemWrapDefinition" && texturePath.Contains("WeaponRenders"))
                    {
                        DrawAdditionalWrapImage(AssetProperties);
                    }
                }
            }
            else if (resourceObjectImportToken != null)
            {
                //this will catch the full path if asset exists to be able to grab his PakReader and List<FPakEntry>
                string renderSwitchPath = AssetEntries.AssetEntriesDict.Where(x => x.Key.Contains("/" + resourceObjectImportToken.Value <string>())).Select(d => d.Key).FirstOrDefault();
                if (!string.IsNullOrEmpty(renderSwitchPath) && (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))
                    {
                        JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData);
                        if (AssetMainToken != null)
                        {
                            JArray renderSwitchProperties = AssetMainToken["properties"].Value <JArray>();
                            if (renderSwitchProperties != null)
                            {
                                JArray textureParameterArray = AssetsUtility.GetPropertyTagText <JArray>(renderSwitchProperties, "TextureParameterValues", "data");
                                textureParameterArray = textureParameterArray[textureParameterArray.Count() > 1 && !AssetsLoader.ExportType.Equals("AthenaItemWrapDefinition") ? 1 : 0]["struct_type"]["properties"].Value <JArray>();
                                if (textureParameterArray != null)
                                {
                                    JToken parameterValueToken = AssetsUtility.GetPropertyTagOuterImport <JToken>(textureParameterArray, "ParameterValue");
                                    if (parameterValueToken != null)
                                    {
                                        string texturePath = FoldersUtility.FixFortnitePath(parameterValueToken.Value <string>());
                                        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();

                                                IconCreator.ICDrawingContext.DrawImage(bmp, new Rect(3, 3, 509, 509));
                                            }
                                        }

                                        if (AssetsLoader.ExportType == "AthenaItemWrapDefinition" && texturePath.Contains("WeaponRenders"))
                                        {
                                            DrawAdditionalWrapImage(AssetProperties);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Example #9
0
        /// <summary>
        /// this is kinda complex but at the end it only gets quest files names, counts, rewards, rewards quantity and the unlock type of the quests
        /// and repeat the process if he find stage quests
        /// </summary>
        /// <param name="BundleProperties"></param>
        /// <param name="assetPath"></param>
        private static void GetQuestData(JArray BundleProperties, string assetPath)
        {
            string jsonData = AssetsUtility.GetAssetJsonDataByPath(assetPath);

            if (jsonData != null && AssetsUtility.IsValidJson(jsonData))
            {
                JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData);
                if (AssetMainToken != null)
                {
                    JArray AssetProperties = AssetMainToken["properties"].Value <JArray>();
                    if (AssetProperties != null)
                    {
                        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 <JToken>(BundleProperties, "QuestUnlockType");
                        if (questUnlockTypeToken != null)
                        {
                            unlockType = questUnlockTypeToken.Value <string>();
                        }

                        //objectives array to catch the quest description and quest count
                        JArray objectivesDataArray = AssetsUtility.GetPropertyTagText <JArray>(AssetProperties, "Objectives", "data");
                        if (objectivesDataArray != null &&
                            objectivesDataArray[0]["struct_name"] != null && objectivesDataArray[0]["struct_type"] != null && string.Equals(objectivesDataArray[0]["struct_name"].Value <string>(), "FortMcpQuestObjectiveInfo"))
                        {
                            JArray objectivesDataProperties = objectivesDataArray[0]["struct_type"]["properties"].Value <JArray>();

                            //this description come from the main quest array (not the objectives array)
                            JToken description_namespace     = AssetsUtility.GetPropertyTagText <JToken>(AssetProperties, "Description", "namespace");
                            JToken description_key           = AssetsUtility.GetPropertyTagText <JToken>(AssetProperties, "Description", "key");
                            JToken description_source_string = AssetsUtility.GetPropertyTagText <JToken>(AssetProperties, "Description", "source_string");
                            if (description_namespace != null && description_key != null && description_source_string != null)
                            {
                                questDescription = AssetTranslations.SearchTranslation(description_namespace.Value <string>(), description_key.Value <string>(), description_source_string.Value <string>());
                            }
                            else
                            {
                                //this description come from the objectives quest array
                                description_namespace     = AssetsUtility.GetPropertyTagText <JToken>(objectivesDataProperties, "Description", "namespace");
                                description_key           = AssetsUtility.GetPropertyTagText <JToken>(objectivesDataProperties, "Description", "key");
                                description_source_string = AssetsUtility.GetPropertyTagText <JToken>(objectivesDataProperties, "Description", "source_string");
                                if (description_namespace != null && description_key != null && description_source_string != null)
                                {
                                    questDescription = AssetTranslations.SearchTranslation(description_namespace.Value <string>(), description_key.Value <string>(), description_source_string.Value <string>());
                                }
                            }

                            if (objectivesDataProperties != null)
                            {
                                JToken countToken = AssetsUtility.GetPropertyTag <JToken>(objectivesDataProperties, "Count");
                                if (countToken != null)
                                {
                                    questCount = countToken.Value <long>();
                                    JToken objectiveCompletionCountToken = AssetsUtility.GetPropertyTag <JToken>(AssetProperties, "ObjectiveCompletionCount");
                                    if (objectiveCompletionCountToken != null)
                                    {
                                        questCount = objectiveCompletionCountToken.Value <long>();
                                    }
                                }
                            }
                        }

                        //rewards array to catch the reward name (not path) and the quantity
                        JArray rewardsDataArray       = AssetsUtility.GetPropertyTagText <JArray>(AssetProperties, "Rewards", "data");
                        JArray hiddenRewardsDataArray = AssetsUtility.GetPropertyTagText <JArray>(AssetProperties, "HiddenRewards", "data");
                        JToken rewardsTable           = AssetsUtility.GetPropertyTagImport <JToken>(AssetProperties, "RewardsTable");
                        if (rewardsDataArray != null)
                        {
                            if (rewardsDataArray[0]["struct_name"] != null && rewardsDataArray[0]["struct_type"] != null && string.Equals(rewardsDataArray[0]["struct_name"].Value <string>(), "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 <string>(), "Quest") &&
                                                                                           !string.Equals(x["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][0]["tag_data"].Value <string>(), "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 <string>(), "Quest") &&
                                                                                            !string.Equals(x["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][0]["tag_data"].Value <string>(), "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<FPakEntry>
                                        string primaryAssetNameFullPath = AssetEntries.AssetEntriesDict.Where(x => x.Key.ToLowerInvariant().Contains("/" + targetChecker.Value <string>().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 <string>();
                                        }

                                        BundleInfosEntry currentData = new BundleInfosEntry(questDescription, questCount, unlockType, rewardPath, rewardQuantity, assetPath);
                                        if (!BundleData.Any(item => item.TheQuestDescription.Equals(currentData.TheQuestDescription, StringComparison.InvariantCultureIgnoreCase) && item.TheQuestCount == currentData.TheQuestCount && string.Equals(item.TheAssetPath, currentData.TheAssetPath)))
                                        {
                                            BundleData.Add(currentData);
                                        }
                                    }
                                    else
                                    {
                                        BundleInfosEntry currentData = new BundleInfosEntry(questDescription, questCount, unlockType, "", "", assetPath);
                                        if (!BundleData.Any(item => item.TheQuestDescription.Equals(currentData.TheQuestDescription, StringComparison.InvariantCultureIgnoreCase) && item.TheQuestCount == currentData.TheQuestCount && string.Equals(item.TheAssetPath, currentData.TheAssetPath)))
                                        {
                                            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 <string>(), "FortHiddenRewardQuantityPair"))
                                        {
                                            JArray hiddenRewardPropertiesArray = hiddenRewardsDataArray[0]["struct_type"]["properties"].Value <JArray>();
                                            if (hiddenRewardPropertiesArray != null)
                                            {
                                                JToken templateIdToken = AssetsUtility.GetPropertyTag <JToken>(hiddenRewardPropertiesArray, "TemplateId");
                                                if (templateIdToken != null)
                                                {
                                                    rewardPath = templateIdToken.Value <string>();
                                                }

                                                //reward quantity (if 1, this won't be displayed)
                                                JToken hiddenQuantityToken = AssetsUtility.GetPropertyTag <JToken>(hiddenRewardPropertiesArray, "Quantity");
                                                if (hiddenQuantityToken != null)
                                                {
                                                    rewardQuantity = hiddenQuantityToken.Value <string>();
                                                }

                                                BundleInfosEntry currentData = new BundleInfosEntry(questDescription, questCount, unlockType, rewardPath, rewardQuantity, assetPath);
                                                if (!BundleData.Any(item => item.TheQuestDescription.Equals(currentData.TheQuestDescription, StringComparison.InvariantCultureIgnoreCase) && item.TheQuestCount == currentData.TheQuestCount && string.Equals(item.TheAssetPath, currentData.TheAssetPath)))
                                                {
                                                    BundleData.Add(currentData);
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        BundleInfosEntry currentData = new BundleInfosEntry(questDescription, questCount, unlockType, "", "", assetPath);
                                        if (!BundleData.Any(item => item.TheQuestDescription.Equals(currentData.TheQuestDescription, StringComparison.InvariantCultureIgnoreCase) && item.TheQuestCount == currentData.TheQuestCount && string.Equals(item.TheAssetPath, currentData.TheAssetPath)))
                                        {
                                            BundleData.Add(currentData);
                                        }
                                    }
                                }
                            }
                        }
                        else if (rewardsTable != null)
                        {
                            string rewardsTablePath = AssetEntries.AssetEntriesDict.Where(x => x.Key.ToLowerInvariant().Contains("/" + rewardsTable.Value <string>().ToLowerInvariant() + ".uasset")).Select(d => d.Key).FirstOrDefault();
                            if (!string.IsNullOrEmpty(rewardsTablePath))
                            {
                                jsonData = AssetsUtility.GetAssetJsonDataByPath(rewardsTablePath.Substring(0, rewardsTablePath.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase)));
                                if (jsonData != null && AssetsUtility.IsValidJson(jsonData))
                                {
                                    JToken AssetRewarsTableMainToken = AssetsUtility.ConvertJson2Token(jsonData);
                                    if (AssetRewarsTableMainToken != null)
                                    {
                                        JArray propertiesArray = AssetRewarsTableMainToken["rows"].Value <JArray>();
                                        if (propertiesArray != null)
                                        {
                                            JArray propertiesRewardTable = AssetsUtility.GetPropertyTagItemData <JArray>(propertiesArray, "Default", "properties");
                                            if (propertiesRewardTable != null)
                                            {
                                                JToken templateIdToken = propertiesRewardTable.FirstOrDefault(item => string.Equals(item["name"].Value <string>(), "TemplateId"));
                                                if (templateIdToken != null)
                                                {
                                                    string templateId = templateIdToken["tag_data"].Value <string>();
                                                    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.FirstOrDefault(item => string.Equals(item["name"].Value <string>(), "Quantity"));
                                                    if (quantityToken != null)
                                                    {
                                                        rewardQuantity = quantityToken["tag_data"].Value <string>();
                                                    }

                                                    BundleInfosEntry currentData = new BundleInfosEntry(questDescription, questCount, unlockType, rewardPath, rewardQuantity, assetPath);
                                                    if (!BundleData.Any(item => item.TheQuestDescription.Equals(currentData.TheQuestDescription, StringComparison.InvariantCultureIgnoreCase) && item.TheQuestCount == currentData.TheQuestCount && string.Equals(item.TheAssetPath, currentData.TheAssetPath)))
                                                    {
                                                        BundleData.Add(currentData);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            BundleInfosEntry currentData = new BundleInfosEntry(questDescription, questCount, unlockType, "", "", assetPath);
                            if (!BundleData.Any(item => item.TheQuestDescription.Equals(currentData.TheQuestDescription, StringComparison.InvariantCultureIgnoreCase) && item.TheQuestCount == currentData.TheQuestCount && string.Equals(item.TheAssetPath, currentData.TheAssetPath)))
                            {
                                BundleData.Add(currentData);
                            }
                        }

                        //catch stage AFTER adding the current quest to the list
                        if (rewardsDataArray != null)
                        {
                            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 <string>(), "Quest"))
                                {
                                    JToken primaryAssetNameToken = token["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][1]["tag_data"];
                                    if (primaryAssetNameToken != null)
                                    {
                                        string primaryAssetName = GetChallengeStageContinuation(assetPath, primaryAssetNameToken.Value <string>());

                                        //this will catch the full path if asset exists to be able to grab his PakReader and List<FPakEntry>
                                        string primaryAssetNameFullPath = AssetEntries.AssetEntriesDict.Where(x => x.Key.ToLowerInvariant().Contains("/" + primaryAssetName.ToLowerInvariant())).Select(d => d.Key).FirstOrDefault();
                                        if (!string.IsNullOrEmpty(primaryAssetNameFullPath))
                                        {
                                            // Prevents loops
                                            if (string.Equals(assetPath, primaryAssetNameFullPath.Substring(0, primaryAssetNameFullPath.LastIndexOf("."))))
                                            {
                                                continue;
                                            }

                                            new UpdateMyProcessEvents(System.IO.Path.GetFileNameWithoutExtension(primaryAssetNameFullPath), "Waiting").Update();
                                            GetQuestData(BundleProperties, primaryAssetNameFullPath.Substring(0, primaryAssetNameFullPath.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase)));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }