Exemple #1
0
        private static void DrawFeaturedImage(JArray AssetProperties, string displayAssetPath)
        {
            string jsonData = AssetsUtility.GetAssetJsonDataByPath(displayAssetPath);

            if (jsonData != null && AssetsUtility.IsValidJson(jsonData))
            {
                FWindow.FCurrentAsset = Path.GetFileName(displayAssetPath);

                JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData);
                if (AssetMainToken != null)
                {
                    JArray displayAssetProperties = AssetMainToken["properties"].Value <JArray>();
                    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 <JArray>(displayAssetProperties, "TileImage", "properties");
                        if (TileImageProperties != null)
                        {
                            DrawFeaturedImageFromDisplayAssetProperty(AssetProperties, TileImageProperties);
                        }
                        break;

                    default:
                        JArray DetailsImageProperties = AssetsUtility.GetPropertyTagStruct <JArray>(displayAssetProperties, "DetailsImage", "properties");
                        if (DetailsImageProperties != null)
                        {
                            DrawFeaturedImageFromDisplayAssetProperty(AssetProperties, DetailsImageProperties);
                        }
                        break;
                    }
                }
            }
        }
        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)));
                            }
                        }
                    }
                }
            }
        }
Exemple #3
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));
            }
        }
Exemple #4
0
        private static void DrawImageFromTagData(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>();
                    DrawLargeSmallImage(AssetProperties);
                }
            }
        }
Exemple #5
0
        private static void GetSerieAsset(JToken serieToken, JToken rarityToken)
        {
            //this will catch the full path if asset exists to be able to grab his PakReader and List<FPakEntry>
            string seriesFullPath = AssetEntries.AssetEntriesDict.Where(x => x.Key.ToLowerInvariant().Contains("/" + serieToken.Value <string>().ToLowerInvariant() + ".uasset")).Select(d => d.Key).FirstOrDefault();

            if (!string.IsNullOrEmpty(seriesFullPath))
            {
                string jsonData = AssetsUtility.GetAssetJsonDataByPath(seriesFullPath.Substring(0, seriesFullPath.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase)));
                if (jsonData != null)
                {
                    if (AssetsUtility.IsValidJson(jsonData))
                    {
                        JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData);
                        if (AssetMainToken != null)
                        {
                            JArray propertiesArray = AssetMainToken["properties"].Value <JArray>();
                            if (propertiesArray != null)
                            {
                                JArray colorsArray = AssetsUtility.GetPropertyTagStruct <JArray>(propertiesArray, "Colors", "properties");
                                if (colorsArray != null)
                                {
                                    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 <JToken>(propertiesArray, "BackgroundTexture", "asset_path_name");
                                if (backgroundTextureToken != null)
                                {
                                    string imagePath = FoldersUtility.FixFortnitePath(backgroundTextureToken.Value <string>());
                                    DrawSerieImage(imagePath);
                                }
                            }
                        }
                    }
                }
                else
                {
                    DrawNormalRarity(rarityToken);
                }
            }
            else
            {
                DrawNormalRarity(rarityToken);
            }
        }
        private static void DrawAbilityKit(string assetPath)
        {
            if (!string.IsNullOrEmpty(assetPath))
            {
                string jsonData = AssetsUtility.GetAssetJsonDataByPath(assetPath);
                if (jsonData != null && AssetsUtility.IsValidJson(jsonData))
                {
                    JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData);
                    if (AssetMainToken != null)
                    {
                        JArray abilityKitProperties = AssetMainToken["properties"].Value <JArray>();
                        if (abilityKitProperties != null)
                        {
                            JToken name_namespace     = AssetsUtility.GetPropertyTagText <JToken>(abilityKitProperties, "DisplayName", "namespace");
                            JToken name_key           = AssetsUtility.GetPropertyTagText <JToken>(abilityKitProperties, "DisplayName", "key");
                            JToken name_source_string = AssetsUtility.GetPropertyTagText <JToken>(abilityKitProperties, "DisplayName", "source_string");

                            JArray iconBrushArray = AssetsUtility.GetPropertyTagStruct <JArray>(abilityKitProperties, "IconBrush", "properties");
                            if (iconBrushArray != null)
                            {
                                JToken resourceObjectToken = AssetsUtility.GetPropertyTagOuterImport <JToken>(iconBrushArray, "ResourceObject");
                                if (resourceObjectToken != null)
                                {
                                    string texturePath = FoldersUtility.FixFortnitePath(resourceObjectToken.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();

                                            //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)
                                            {
                                                string displayName = AssetTranslations.SearchTranslation(name_namespace.Value <string>(), name_key.Value <string>(), name_source_string.Value <string>());

                                                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.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;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #7
0
        private static void GetRarityData(JToken rarityToken)
        {
            string jsonData = AssetsUtility.GetAssetJsonDataByPath("/FortniteGame/Content/Balance/RarityData");

            if (jsonData != null)
            {
                if (AssetsUtility.IsValidJson(jsonData))
                {
                    JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData);
                    if (AssetMainToken != null)
                    {
                        JArray propertiesArray = AssetMainToken["properties"].Value <JArray>();
                        if (propertiesArray != null)
                        {
                            RarityCollectionIndexes rColor = RarityCollectionIndexes.Uncommon;
                            switch (rarityToken != null ? rarityToken.Value <string>() : string.Empty)
                            {
                            case "EFortRarity::Unattainable":     //OLD IMPOSSIBLE (T9) but its EFortRarity doesn't exist anymore and T9 is now T7
                                rColor = RarityCollectionIndexes.Impossible_T7;
                                break;

                            case "EFortRarity::Transcendent":
                                rColor = RarityCollectionIndexes.Transcendent;
                                break;

                            case "EFortRarity::Mythic":
                                rColor = RarityCollectionIndexes.Mythic;
                                break;

                            case "EFortRarity::Legendary":
                                rColor = RarityCollectionIndexes.Legendary;
                                break;

                            case "EFortRarity::Epic":
                            case "EFortRarity::Quality":
                                rColor = RarityCollectionIndexes.Epic;
                                break;

                            case "EFortRarity::Rare":
                                rColor = RarityCollectionIndexes.Rare;
                                break;

                            case "EFortRarity::Common":
                                rColor = RarityCollectionIndexes.Common;
                                break;
                            }

                            JArray rarityCollectionArray = propertiesArray[(int)rColor]["tag_data"]["struct_type"]["properties"].Value <JArray>();
                            if (rarityCollectionArray != null)
                            {
                                DrawWithInGameColors(rarityCollectionArray, true);
                            }
                        }
                    }
                }
            }
            else
            {
                DebugHelper.WriteLine("Rarity: This is kinda important because /FortniteGame/Content/Balance/RarityData.uasset couldn't be find");
                DrawNormalRarity(rarityToken);
            }
        }
Exemple #8
0
        public static void LoadAsset(string assetPath)
        {
            string jsonData = AssetsUtility.GetAssetJsonDataByPath(assetPath, true);

            if (jsonData != null)
            {
                FWindow.FMain.Dispatcher.InvokeAsync(() =>
                {
                    FWindow.FMain.AssetPropertiesBox_Main.Text = jsonData;
                });

                if (AssetsUtility.IsValidJson(jsonData))
                {
                    JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData);
                    if (AssetMainToken != null && AssetMainToken["export_type"] != null && AssetMainToken["properties"] != null)
                    {
                        ExportType = AssetMainToken["export_type"].Value <string>();
                        DrawingVisual VisualImage = null;
                        switch (ExportType)
                        {
                        case "AthenaBackpackItemDefinition":
                        case "AthenaBattleBusItemDefinition":
                        case "AthenaCharacterItemDefinition":
                        case "AthenaConsumableEmoteItemDefinition":
                        case "AthenaSkyDiveContrailItemDefinition":
                        case "AthenaDanceItemDefinition":
                        case "AthenaEmojiItemDefinition":
                        case "AthenaGliderItemDefinition":
                        case "AthenaItemWrapDefinition":
                        case "AthenaLoadingScreenItemDefinition":
                        case "AthenaMusicPackItemDefinition":
                        case "AthenaPetCarrierItemDefinition":
                        case "AthenaPickaxeItemDefinition":
                        case "AthenaSprayItemDefinition":
                        case "AthenaToyItemDefinition":
                        case "AthenaVictoryPoseItemDefinition":
                        case "FortBannerTokenType":
                        case "AthenaGadgetItemDefinition":
                        case "FortWeaponRangedItemDefinition":
                        case "FortWeaponMeleeItemDefinition":
                        case "FortWeaponMeleeDualWieldItemDefinition":
                        case "FortIngredientItemDefinition":
                        case "FortVariantTokenType":
                        case "FortAmmoItemDefinition":
                        case "FortHeroType":
                        case "FortDefenderItemDefinition":
                        case "FortContextTrapItemDefinition":
                        case "FortTrapItemDefinition":
                        case "FortCardPackItemDefinition":
                        case "FortPlaysetGrenadeItemDefinition":
                        case "FortConsumableAccountItemDefinition":
                        case "FortBadgeItemDefinition":
                        case "FortCurrencyItemDefinition":
                        case "FortConversionControlItemDefinition":
                        case "FortHomebaseNodeItemDefinition":
                        case "FortPersonalVehicleItemDefinition":
                        case "FortCampaignHeroLoadoutItemDefinition":
                        case "FortNeverPersistItemDefinition":
                        case "FortPersistentResourceItemDefinition":
                        case "FortResourceItemDefinition":
                        case "FortGadgetItemDefinition":
                        case "FortStatItemDefinition":
                        case "FortTokenType":
                        case "FortDailyRewardScheduleTokenDefinition":
                        case "FortWorkerType":
                        case "FortConditionalResourceItemDefinition":
                        case "FortAwardItemDefinition":
                        case "FortChallengeBundleScheduleDefinition":
                        case "FortAbilityKit":
                        case "FortSchematicItemDefinition":
                        case "FortAccoladeItemDefinition":
                        case "FortSpyTechItemDefinition":
                        case "FortPlayerPerksItemDefinition":
                        case "FortHardcoreModifierItemDefinition":
                        case "FortQuestItemDefinition":
                        case "FortFeatItemDefinition":
                        case "AthenaDailyQuestDefinition":
                            VisualImage = IconCreator.IconCreator.DrawNormalIconKThx(AssetMainToken["properties"].Value <JArray>());
                            break;

                        case "FortChallengeBundleItemDefinition":
                            VisualImage = IconCreator.IconCreator.DrawChallengeKThx(AssetMainToken["properties"].Value <JArray>(), assetPath);
                            break;
                        }
                        if (VisualImage != null)
                        {
                            ImagesUtility.LoadImageAfterExtraction(VisualImage);
                        }
                    }
                }
            }
        }
Exemple #9
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);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #10
0
        private static void DrawBannerIcon(string bannerName, int y)
        {
            //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.Contains("/BannerIcons.uasset")).Select(d => d.Key).FirstOrDefault();

            if (!string.IsNullOrEmpty(assetPath))
            {
                string jsonData = AssetsUtility.GetAssetJsonDataByPath(assetPath.Substring(0, assetPath.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase)));
                if (jsonData != null && AssetsUtility.IsValidJson(jsonData))
                {
                    JToken AssetMainToken = AssetsUtility.ConvertJson2Token(jsonData);
                    if (AssetMainToken != null)
                    {
                        JArray propertiesArray = AssetMainToken["rows"].Value <JArray>();
                        if (propertiesArray != null)
                        {
                            JArray target = AssetsUtility.GetPropertyTagItemData <JArray>(propertiesArray, bannerName, "properties");
                            if (target != null)
                            {
                                JToken largeImage = target.FirstOrDefault(x => string.Equals(x["name"].Value <string>(), "LargeImage"));
                                JToken smallImage = target.FirstOrDefault(x => string.Equals(x["name"].Value <string>(), "SmallImage"));
                                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)
                                    {
                                        string texturePath = FoldersUtility.FixFortnitePath(assetPathName.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(902, y + 3, 64, 64));
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            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));
            }
        }
Exemple #11
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)));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }