Ejemplo n.º 1
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)));
            }
        }
Ejemplo n.º 2
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))
            {
                PakReader.PakReader reader = AssetsUtility.GetPakReader(assetPath.Substring(0, assetPath.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase)));
                if (reader != null)
                {
                    List <FPakEntry> entriesList = AssetsUtility.GetPakEntries(assetPath.Substring(0, assetPath.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase)));
                    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 propertiesArray = AssetMainToken["rows"].Value <JArray>();
                            if (propertiesArray != null)
                            {
                                JArray target = AssetsUtility.GetPropertyTagItemData <JArray>(propertiesArray, bannerName, "properties");
                                if (target != null)
                                {
                                    JToken largeImage = target.Where(x => string.Equals(x["name"].Value <string>(), "LargeImage")).FirstOrDefault();
                                    JToken smallImage = target.Where(x => string.Equals(x["name"].Value <string>(), "SmallImage")).FirstOrDefault();
                                    if (largeImage != null || smallImage != null)
                                    {
                                        JToken assetPathName =
                                            largeImage != null ? largeImage["tag_data"]["asset_path_name"] :
                                            smallImage != null ? smallImage["tag_data"]["asset_path_name"] : null;

                                        if (assetPathName != null)
                                        {
                                            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("pack://application:,,,/Resources/unknown512.png")).Stream;
                bmp.EndInit();
                bmp.Freeze();
                IconCreator.ICDrawingContext.DrawImage(bmp, new Rect(902, y + 3, 64, 64));
            }
        }
Ejemplo n.º 3
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)));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }