Exemplo n.º 1
0
        public static void DrawWeaponFacingFlag(JToken uFF)
        {
            if (SecondaryCategoriesDataArray == null)
            {
                string jsonData = AssetsUtility.GetAssetJsonDataByPath("/FortniteGame/Content/Items/ItemCategories", true);
                if (jsonData != null && AssetsUtility.IsValidJson(jsonData))
                {
                    dynamic AssetData  = JsonConvert.DeserializeObject(jsonData);
                    JArray  AssetArray = JArray.FromObject(AssetData);
                    JToken  secondaryCategoriesToken = AssetsUtility.GetPropertyTag <JToken>(AssetArray[0]["properties"].Value <JArray>(), "SecondaryCategories");
                    if (secondaryCategoriesToken != null)
                    {
                        SecondaryCategoriesDataArray = secondaryCategoriesToken["data"].Value <JArray>();

                        string uFFTargeted = uFF.Value <string>();
                        SearchWeaponFacingFlag(uFFTargeted);
                    }
                }
            }
            else
            {
                string uFFTargeted = uFF.Value <string>();
                SearchWeaponFacingFlag(uFFTargeted);
            }
        }
Exemplo n.º 2
0
        public static void DrawUserFacingFlag(JToken uFF)
        {
            if (ItemCategoriesArray == null)
            {
                PakReader.PakReader reader = AssetsUtility.GetPakReader("/FortniteGame/Content/Items/ItemCategories");
                if (reader != null)
                {
                    List <FPakEntry> entriesList = AssetsUtility.GetPakEntries("/FortniteGame/Content/Items/ItemCategories");
                    string           jsonData    = AssetsUtility.GetAssetJsonData(reader, entriesList, true);
                    if (AssetsUtility.IsValidJson(jsonData))
                    {
                        dynamic AssetData  = JsonConvert.DeserializeObject(jsonData);
                        JArray  AssetArray = JArray.FromObject(AssetData);
                        JToken  tertiaryCategoriesToken = AssetsUtility.GetPropertyTag <JToken>(AssetArray[0]["properties"].Value <JArray>(), "TertiaryCategories");
                        if (tertiaryCategoriesToken != null)
                        {
                            ItemCategoriesArray = tertiaryCategoriesToken["data"].Value <JArray>();

                            string uFFTargeted = uFF.Value <string>().Substring("Cosmetics.UserFacingFlags.".Length);
                            SearchUserFacingFlag(uFFTargeted);
                        }
                    }
                }
            }
            else
            {
                string uFFTargeted = uFF.Value <string>().Substring("Cosmetics.UserFacingFlags.".Length);
                SearchUserFacingFlag(uFFTargeted);
            }
        }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
0
        private static void GetUFFImage(JArray Properties)
        {
            JToken categoryBrushToken = AssetsUtility.GetPropertyTag <JToken>(Properties, "CategoryBrush");

            if (categoryBrushToken != null)
            {
                JArray categoryBrushProperties = categoryBrushToken["struct_type"]["properties"].Value <JArray>();
                if (categoryBrushProperties != null)
                {
                    JToken BrushXXSToken = AssetsUtility.GetPropertyTag <JToken>(categoryBrushProperties, "Brush_XXS");
                    if (BrushXXSToken != null)
                    {
                        JArray brushXXSProperties = BrushXXSToken["struct_type"]["properties"].Value <JArray>();
                        if (brushXXSProperties != null)
                        {
                            JToken resourceObjectToken = AssetsUtility.GetPropertyTagOuterImport <JToken>(brushXXSProperties, "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();

                                        xCoords += 25;
                                        IconCreator.ICDrawingContext.DrawImage(bmp, new Rect(xCoords, 4, 25, 25));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        public static void DrawChallengeCompletion(JArray AssetProperties, SolidColorBrush PrimaryColor, SolidColorBrush SecondaryColor, int y)
        {
            JArray bundleCompletionRewardsArray = AssetsUtility.GetPropertyTagText <JArray>(AssetProperties, "BundleCompletionRewards", "data");

            if (bundleCompletionRewardsArray != null)
            {
                new UpdateMyProcessEvents("Completion Rewards...", "Waiting").Update();
                IconCreator.ICDrawingContext.DrawRectangle(ChallengesUtility.DarkBrush(PrimaryColor, 0.3f), null, new Rect(0, y, 1024, 40));
                y += 40;

                foreach (JToken data in bundleCompletionRewardsArray)
                {
                    JArray challengeBundleRewardsArray = data["struct_type"]["properties"].Value <JArray>();
                    if (challengeBundleRewardsArray != null)
                    {
                        string completionCount      = string.Empty;
                        JToken completionCountToken = AssetsUtility.GetPropertyTag <JToken>(challengeBundleRewardsArray, "CompletionCount");
                        if (completionCountToken != null)
                        {
                            completionCount = completionCountToken.Value <string>();
                        }

                        JArray rewardsArray = AssetsUtility.GetPropertyTagText <JArray>(challengeBundleRewardsArray, "Rewards", "data");
                        if (rewardsArray != null)
                        {
                            foreach (JToken reward in rewardsArray)
                            {
                                if (reward["struct_name"] != null && reward["struct_type"] != null && string.Equals(reward["struct_name"].Value <string>(), "AthenaRewardItemReference"))
                                {
                                    JArray dataPropertiesArray = reward["struct_type"]["properties"].Value <JArray>();
                                    if (dataPropertiesArray != null)
                                    {
                                        string rewardPath     = string.Empty;
                                        string rewardQuantity = string.Empty;

                                        JToken quantityToken = AssetsUtility.GetPropertyTag <JToken>(dataPropertiesArray, "Quantity");
                                        if (quantityToken != null)
                                        {
                                            rewardQuantity = quantityToken.Value <string>();
                                        }

                                        JToken questDefinitionToken = AssetsUtility.GetPropertyTagText <JToken>(dataPropertiesArray, "ItemDefinition", "asset_path_name");
                                        if (questDefinitionToken != null)
                                        {
                                            if (questDefinitionToken.Value <string>().Contains("/Game/Items/Tokens/") || questDefinitionToken.Value <string>().Contains("Quest_BR_"))
                                            {
                                                continue;
                                            }

                                            if (string.Equals(questDefinitionToken.Value <string>(), "None", StringComparison.InvariantCultureIgnoreCase))
                                            {
                                                //banners
                                                JToken templateIdToken = AssetsUtility.GetPropertyTag <JToken>(dataPropertiesArray, "TemplateId");
                                                if (templateIdToken != null)
                                                {
                                                    DrawCompletionText(completionCount, PrimaryColor, SecondaryColor, y);
                                                    ChallengeRewards.DrawRewards(templateIdToken.Value <string>(), rewardQuantity, y);
                                                    y += 90;
                                                }
                                            }
                                            else
                                            {
                                                rewardPath = FoldersUtility.FixFortnitePath(questDefinitionToken.Value <string>());

                                                DrawCompletionText(completionCount, PrimaryColor, SecondaryColor, y);
                                                ChallengeRewards.DrawRewards(rewardPath, rewardQuantity, y);
                                                y += 90;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 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."));
            }
        }
Exemplo n.º 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>());
                }
            }
        }
Exemplo n.º 8
0
        private static void SearchWeaponStats(string rowname)
        {
            JArray weaponPropertiesArray = AssetsUtility.GetPropertyTagItemData <JArray>(WeaponsStatsArray, rowname, "properties");

            if (weaponPropertiesArray != null)
            {
                int    count      = 0;
                int    borderY    = 518;
                JToken ReloadTime = AssetsUtility.GetPropertyTag <JToken>(weaponPropertiesArray, "ReloadTime");
                JToken ClipSize   = AssetsUtility.GetPropertyTag <JToken>(weaponPropertiesArray, "ClipSize");
                JToken DmgPB      = AssetsUtility.GetPropertyTag <JToken>(weaponPropertiesArray, "DmgPB");

                if (ReloadTime != null)
                {
                    count++;
                    borderY += 37;
                    IconCreator.ICDrawingContext.DrawRectangle(new SolidColorBrush(ImagesUtility.ParseColorFromHex("#6D6D6D")), null, new Rect(0, borderY, 515, 34));

                    BitmapImage bmp = new BitmapImage();
                    bmp.BeginInit();
                    bmp.CacheOption = BitmapCacheOption.OnLoad;
                    bmp.UriSource   = new Uri(RELOAD_CUSTOM_ICON);
                    bmp.EndInit();
                    bmp.Freeze();

                    Typeface      typeface      = new Typeface(TextsUtility.FBurbank, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal);
                    FormattedText formattedText =
                        new FormattedText(
                            $"{AssetTranslations.SearchTranslation("", "6EA26D1A4252034FBD869A90F9A6E49A", "Reload Time")} ({AssetTranslations.SearchTranslation("", "6BA53D764BA5CC13E821D2A807A72365", "seconds")}) : {ReloadTime.Value<string>()}".ToUpperInvariant(),
                            CultureInfo.CurrentUICulture,
                            FlowDirection.LeftToRight,
                            typeface,
                            25,
                            Brushes.White,
                            IconCreator.PPD
                            );
                    formattedText.TextAlignment = TextAlignment.Center;
                    formattedText.MaxTextWidth  = 515;
                    formattedText.MaxLineCount  = 1;

                    Point textLocation = new Point(0, 587 - formattedText.Height);

                    IconCreator.ICDrawingContext.DrawText(formattedText, textLocation);
                    IconCreator.ICDrawingContext.DrawImage(bmp, new Rect(12, 560, 24, 24));
                }

                if (ClipSize != null)
                {
                    count++;
                    borderY += 37;
                    IconCreator.ICDrawingContext.DrawRectangle(new SolidColorBrush(ImagesUtility.ParseColorFromHex("#6D6D6D")), null, new Rect(0, borderY, 515, 34));

                    BitmapImage bmp = new BitmapImage();
                    bmp.BeginInit();
                    bmp.CacheOption = BitmapCacheOption.OnLoad;
                    bmp.UriSource   = new Uri(MAGSIZE_CUSTOM_ICON);
                    bmp.EndInit();
                    bmp.Freeze();

                    Typeface      typeface      = new Typeface(TextsUtility.FBurbank, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal);
                    FormattedText formattedText =
                        new FormattedText(
                            $"{AssetTranslations.SearchTranslation("", "068239DD4327B36124498C9C5F61C038", "Magazine Size")} : {ClipSize.Value<string>()}".ToUpperInvariant(),
                            CultureInfo.CurrentUICulture,
                            FlowDirection.LeftToRight,
                            typeface,
                            25,
                            Brushes.White,
                            IconCreator.PPD
                            );
                    formattedText.TextAlignment = TextAlignment.Center;
                    formattedText.MaxTextWidth  = 515;
                    formattedText.MaxLineCount  = 1;

                    Point textLocation = new Point(0, 624 - formattedText.Height);

                    IconCreator.ICDrawingContext.DrawText(formattedText, textLocation);
                    IconCreator.ICDrawingContext.DrawImage(bmp, new Rect(12, 598, 24, 24));
                }

                if (DmgPB != null)
                {
                    count++;
                    borderY += 37;
                    IconCreator.ICDrawingContext.DrawRectangle(new SolidColorBrush(ImagesUtility.ParseColorFromHex("#6D6D6D")), null, new Rect(0, borderY, 515, 34));

                    BitmapImage bmp = new BitmapImage();
                    bmp.BeginInit();
                    bmp.CacheOption = BitmapCacheOption.OnLoad;
                    bmp.UriSource   = new Uri(DAMAGE_CUSTOM_ICON);
                    bmp.EndInit();
                    bmp.Freeze();

                    Typeface      typeface      = new Typeface(TextsUtility.FBurbank, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal);
                    FormattedText formattedText =
                        new FormattedText(
                            $"{AssetTranslations.SearchTranslation("", "BF7E3CF34A9ACFF52E95EAAD4F09F133", "Damage to Player")} : {DmgPB.Value<string>()}".ToUpperInvariant(),
                            CultureInfo.CurrentUICulture,
                            FlowDirection.LeftToRight,
                            typeface,
                            25,
                            Brushes.White,
                            IconCreator.PPD
                            );
                    formattedText.TextAlignment = TextAlignment.Center;
                    formattedText.MaxTextWidth  = 515;
                    formattedText.MaxLineCount  = 1;

                    Point textLocation = new Point(0, 661 - formattedText.Height);

                    IconCreator.ICDrawingContext.DrawText(formattedText, textLocation);
                    IconCreator.ICDrawingContext.DrawImage(bmp, new Rect(12, 634, 24, 24));
                }

                //RESIZE
                IconCreator.ICDrawingContext.DrawRectangle(Brushes.Transparent, null, new Rect(new Point(0, 0), new Size(515, 560 + 35 * count)));
            }
        }
Exemplo n.º 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)
        {
            PakReader.PakReader reader = AssetsUtility.GetPakReader(assetPath);
            if (reader != null)
            {
                List <FPakEntry> entriesList = AssetsUtility.GetPakEntries(assetPath);
                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 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)
                            {
                                if (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");
                            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.Where(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"))
                                                               .FirstOrDefault()["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][1]["tag_data"];

                                        //checking the whole array for the reward quantity
                                        //ignoring all Quest and Token until he find the reward quantity
                                        JToken targetQuantity = rewardsDataArray.Where(x =>
                                                                                       !string.Equals(x["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][0]["tag_data"]["struct_type"]["properties"][0]["tag_data"].Value <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"))
                                                                .FirstOrDefault()["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);
                                            if (!BundleData.Any(item => item.TheQuestDescription.Equals(currentData.TheQuestDescription, StringComparison.InvariantCultureIgnoreCase) && item.TheQuestCount == currentData.TheQuestCount))
                                            {
                                                BundleData.Add(currentData);
                                            }
                                        }
                                        else
                                        {
                                            BundleInfosEntry currentData = new BundleInfosEntry(questDescription, questCount, unlockType, "", "");
                                            if (!BundleData.Any(item => item.TheQuestDescription.Equals(currentData.TheQuestDescription, StringComparison.InvariantCultureIgnoreCase) && item.TheQuestCount == currentData.TheQuestCount))
                                            {
                                                BundleData.Add(currentData);
                                            }
                                        }
                                    }
                                    catch (Exception)
                                    {
                                        if (hiddenRewardsDataArray != null)
                                        {
                                            if (hiddenRewardsDataArray[0]["struct_name"] != null && hiddenRewardsDataArray[0]["struct_type"] != null && string.Equals(hiddenRewardsDataArray[0]["struct_name"].Value <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);
                                                    if (!BundleData.Any(item => item.TheQuestDescription.Equals(currentData.TheQuestDescription, StringComparison.InvariantCultureIgnoreCase) && item.TheQuestCount == currentData.TheQuestCount))
                                                    {
                                                        BundleData.Add(currentData);
                                                    }
                                                }
                                            }
                                        }
                                        else
                                        {
                                            BundleInfosEntry currentData = new BundleInfosEntry(questDescription, questCount, unlockType, "", "");
                                            if (!BundleData.Any(item => item.TheQuestDescription.Equals(currentData.TheQuestDescription, StringComparison.InvariantCultureIgnoreCase) && item.TheQuestCount == currentData.TheQuestCount))
                                            {
                                                BundleData.Add(currentData);
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                BundleInfosEntry currentData = new BundleInfosEntry(questDescription, questCount, unlockType, "", "");
                                if (!BundleData.Any(item => item.TheQuestDescription.Equals(currentData.TheQuestDescription, StringComparison.InvariantCultureIgnoreCase) && item.TheQuestCount == currentData.TheQuestCount))
                                {
                                    BundleData.Add(currentData);
                                }
                            }

                            //catch 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)
                                        {
                                            //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.Contains("/" + primaryAssetNameToken.Value <string>())).Select(d => d.Key).FirstOrDefault();
                                            if (!string.IsNullOrEmpty(primaryAssetNameFullPath))
                                            {
                                                new UpdateMyProcessEvents(System.IO.Path.GetFileNameWithoutExtension(primaryAssetNameFullPath), "Waiting").Update();
                                                GetQuestData(BundleProperties, primaryAssetNameFullPath.Substring(0, primaryAssetNameFullPath.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase)));
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }