Beispiel #1
0
        /// <summary>
        /// JohnWick is case sensitive so that way we search the item in the dictionary with CurrentCultureIgnoreCase and if he exists, we take his name
        /// so the name taken will be working for JohnWick
        /// </summary>
        /// <param name="item"></param>
        public static void DrawRewardIcon(string item)
        {
            ItemIcon.ItemIconPath = string.Empty;
            var value = ThePak.AllpaksDictionary.Where(x => string.Equals(x.Key, item, StringComparison.CurrentCultureIgnoreCase)).Select(d => d.Key).FirstOrDefault();

            if (value != null)
            {
                string extractedIconPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[value], value);
                if (extractedIconPath != null)
                {
                    if (extractedIconPath.Contains(".uasset") || extractedIconPath.Contains(".uexp") || extractedIconPath.Contains(".ubulk"))
                    {
                        JohnWick.MyAsset = new PakAsset(extractedIconPath.Substring(0, extractedIconPath.LastIndexOf('.')));
                        try
                        {
                            if (JohnWick.MyAsset.GetSerialized() != null)
                            {
                                var itemId = ItemsIdParser.FromJson(JToken.Parse(JohnWick.MyAsset.GetSerialized()).ToString());
                                for (int i = 0; i < itemId.Length; i++)
                                {
                                    ItemIcon.SearchAthIteDefIcon(itemId[i]);

                                    drawIcon(item);
                                }
                            }
                        }
                        catch (JsonSerializationException)
                        {
                            //do not crash when JsonSerialization does weird stuff
                        }
                    }
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// this is only triggered for weapons
 /// draw the damage per bullet as well as the reload time
 /// </summary>
 /// <param name="weaponName"></param>
 /// <param name="myGraphic"></param>
 private static void DrawWeaponStat(string filename, string weaponName, Graphics myGraphic)
 {
     if (weaponsStatsArray == null || !weaponStatsFilename.Equals(filename))
     {
         ItemIcon.ItemIconPath = string.Empty;
         string extractedWeaponsStatPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[filename], filename);
         if (extractedWeaponsStatPath != null)
         {
             if (extractedWeaponsStatPath.Contains(".uasset") || extractedWeaponsStatPath.Contains(".uexp") || extractedWeaponsStatPath.Contains(".ubulk"))
             {
                 JohnWick.MyAsset = new PakAsset(extractedWeaponsStatPath.Substring(0, extractedWeaponsStatPath.LastIndexOf('.')));
                 try
                 {
                     if (JohnWick.MyAsset.GetSerialized() != null)
                     {
                         dynamic AssetData = JsonConvert.DeserializeObject(JohnWick.MyAsset.GetSerialized());
                         weaponsStatsArray   = JArray.FromObject(AssetData);
                         weaponStatsFilename = filename;
                         loopingLol(weaponName, myGraphic);
                     }
                 }
                 catch (JsonSerializationException)
                 {
                     //do not crash when JsonSerialization does weird stuff
                 }
             }
         }
     }
     else
     {
         loopingLol(weaponName, myGraphic);
     }
 }
Beispiel #3
0
 /// <summary>
 /// this is only triggered for weapons
 /// draw the damage per bullet as well as the reload time
 /// </summary>
 /// <param name="weaponName"></param>
 /// <param name="myGraphic"></param>
 private static void DrawWeaponStat(string weaponName, Graphics myGraphic)
 {
     if (jo == null)
     {
         ItemIcon.ItemIconPath = string.Empty;
         string extractedWeaponsStatPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary["AthenaRangedWeapons"], "AthenaRangedWeapons");
         if (extractedWeaponsStatPath != null)
         {
             if (extractedWeaponsStatPath.Contains(".uasset") || extractedWeaponsStatPath.Contains(".uexp") || extractedWeaponsStatPath.Contains(".ubulk"))
             {
                 JohnWick.MyAsset = new PakAsset(extractedWeaponsStatPath.Substring(0, extractedWeaponsStatPath.LastIndexOf('.')));
                 try
                 {
                     if (JohnWick.MyAsset.GetSerialized() != null)
                     {
                         string parsedJson = JToken.Parse(JohnWick.MyAsset.GetSerialized()).ToString().TrimStart('[').TrimEnd(']');
                         jo = JObject.Parse(parsedJson);
                         loopingLol(weaponName, myGraphic);
                     }
                 }
                 catch (JsonSerializationException)
                 {
                     //do not crash when JsonSerialization does weird stuff
                 }
             }
         }
     }
     else
     {
         loopingLol(weaponName, myGraphic);
     }
 }
Beispiel #4
0
 private static void DrawCosmeticUff(JToken theItem, Graphics myGraphic)
 {
     if (tertiaryCategoriesArray == null)
     {
         string extractedCosmeticsSetsPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary["ItemCategories"], "ItemCategories");
         if (extractedCosmeticsSetsPath != null)
         {
             if (extractedCosmeticsSetsPath.Contains(".uasset") || extractedCosmeticsSetsPath.Contains(".uexp") || extractedCosmeticsSetsPath.Contains(".ubulk"))
             {
                 JohnWick.MyAsset = new PakAsset(extractedCosmeticsSetsPath.Substring(0, extractedCosmeticsSetsPath.LastIndexOf('.')));
                 try
                 {
                     if (JohnWick.MyAsset.GetSerialized() != null)
                     {
                         dynamic AssetData          = JsonConvert.DeserializeObject(JohnWick.MyAsset.GetSerialized());
                         JToken  tertiaryCategories = AssetData[0]["TertiaryCategories"];
                         if (tertiaryCategories != null)
                         {
                             tertiaryCategoriesArray = tertiaryCategories.Value <JArray>();
                             DrawCosmeticUffFromArray(theItem, myGraphic);
                         }
                     }
                 }
                 catch (JsonSerializationException)
                 {
                     //do not crash when JsonSerialization does weird stuff
                 }
             }
         }
     }
     else
     {
         DrawCosmeticUffFromArray(theItem, myGraphic);
     }
 }
Beispiel #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="selectedLanguage"></param>
        /// <returns></returns>
        private static void getMyLocRes(string selectedLanguage)
        {
            if (ThePak.AllpaksDictionary != null)
            {
                if (ThePak.AllpaksDictionary.ContainsKey("Game_BR.locres"))
                {
                    string locResPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary["Game_BR.locres"], "Game_BR.locres");

                    LocResSerializer.setLocRes(locResPath.Replace("zh-Hant", selectedLanguage));
                }
                else
                {
                    new UpdateMyConsole("Game_BR.locres ", Color.Crimson).AppendToConsole();
                    new UpdateMyConsole("not found", Color.Black, true).AppendToConsole();
                    new UpdateMyConsole("Icon language set to ", Color.Black).AppendToConsole();
                    new UpdateMyConsole("English", Color.CornflowerBlue, true).AppendToConsole();

                    Properties.Settings.Default.IconLanguage = "English";
                    Properties.Settings.Default.Save();
                }

                if (ThePak.AllpaksDictionary.ContainsKey("Game_StW.locres"))
                {
                    string locResPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary["Game_StW.locres"], "Game_StW.locres");

                    LocResSerializer.setLocRes(locResPath.Replace("zh-Hant", selectedLanguage), true);
                }
                else
                {
                    new UpdateMyConsole("Game_StW.locres ", Color.Crimson).AppendToConsole();
                    new UpdateMyConsole("not found", Color.Black, true).AppendToConsole();
                }
            }
        }
        /// <summary>
        /// "BannerIcons" contains all banners id, their image path and more
        /// so basically we export and serialize "BannerIcons", locate where our banner id is, with FindTokens
        /// after that we only have what we want with token.ToString() -> "SmallImage", "LargeImage", "asset_path_name", "CategoryRowName", "DisplayName", "DisplayDescription"
        /// so we can just parse token.ToString() to properly get the LargeImage's asset_path_name or SmallImage's asset_path_name and draw
        /// </summary>
        /// <param name="bannerName"></param>
        public static void DrawRewardBanner(string bannerName)
        {
            ItemIcon.ItemIconPath = string.Empty;
            string extractedBannerPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary["BannerIcons"], "BannerIcons");

            if (extractedBannerPath != null)
            {
                if (extractedBannerPath.Contains(".uasset") || extractedBannerPath.Contains(".uexp") || extractedBannerPath.Contains(".ubulk"))
                {
                    JohnWick.MyAsset = new PakAsset(extractedBannerPath.Substring(0, extractedBannerPath.LastIndexOf('.')));
                    try
                    {
                        if (JohnWick.MyAsset.GetSerialized() != null)
                        {
                            dynamic AssetData  = JsonConvert.DeserializeObject(JohnWick.MyAsset.GetSerialized());
                            JArray  AssetArray = JArray.FromObject(AssetData);

                            JToken bannerToken = ((JObject)AssetArray[0]).GetValue(bannerName, StringComparison.InvariantCultureIgnoreCase);
                            if (bannerToken != null)
                            {
                                JToken largeImage = bannerToken["LargeImage"];
                                JToken smallImage = bannerToken["SmallImage"];
                                if (largeImage != null)
                                {
                                    JToken assetPathName = largeImage["asset_path_name"];
                                    if (assetPathName != null)
                                    {
                                        string textureFile = Path.GetFileName(assetPathName.Value <string>()).Substring(0, Path.GetFileName(assetPathName.Value <string>()).LastIndexOf('.'));
                                        ItemIcon.ItemIconPath = JohnWick.AssetToTexture2D(textureFile);
                                        drawIcon();
                                    }
                                }
                                else if (smallImage != null)
                                {
                                    JToken assetPathName = smallImage["asset_path_name"];
                                    if (assetPathName != null)
                                    {
                                        string textureFile = Path.GetFileName(assetPathName.Value <string>()).Substring(0, Path.GetFileName(assetPathName.Value <string>()).LastIndexOf('.'));
                                        ItemIcon.ItemIconPath = JohnWick.AssetToTexture2D(textureFile);
                                        drawIcon();
                                    }
                                }
                            }
                        }
                    }
                    catch (JsonSerializationException)
                    {
                        //do not crash when JsonSerialization does weird stuff
                    }
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// This is only triggered if ThePak.CurrentUsedItem is a weapon id, it's to display the bullet type
        /// extract, serialize and parse the ammoFile, search a Large or Small icon, display this icon at the top left of the rarity image
        /// </summary>
        /// <param name="ammoFile"></param>
        /// <param name="toDrawOn"></param>
        public static void GetAmmoData(string ammoFile, Graphics toDrawOn)
        {
            string ammoFilePath;

            if (ThePak.CurrentUsedPakGuid != null && ThePak.CurrentUsedPakGuid != "0-0-0-0")
            {
                ammoFilePath = JohnWick.ExtractAsset(ThePak.CurrentUsedPak, ammoFile.Substring(ammoFile.LastIndexOf('.') + 1));
            }
            else
            {
                ammoFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[ammoFile.Substring(ammoFile.LastIndexOf('.') + 1)], ammoFile.Substring(ammoFile.LastIndexOf('.') + 1));
            }

            if (ammoFilePath != null)
            {
                if (ammoFilePath.Contains(".uasset") || ammoFilePath.Contains(".uexp") || ammoFilePath.Contains(".ubulk"))
                {
                    JohnWick.MyAsset = new PakAsset(ammoFilePath.Substring(0, ammoFilePath.LastIndexOf('.')));
                    try
                    {
                        if (JohnWick.MyAsset.GetSerialized() != null)
                        {
                            string parsedJson = JToken.Parse(JohnWick.MyAsset.GetSerialized()).ToString();
                            var    ammoId     = ItemsIdParser.FromJson(parsedJson);
                            for (int i = 0; i < ammoId.Length; i++)
                            {
                                SearchLargeSmallIcon(ammoId[i]);

                                if (File.Exists(ItemIconPath))
                                {
                                    Image itemIcon;
                                    using (var bmpTemp = new Bitmap(ItemIconPath))
                                    {
                                        itemIcon = new Bitmap(bmpTemp);
                                    }
                                    toDrawOn.DrawImage(ImageUtilities.ResizeImage(itemIcon, 64, 64), new Point(6, 6));
                                }
                                else
                                {
                                    Image itemIcon = Resources.unknown512;
                                    toDrawOn.DrawImage(ImageUtilities.ResizeImage(itemIcon, 64, 64), new Point(6, 6));
                                }
                            }
                        }
                    }
                    catch (JsonSerializationException)
                    {
                        //do not crash when JsonSerialization does weird stuff
                    }
                }
            }
        }
Beispiel #8
0
        /// <summary>
        /// "BannerIcons" contains all banners id, their image path and more
        /// so basically we export and serialize "BannerIcons", locate where our banner id is, with FindTokens
        /// after that we only have what we want with token.ToString() -> "SmallImage", "LargeImage", "asset_path_name", "CategoryRowName", "DisplayName", "DisplayDescription"
        /// so we can just parse token.ToString() to properly get the LargeImage's asset_path_name or SmallImage's asset_path_name and draw
        /// </summary>
        /// <param name="bannerName"></param>
        public static void DrawRewardBanner(string bannerName)
        {
            ItemIcon.ItemIconPath = string.Empty;
            string extractedBannerPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary["BannerIcons"], "BannerIcons");

            if (extractedBannerPath != null)
            {
                if (extractedBannerPath.Contains(".uasset") || extractedBannerPath.Contains(".uexp") || extractedBannerPath.Contains(".ubulk"))
                {
                    JohnWick.MyAsset = new PakAsset(extractedBannerPath.Substring(0, extractedBannerPath.LastIndexOf('.')));
                    try
                    {
                        if (JohnWick.MyAsset.GetSerialized() != null)
                        {
                            string  parsedJson = JToken.Parse(JohnWick.MyAsset.GetSerialized()).ToString().TrimStart('[').TrimEnd(']');
                            JObject jo         = JObject.Parse(parsedJson);
                            foreach (JToken token in jo.FindTokens(bannerName))
                            {
                                var bannerId = Parser.Banners.BannersParser.FromJson(token.ToString());

                                if (bannerId.LargeImage != null)
                                {
                                    string textureFile = Path.GetFileName(bannerId.LargeImage.AssetPathName)
                                                         ?.Substring(0,
                                                                     Path.GetFileName(bannerId.LargeImage.AssetPathName).LastIndexOf('.'));

                                    ItemIcon.ItemIconPath = JohnWick.AssetToTexture2D(textureFile);
                                }
                                else if (bannerId.SmallImage != null)
                                {
                                    string textureFile = Path.GetFileName(bannerId.SmallImage.AssetPathName)
                                                         ?.Substring(0,
                                                                     Path.GetFileName(bannerId.SmallImage.AssetPathName).LastIndexOf('.'));

                                    ItemIcon.ItemIconPath = JohnWick.AssetToTexture2D(textureFile);
                                }

                                drawIcon(bannerName);
                            }
                        }
                    }
                    catch (JsonSerializationException)
                    {
                        //do not crash when JsonSerialization does weird stuff
                    }
                }
            }
        }
        public static JToken setSchematicData(JToken schematicAsset)
        {
            schematicInfoList = new List <SchematicInfoEntry>();
            JToken toReturn = null;

            JToken craftingRecipe = schematicAsset["CraftingRecipe"];

            if (craftingRecipe != null)
            {
                JToken dataTable = craftingRecipe["DataTable"];
                if (dataTable != null)
                {
                    string dataTableFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[dataTable.Value <string>()], dataTable.Value <string>());
                    if (!string.IsNullOrEmpty(dataTableFilePath))
                    {
                        if (dataTableFilePath.Contains(".uasset") || dataTableFilePath.Contains(".uexp") || dataTableFilePath.Contains(".ubulk"))
                        {
                            JohnWick.MyAsset = new PakAsset(dataTableFilePath.Substring(0, dataTableFilePath.LastIndexOf('.')));
                            try
                            {
                                if (JohnWick.MyAsset.GetSerialized() != null)
                                {
                                    dynamic AssetData  = JsonConvert.DeserializeObject(JohnWick.MyAsset.GetSerialized());
                                    JArray  AssetArray = JArray.FromObject(AssetData);

                                    JToken weaponRowName = ((JObject)AssetArray[0]).GetValue(craftingRecipe["RowName"].Value <string>(), StringComparison.OrdinalIgnoreCase);
                                    if (weaponRowName != null)
                                    {
                                        toReturn = getSchematicRecipeResult(weaponRowName);
                                        registerSchematicRecipeCosts(weaponRowName);
                                    }
                                }
                            }
                            catch (JsonSerializationException)
                            {
                                //do not crash when JsonSerialization does weird stuff
                            }
                        }
                    }
                }
            }
            else
            {
                throw new ArgumentException("Not enough informations to create an icon about this schematic - Missing: \"CraftingRecipe\"");
            }

            return(toReturn);
        }
Beispiel #10
0
        /// <summary>
        /// this is only triggered for wraps, in case the featured (weapon render) image is drawn
        /// also draw the non featured image to make it clear it's a wrap, not a weapon
        /// </summary>
        /// <param name="theItem"></param>
        /// <param name="myGraphic"></param>
        private static void DrawAdditionalImage(ItemsIdParser theItem, Graphics myGraphic)
        {
            string wrapAddImg = theItem.LargePreviewImage.AssetPathName.Substring(theItem.LargePreviewImage.AssetPathName.LastIndexOf(".", StringComparison.Ordinal) + 1);

            ItemIcon.ItemIconPath = JohnWick.AssetToTexture2D(wrapAddImg);

            if (File.Exists(ItemIcon.ItemIconPath))
            {
                Image itemIcon;
                using (var bmpTemp = new Bitmap(ItemIcon.ItemIconPath))
                {
                    itemIcon = new Bitmap(bmpTemp);
                }
                myGraphic.DrawImage(ImageUtilities.ResizeImage(itemIcon, 122, 122), new Point(395, 282));
            }
        }
Beispiel #11
0
        /// <summary>
        /// convert Large or Small image to a png image
        /// </summary>
        /// <param name="theItem"></param>
        private static void SearchLargeSmallIcon(ItemsIdParser theItem)
        {
            if (theItem.LargePreviewImage != null)
            {
                string textureFile = Path.GetFileName(theItem.LargePreviewImage.AssetPathName)?.Substring(0,
                                                                                                          Path.GetFileName(theItem.LargePreviewImage.AssetPathName).LastIndexOf('.'));

                ItemIconPath = JohnWick.AssetToTexture2D(textureFile);
            }
            else if (theItem.SmallPreviewImage != null)
            {
                string textureFile = Path.GetFileName(theItem.SmallPreviewImage.AssetPathName)?.Substring(0,
                                                                                                          Path.GetFileName(theItem.SmallPreviewImage.AssetPathName).LastIndexOf('.'));

                ItemIconPath = JohnWick.AssetToTexture2D(textureFile);
            }
        }
Beispiel #12
0
        private static string DrawCosmeticSet(string setName)
        {
            if (cosmeticsSetsArray == null)
            {
                string extractedCosmeticsSetsPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary["CosmeticSets"], "CosmeticSets");

                if (extractedCosmeticsSetsPath != null)
                {
                    if (extractedCosmeticsSetsPath.Contains(".uasset") || extractedCosmeticsSetsPath.Contains(".uexp") || extractedCosmeticsSetsPath.Contains(".ubulk"))
                    {
                        JohnWick.MyAsset = new PakAsset(extractedCosmeticsSetsPath.Substring(0, extractedCosmeticsSetsPath.LastIndexOf('.')));
                        try
                        {
                            if (JohnWick.MyAsset.GetSerialized() != null)
                            {
                                dynamic AssetData = JsonConvert.DeserializeObject(JohnWick.MyAsset.GetSerialized());
                                cosmeticsSetsArray = JArray.FromObject(AssetData);
                                return(searchSetName(setName));
                            }
                            else
                            {
                                return("");
                            }
                        }
                        catch (JsonSerializationException)
                        {
                            return("");
                            //do not crash when JsonSerialization does weird stuff
                        }
                    }
                    else
                    {
                        return("");
                    }
                }
                else
                {
                    return("");
                }
            }
            else
            {
                return(searchSetName(setName));
            }
        }
Beispiel #13
0
        private static void drawIconSeparator(string iconName)
        {
            string texture = JohnWick.AssetToTexture2D(iconName);

            if (File.Exists(texture))
            {
                Image itemIcon;
                using (var bmpTemp = new Bitmap(texture))
                {
                    itemIcon = new Bitmap(bmpTemp);
                }

                toDrawOn.FillRectangle(new SolidBrush(Color.FromArgb(100, headerColor.R, headerColor.G, headerColor.B)), new Rectangle(25, theY, 50, 35));

                toDrawOn.DrawImage(ImageUtilities.ResizeImage(itemIcon, 32, 32), new Point(50 - 15, theY + 2));

                theY += 40;
            }
        }
Beispiel #14
0
        /// <summary>
        /// This is only triggered if ThePak.CurrentUsedItem is a weapon id, it's to display the bullet type
        /// extract, serialize and parse the ammoFile, search a Large or Small icon, display this icon at the top left of the rarity image
        /// </summary>
        /// <param name="ammoFile"></param>
        /// <param name="toDrawOn"></param>
        public static void GetAmmoData(string ammoFile, Graphics toDrawOn)
        {
            string ammoFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[ammoFile.Substring(ammoFile.LastIndexOf('.') + 1)], ammoFile.Substring(ammoFile.LastIndexOf('.') + 1));

            if (ammoFilePath != null)
            {
                if (ammoFilePath.Contains(".uasset") || ammoFilePath.Contains(".uexp") || ammoFilePath.Contains(".ubulk"))
                {
                    JohnWick.MyAsset = new PakAsset(ammoFilePath.Substring(0, ammoFilePath.LastIndexOf('.')));
                    try
                    {
                        if (JohnWick.MyAsset.GetSerialized() != null)
                        {
                            dynamic AssetData  = JsonConvert.DeserializeObject(JohnWick.MyAsset.GetSerialized());
                            JArray  AssetArray = JArray.FromObject(AssetData);

                            SearchLargeSmallIcon(AssetArray[0]);

                            if (File.Exists(ItemIconPath))
                            {
                                Image itemIcon;
                                using (var bmpTemp = new Bitmap(ItemIconPath))
                                {
                                    itemIcon = new Bitmap(bmpTemp);
                                }
                                toDrawOn.DrawImage(ImageUtilities.ResizeImage(itemIcon, 64, 64), new Point(6, 6));
                            }
                            else
                            {
                                Image itemIcon = Resources.unknown512;
                                toDrawOn.DrawImage(ImageUtilities.ResizeImage(itemIcon, 64, 64), new Point(6, 6));
                            }
                        }
                    }
                    catch (JsonSerializationException)
                    {
                        //do not crash when JsonSerialization does weird stuff
                    }
                }
            }
        }
Beispiel #15
0
 private static void DrawSeriesBackground(JToken theItem, Graphics toDrawOn, string theSeries)
 {
     if (theSeries.Equals("MarvelSeries"))
     {
         DrawBackground(toDrawOn, Color.FromArgb(255, 203, 35, 45), Color.FromArgb(255, 127, 14, 29), Color.FromArgb(255, 255, 67, 61));
     }
     else if (theSeries.Equals("CUBESeries"))
     {
         DrawBackground(toDrawOn, Color.FromArgb(255, 157, 0, 108), Color.FromArgb(255, 97, 0, 100), Color.FromArgb(255, 175, 27, 185));
         string cubeBG = JohnWick.AssetToTexture2D("T-Cube-Background");
         if (!string.IsNullOrEmpty(cubeBG))
         {
             Image itemIcon;
             using (var bmpTemp = new Bitmap(cubeBG))
             {
                 itemIcon = new Bitmap(bmpTemp);
             }
             Image opacityImage = ImageUtilities.SetImageOpacity(itemIcon, (float)0.2);
             toDrawOn.DrawImage(ImageUtilities.ResizeImage(opacityImage, 512, 512), new Point(5, 5));
         }
     }
     else if (theSeries.Equals("DCUSeries"))
     {
         DrawBackground(toDrawOn, Color.FromArgb(255, 45, 68, 93), Color.FromArgb(255, 16, 25, 40), Color.FromArgb(255, 62, 94, 122));
         string cubeBG = JohnWick.AssetToTexture2D("T-BlackMonday-Background");
         if (!string.IsNullOrEmpty(cubeBG))
         {
             Image itemIcon;
             using (var bmpTemp = new Bitmap(cubeBG))
             {
                 itemIcon = new Bitmap(bmpTemp);
             }
             Image opacityImage = ImageUtilities.SetImageOpacity(itemIcon, (float)0.6);
             toDrawOn.DrawImage(ImageUtilities.ResizeImage(opacityImage, 512, 512), new Point(5, 5));
         }
     }
     else
     {
         DrawRarityBackground(theItem, toDrawOn);
     }
 }
Beispiel #16
0
        /// <summary>
        /// JohnWick is case sensitive so that way we search the item in the dictionary with CurrentCultureIgnoreCase and if he exists, we take his name
        /// so the name taken will be working for JohnWick
        /// </summary>
        /// <param name="item"></param>
        public static void DrawRewardIcon(string item)
        {
            ItemIcon.ItemIconPath = string.Empty;
            var value = ThePak.AllpaksDictionary.Where(x => string.Equals(x.Key, item, StringComparison.CurrentCultureIgnoreCase)).Select(d => d.Key).FirstOrDefault();

            if (value != null)
            {
                string extractedIconPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[value], value);
                if (extractedIconPath != null)
                {
                    if (extractedIconPath.Contains(".uasset") || extractedIconPath.Contains(".uexp") || extractedIconPath.Contains(".ubulk"))
                    {
                        JohnWick.MyAsset = new PakAsset(extractedIconPath.Substring(0, extractedIconPath.LastIndexOf('.')));
                        try
                        {
                            if (JohnWick.MyAsset.GetSerialized() != null)
                            {
                                dynamic AssetData  = JsonConvert.DeserializeObject(JohnWick.MyAsset.GetSerialized());
                                JArray  AssetArray = JArray.FromObject(AssetData);

                                ItemIcon.SearchAthIteDefIcon(AssetArray[0]);

                                drawIcon();
                            }
                        }
                        catch (JsonSerializationException)
                        {
                            //do not crash when JsonSerialization does weird stuff
                        }
                    }
                }
                else
                {
                    drawIcon();
                }
            }
            else
            {
                drawIcon();
            }
        }
Beispiel #17
0
        private static void drawForbyteReward()
        {
            string textureFile = "T_UI_ChallengeTile_Fortbytes";

            ItemIcon.ItemIconPath = JohnWick.AssetToTexture2D(textureFile);

            if (File.Exists(ItemIcon.ItemIconPath))
            {
                Image itemIcon;
                using (var bmpTemp = new Bitmap(ItemIcon.ItemIconPath))
                {
                    itemIcon = new Bitmap(bmpTemp);
                }
                toDrawOn.DrawImage(ImageUtilities.ResizeImage(itemIcon, 110, 110), new Point(2300, theY + 6));
            }
            else
            {
                Image itemIcon = Resources.unknown512;
                toDrawOn.DrawImage(ImageUtilities.ResizeImage(itemIcon, 110, 110), new Point(2300, theY + 6));
            }
        }
Beispiel #18
0
        /// <summary>
        /// 1. if loading a dynamic pak we have to switch between keys because the translation file is the main paks hence string oldKey is there
        /// 2. smh if loading a dynamic pak, the guid isn't reset when registering, the temp solution is to fake the guid
        /// </summary>
        /// <param name="selectedLanguage"></param>
        /// <returns></returns>
        private static string getMyLocRes(string selectedLanguage)
        {
            if (ThePak.AllpaksDictionary != null && ThePak.AllpaksDictionary["Game_BR.locres"] != null)
            {
                string oldKey  = JohnWick.MyKey;                                //get the old key
                string oldGuid = ThePak.CurrentUsedPakGuid;                     //get the old guid

                JohnWick.MyKey            = Properties.Settings.Default.AESKey; //set the main key to extract
                ThePak.CurrentUsedPakGuid = "0-0-0-0";                          //fake the guid -> writeFile need this guid to get the mountPoint, otherwise it crashes

                string locResPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary["Game_BR.locres"], "Game_BR.locres");

                JohnWick.MyKey            = oldKey;  //set the old key
                ThePak.CurrentUsedPakGuid = oldGuid; //set the old guid

                return(LocResSerializer.StringFinder(locResPath.Replace("zh-Hant", selectedLanguage)));
            }
            else
            {
                return("");
            }
        }
        public static JToken getSchematicRecipeResult(JToken schematicDataTable)
        {
            JToken toReturn = null;

            JToken recipeResults = schematicDataTable["RecipeResults"];

            if (recipeResults != null)
            {
                JToken primaryAssetName = recipeResults[0]["ItemPrimaryAssetId"]["PrimaryAssetName"];
                if (primaryAssetName != null)
                {
                    string primaryAssetNameInDict    = ThePak.AllpaksDictionary.Where(x => string.Equals(x.Key, primaryAssetName.Value <string>(), StringComparison.CurrentCultureIgnoreCase)).Select(d => d.Key).FirstOrDefault();
                    string primaryAssetTableFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[primaryAssetNameInDict], primaryAssetNameInDict);
                    if (!string.IsNullOrEmpty(primaryAssetTableFilePath))
                    {
                        if (primaryAssetTableFilePath.Contains(".uasset") || primaryAssetTableFilePath.Contains(".uexp") || primaryAssetTableFilePath.Contains(".ubulk"))
                        {
                            JohnWick.MyAsset = new PakAsset(primaryAssetTableFilePath.Substring(0, primaryAssetTableFilePath.LastIndexOf('.')));
                            try
                            {
                                if (JohnWick.MyAsset.GetSerialized() != null)
                                {
                                    dynamic primaryAssetData  = JsonConvert.DeserializeObject(JohnWick.MyAsset.GetSerialized());
                                    JArray  primaryAssetArray = JArray.FromObject(primaryAssetData);
                                    toReturn = primaryAssetArray[0];
                                }
                            }
                            catch (JsonSerializationException)
                            {
                                //do not crash when JsonSerialization does weird stuff
                            }
                        }
                    }
                }
            }

            return(toReturn);
        }
Beispiel #20
0
        private static Image getUffFromBrush(int index)
        {
            JToken categoryBrush = tertiaryCategoriesArray[index]["CategoryBrush"];

            if (categoryBrush != null)
            {
                JToken brush_XXS = categoryBrush["Brush_XXS"];
                if (brush_XXS != null)
                {
                    JToken resourceObject = brush_XXS["ResourceObject"];
                    if (resourceObject != null)
                    {
                        string texture = JohnWick.AssetToTexture2D(resourceObject.Value <string>());
                        if (!string.IsNullOrEmpty(texture))
                        {
                            return(Image.FromFile(texture));
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Beispiel #21
0
        /// <summary>
        /// convert Large or Small image to a png image
        /// </summary>
        /// <param name="theItem"></param>
        private static void SearchLargeSmallIcon(JToken theItem)
        {
            JToken largePreviewImage = theItem["LargePreviewImage"];
            JToken smallPreviewImage = theItem["SmallPreviewImage"];
            JToken iconBrush         = theItem["IconBrush"];

            if (largePreviewImage != null)
            {
                JToken assetPathName = largePreviewImage["asset_path_name"];
                if (assetPathName != null)
                {
                    string textureFile = Path.GetFileName(assetPathName.Value <string>()).Substring(0, Path.GetFileName(assetPathName.Value <string>()).LastIndexOf('.'));

                    ItemIconPath = JohnWick.AssetToTexture2D(textureFile);
                }
            }
            else if (smallPreviewImage != null)
            {
                JToken assetPathName = smallPreviewImage["asset_path_name"];
                if (assetPathName != null)
                {
                    string textureFile = Path.GetFileName(assetPathName.Value <string>()).Substring(0, Path.GetFileName(assetPathName.Value <string>()).LastIndexOf('.'));

                    ItemIconPath = JohnWick.AssetToTexture2D(textureFile);
                }
            }
            else if (iconBrush != null)
            {
                JToken resourceObject = iconBrush["ResourceObject"];
                if (resourceObject != null)
                {
                    string textureFile = resourceObject.Value <string>();

                    ItemIconPath = JohnWick.AssetToTexture2D(textureFile);
                }
            }
        }
Beispiel #22
0
        /// <summary>
        /// this is only triggered for wraps, in case the featured (weapon render) image is drawn
        /// also draw the non featured image to make it clear it's a wrap, not a weapon
        /// </summary>
        /// <param name="theItem"></param>
        /// <param name="myGraphic"></param>
        private static void DrawAdditionalImage(JToken theItem, Graphics myGraphic)
        {
            JToken largePreviewImage = theItem["LargePreviewImage"];

            if (largePreviewImage != null)
            {
                JToken assetPathName = largePreviewImage["asset_path_name"];
                if (assetPathName != null)
                {
                    string textureFile = Path.GetFileName(assetPathName.Value <string>()).Substring(0, Path.GetFileName(assetPathName.Value <string>()).LastIndexOf('.'));

                    ItemIcon.ItemIconPath = JohnWick.AssetToTexture2D(textureFile);
                    if (File.Exists(ItemIcon.ItemIconPath))
                    {
                        Image itemIcon;
                        using (var bmpTemp = new Bitmap(ItemIcon.ItemIconPath))
                        {
                            itemIcon = new Bitmap(bmpTemp);
                        }
                        myGraphic.DrawImage(ImageUtilities.ResizeImage(itemIcon, 122, 122), new Point(275, 272));
                    }
                }
            }
        }
Beispiel #23
0
        public static void createIngredientIcon()
        {
            for (int i = 0; i < SchematicItemInfos.schematicInfoList.Count; i++)
            {
                string ingredientsFileName = ThePak.AllpaksDictionary.Where(x => string.Equals(x.Key, SchematicItemInfos.schematicInfoList[i].theIngredientItemDefinition, StringComparison.CurrentCultureIgnoreCase)).Select(d => d.Key).FirstOrDefault();
                if (!string.IsNullOrEmpty(ingredientsFileName))
                {
                    string extractedIconPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[ingredientsFileName], ingredientsFileName);
                    if (extractedIconPath != null)
                    {
                        if (extractedIconPath.Contains(".uasset") || extractedIconPath.Contains(".uexp") || extractedIconPath.Contains(".ubulk"))
                        {
                            JohnWick.MyAsset = new PakAsset(extractedIconPath.Substring(0, extractedIconPath.LastIndexOf('.')));
                            try
                            {
                                if (JohnWick.MyAsset.GetSerialized() != null)
                                {
                                    new UpdateMyState("Drawing " + ingredientsFileName + "...", "Waiting").ChangeProcessState();

                                    dynamic AssetData  = JsonConvert.DeserializeObject(JohnWick.MyAsset.GetSerialized());
                                    JArray  AssetArray = JArray.FromObject(AssetData);

                                    fillSchematicIcon(AssetData[0], i);
                                    drawIngredientIcon(AssetData[0], i);
                                    drawDisplayNameAndQuantity(AssetData[0], SchematicItemInfos.schematicInfoList[i].theIngredientQuantity, i);
                                }
                            }
                            catch (JsonSerializationException)
                            {
                                //do not crash when JsonSerialization does weird stuff
                            }
                        }
                    }
                }
            }
        }
Beispiel #24
0
        /// <summary>
        /// extract, serialize, get Large or Small image for HeroDefinition or WeaponDefinition
        /// if no HeroDefinition and WeaponDefinition move to SearchLargeSmallIcon
        /// </summary>
        /// <param name="theItem"></param>
        public static void SearchAthIteDefIcon(JToken theItem)
        {
            JToken heroDefinition   = theItem["HeroDefinition"];
            JToken weaponDefinition = theItem["WeaponDefinition"];

            if (heroDefinition != null)
            {
                string heroFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[heroDefinition.Value <string>()], heroDefinition.Value <string>());
                if (heroFilePath != null)
                {
                    if (heroFilePath.Contains(".uasset") || heroFilePath.Contains(".uexp") || heroFilePath.Contains(".ubulk"))
                    {
                        JohnWick.MyAsset = new PakAsset(heroFilePath.Substring(0, heroFilePath.LastIndexOf('.')));
                        try
                        {
                            if (JohnWick.MyAsset.GetSerialized() != null)
                            {
                                dynamic AssetData  = JsonConvert.DeserializeObject(JohnWick.MyAsset.GetSerialized());
                                JArray  AssetArray = JArray.FromObject(AssetData);

                                JToken largePreviewImage = AssetArray[0]["LargePreviewImage"];
                                if (largePreviewImage != null)
                                {
                                    JToken assetPathName = largePreviewImage["asset_path_name"];
                                    if (assetPathName != null)
                                    {
                                        string textureFile = Path.GetFileName(assetPathName.Value <string>()).Substring(0, Path.GetFileName(assetPathName.Value <string>()).LastIndexOf('.'));

                                        ItemIconPath = JohnWick.AssetToTexture2D(textureFile);
                                    }
                                }
                            }
                        }
                        catch (JsonSerializationException)
                        {
                            //do not crash when JsonSerialization does weird stuff
                        }
                    }
                }
            }
            else if (weaponDefinition != null)
            {
                //STW PICKAXES MANUAL FIX
                if (weaponDefinition.Value <string>().Equals("WID_Harvest_Pickaxe_STWCosmetic_Tier"))
                {
                    weaponDefinition = "WID_Harvest_Pickaxe_STWCosmetic_Tier_" + ThePak.CurrentUsedItem.Substring(ThePak.CurrentUsedItem.Length - 1);
                }

                string value = ThePak.AllpaksDictionary.Where(x => string.Equals(x.Key, weaponDefinition.Value <string>(), StringComparison.CurrentCultureIgnoreCase)).Select(d => d.Key).FirstOrDefault();
                if (value != null)
                {
                    string weaponFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[value], value);
                    if (weaponFilePath != null)
                    {
                        if (weaponFilePath.Contains(".uasset") || weaponFilePath.Contains(".uexp") || weaponFilePath.Contains(".ubulk"))
                        {
                            JohnWick.MyAsset = new PakAsset(weaponFilePath.Substring(0, weaponFilePath.LastIndexOf('.')));
                            try
                            {
                                if (JohnWick.MyAsset.GetSerialized() != null)
                                {
                                    dynamic AssetData  = JsonConvert.DeserializeObject(JohnWick.MyAsset.GetSerialized());
                                    JArray  AssetArray = JArray.FromObject(AssetData);

                                    JToken largePreviewImage = AssetArray[0]["LargePreviewImage"];
                                    if (largePreviewImage != null)
                                    {
                                        JToken assetPathName = largePreviewImage["asset_path_name"];
                                        if (assetPathName != null)
                                        {
                                            string textureFile = Path.GetFileName(assetPathName.Value <string>()).Substring(0, Path.GetFileName(assetPathName.Value <string>()).LastIndexOf('.'));

                                            ItemIconPath = JohnWick.AssetToTexture2D(textureFile);
                                        }
                                    }
                                }
                            }
                            catch (JsonSerializationException)
                            {
                                //do not crash when JsonSerialization does weird stuff
                            }
                        }
                    }
                }
            }
            else
            {
                SearchLargeSmallIcon(theItem);
            }
        }
Beispiel #25
0
        /// <summary>
        /// extract quest and add description, count, reward item, reward quantity to List<BundleInfoEntry> BundleData
        /// loop if stage exist
        /// </summary>
        /// <param name="questFile"></param>
        private static void getQuestData(string questFile)
        {
            try
            {
                string questFilePath;
                if (ThePak.CurrentUsedPakGuid != null && ThePak.CurrentUsedPakGuid != "0-0-0-0")
                {
                    questFilePath = JohnWick.ExtractAsset(ThePak.CurrentUsedPak, questFile);
                }
                else
                {
                    questFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[questFile], questFile);
                }

                if (questFilePath != null)
                {
                    if (questFilePath.Contains(".uasset") || questFilePath.Contains(".uexp") || questFilePath.Contains(".ubulk"))
                    {
                        JohnWick.MyAsset = new PakAsset(questFilePath.Substring(0, questFilePath.LastIndexOf('.')));
                        try
                        {
                            if (JohnWick.MyAsset.GetSerialized() != null)
                            {
                                QuestParser[] questParser = QuestParser.FromJson(JToken.Parse(JohnWick.MyAsset.GetSerialized()).ToString());
                                for (int x = 0; x < questParser.Length; x++)
                                {
                                    string oldQuest = string.Empty;
                                    long   oldCount = 0;

                                    for (int p = 0; p < questParser[x].Objectives.Length; p++)
                                    {
                                        long newCount = questParser[x].Objectives[p].Count;
                                        if (questParser[x].ObjectiveCompletionCount > 0)
                                        {
                                            newCount = questParser[x].ObjectiveCompletionCount;
                                        }

                                        //fortbyte check
                                        bool isFortbyte = false;
                                        Parser.Quests.Reward assetTypeToken = null;
                                        if (questParser[x].Rewards != null) //this caused a null exception for some challenges (most of them in the Styles folder)
                                        {
                                            assetTypeToken = questParser[x].Rewards.Where(item => item.ItemPrimaryAssetId.PrimaryAssetType.Name == "Token").FirstOrDefault();
                                            if (assetTypeToken != null)
                                            {
                                                isFortbyte = assetTypeToken.ItemPrimaryAssetId.PrimaryAssetName == "AthenaFortbyte";
                                            }
                                        }

                                        string newQuest = SearchResource.getTextByKey(questParser[x].Objectives[p].Description.Key, questParser[x].Objectives[p].Description.SourceString);
                                        if (newQuest != oldQuest && newCount != oldCount)
                                        {
                                            if (questParser[x].Rewards != null && !isFortbyte)
                                            {
                                                try
                                                {
                                                    string rewardId       = questParser[x].Rewards.Where(item => item.ItemPrimaryAssetId.PrimaryAssetType.Name != "Quest").Where(item => item.ItemPrimaryAssetId.PrimaryAssetType.Name != "Token").FirstOrDefault().ItemPrimaryAssetId.PrimaryAssetName;
                                                    string rewardQuantity = questParser[x].Rewards.Where(item => item.ItemPrimaryAssetId.PrimaryAssetType.Name != "Quest").Where(item => item.ItemPrimaryAssetId.PrimaryAssetType.Name != "Token").FirstOrDefault().Quantity.ToString();

                                                    BundleData.Add(new BundleInfoEntry(newQuest, newCount, rewardId, rewardQuantity));
                                                }
                                                catch (NullReferenceException)
                                                {
                                                    if (questParser[x].HiddenRewards != null)
                                                    {
                                                        string rewardId       = questParser[x].HiddenRewards.FirstOrDefault().TemplateId;
                                                        string rewardQuantity = questParser[x].HiddenRewards.FirstOrDefault().Quantity.ToString();

                                                        BundleData.Add(new BundleInfoEntry(newQuest, newCount, rewardId, rewardQuantity));
                                                    }
                                                }

                                                //get stage
                                                for (int k = 0; k < questParser[x].Rewards.Length; k++)
                                                {
                                                    string qAssetType = questParser[x].Rewards[k].ItemPrimaryAssetId.PrimaryAssetType.Name;
                                                    string qAssetName = questParser[x].Rewards[k].ItemPrimaryAssetId.PrimaryAssetName;

                                                    if (qAssetType == "Quest")
                                                    {
                                                        getQuestData(qAssetName);
                                                    }
                                                }
                                            }
                                            else if (isFortbyte && assetTypeToken != null)
                                            {
                                                BundleData.Add(new BundleInfoEntry(newQuest, newCount, assetTypeToken.ItemPrimaryAssetId.PrimaryAssetName, questParser[x].Weight > 0 ? questParser[x].Weight.ToString() : "01"));
                                            }
                                            else
                                            {
                                                BundleData.Add(new BundleInfoEntry(newQuest, newCount, "", ""));
                                            }

                                            oldQuest = newQuest;
                                            oldCount = newCount;
                                        }
                                    }
                                }
                            }
                        }
                        catch (JsonSerializationException)
                        {
                            //do not crash when JsonSerialization does weird stuff
                        }
                    }
                }
            }
            catch (KeyNotFoundException)
            {
                //do not stop when questFile doesn't exist
                //Console.WriteLine("Can't extract " + questFile);
            }
        }
Beispiel #26
0
        /// <summary>
        /// extract, serialize, get Large or Small image for HeroDefinition or WeaponDefinition
        /// if no HeroDefinition and WeaponDefinition move to SearchLargeSmallIcon
        /// </summary>
        /// <param name="theItem"></param>
        public static void SearchAthIteDefIcon(ItemsIdParser theItem)
        {
            if (theItem.HeroDefinition != null)
            {
                string heroFilePath;
                if (ThePak.CurrentUsedPakGuid != null && ThePak.CurrentUsedPakGuid != "0-0-0-0")
                {
                    heroFilePath = JohnWick.ExtractAsset(ThePak.CurrentUsedPak, theItem.HeroDefinition);
                }
                else
                {
                    heroFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[theItem.HeroDefinition], theItem.HeroDefinition);
                }

                if (heroFilePath != null)
                {
                    if (heroFilePath.Contains(".uasset") || heroFilePath.Contains(".uexp") || heroFilePath.Contains(".ubulk"))
                    {
                        JohnWick.MyAsset = new PakAsset(heroFilePath.Substring(0, heroFilePath.LastIndexOf('.')));
                        try
                        {
                            if (JohnWick.MyAsset.GetSerialized() != null)
                            {
                                string parsedJson = JToken.Parse(JohnWick.MyAsset.GetSerialized()).ToString();
                                var    itemId     = ItemsIdParser.FromJson(parsedJson);
                                for (int i = 0; i < itemId.Length; i++)
                                {
                                    if (itemId[i].LargePreviewImage != null)
                                    {
                                        string textureFile = Path.GetFileName(itemId[i].LargePreviewImage.AssetPathName)
                                                             ?.Substring(0,
                                                                         Path.GetFileName(itemId[i].LargePreviewImage.AssetPathName)
                                                                         .LastIndexOf('.'));


                                        ItemIconPath = JohnWick.AssetToTexture2D(textureFile);
                                    }
                                }
                            }
                        }
                        catch (JsonSerializationException)
                        {
                            //do not crash when JsonSerialization does weird stuff
                        }
                    }
                }
            }
            else if (theItem.WeaponDefinition != null)
            {
                //MANUAL FIX
                if (theItem.WeaponDefinition == "WID_Harvest_Pickaxe_NutCracker")
                {
                    theItem.WeaponDefinition = "WID_Harvest_Pickaxe_Nutcracker";
                }
                if (theItem.WeaponDefinition == "WID_Harvest_Pickaxe_Wukong")
                {
                    theItem.WeaponDefinition = "WID_Harvest_Pickaxe_WuKong";
                }

                string weaponFilePath;
                if (ThePak.CurrentUsedPakGuid != null && ThePak.CurrentUsedPakGuid != "0-0-0-0")
                {
                    weaponFilePath = JohnWick.ExtractAsset(ThePak.CurrentUsedPak, theItem.WeaponDefinition);
                }
                else
                {
                    weaponFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[theItem.WeaponDefinition], theItem.WeaponDefinition);
                }

                if (weaponFilePath != null)
                {
                    if (weaponFilePath.Contains(".uasset") || weaponFilePath.Contains(".uexp") || weaponFilePath.Contains(".ubulk"))
                    {
                        JohnWick.MyAsset = new PakAsset(weaponFilePath.Substring(0, weaponFilePath.LastIndexOf('.')));
                        try
                        {
                            if (JohnWick.MyAsset.GetSerialized() != null)
                            {
                                string parsedJson = JToken.Parse(JohnWick.MyAsset.GetSerialized()).ToString();
                                var    itemId     = ItemsIdParser.FromJson(parsedJson);
                                for (int i = 0; i < itemId.Length; i++)
                                {
                                    if (itemId[i].LargePreviewImage != null)
                                    {
                                        string textureFile = Path.GetFileName(itemId[i].LargePreviewImage.AssetPathName)
                                                             ?.Substring(0,
                                                                         Path.GetFileName(itemId[i].LargePreviewImage.AssetPathName)
                                                                         .LastIndexOf('.'));

                                        ItemIconPath = JohnWick.AssetToTexture2D(textureFile);
                                    }
                                }
                            }
                        }
                        catch (JsonSerializationException)
                        {
                            //do not crash when JsonSerialization does weird stuff
                        }
                    }
                }
            }
            else
            {
                SearchLargeSmallIcon(theItem);
            }
        }
Beispiel #27
0
        /// <summary>
        /// if the catalogFile is in AllpaksDictionary (is known) extract, serialize the catalogFile and parse to get and convert the featured file to a png image
        /// </summary>
        /// <param name="theItem"></param>
        /// <param name="catName"></param>
        private static void GetFeaturedItemIcon(ItemsIdParser theItem, string catName)
        {
            if (ThePak.AllpaksDictionary.ContainsKey(catName))
            {
                ThePak.CurrentUsedItem = catName;

                string catalogFilePath;
                if (ThePak.CurrentUsedPakGuid != null && ThePak.CurrentUsedPakGuid != "0-0-0-0")
                {
                    catalogFilePath = JohnWick.ExtractAsset(ThePak.CurrentUsedPak, catName);
                }
                else
                {
                    catalogFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[catName], catName);
                }

                if (catalogFilePath != null)
                {
                    Checking.WasFeatured = true;
                    if (catalogFilePath.Contains(".uasset") || catalogFilePath.Contains(".uexp") || catalogFilePath.Contains(".ubulk"))
                    {
                        JohnWick.MyAsset = new PakAsset(catalogFilePath.Substring(0, catalogFilePath.LastIndexOf('.')));
                        try
                        {
                            if (JohnWick.MyAsset.GetSerialized() != null)
                            {
                                string parsedJson = JToken.Parse(JohnWick.MyAsset.GetSerialized()).ToString();
                                var    featuredId = FeaturedParser.FromJson(parsedJson);
                                for (int i = 0; i < featuredId.Length; i++)
                                {
                                    switch (catName)
                                    {
                                    case "DA_Featured_Glider_ID_070_DarkViking":
                                    case "DA_Featured_CID_319_Athena_Commando_F_Nautilus":
                                        if (featuredId[i].TileImage != null)
                                        {
                                            string textureFile = featuredId[i].TileImage.ResourceObject;
                                            ItemIconPath = JohnWick.AssetToTexture2D(textureFile);
                                        }
                                        break;

                                    default:
                                        if (featuredId[i].DetailsImage != null)
                                        {
                                            string textureFile = featuredId[i].DetailsImage.ResourceObject;
                                            ItemIconPath = JohnWick.AssetToTexture2D(textureFile);
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                        catch (JsonSerializationException)
                        {
                            //do not crash when JsonSerialization does weird stuff
                        }
                    }
                }
            }
            else
            {
                GetItemIcon(theItem);
            }
        }
Beispiel #28
0
        /// <summary>
        /// if the catalogFile is in AllpaksDictionary (is known) extract, serialize the catalogFile and parse to get and convert the featured file to a png image
        /// </summary>
        /// <param name="theItem"></param>
        /// <param name="catName"></param>
        private static void GetFeaturedItemIcon(JToken theItem, string catName)
        {
            string value = ThePak.AllpaksDictionary.Where(x => string.Equals(x.Key, catName, StringComparison.CurrentCultureIgnoreCase)).Select(d => d.Key).FirstOrDefault();

            if (value != null)
            {
                string catalogFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[value], value);
                if (!string.IsNullOrEmpty(catalogFilePath))
                {
                    Checking.WasFeatured = true;
                    if (catalogFilePath.Contains(".uasset") || catalogFilePath.Contains(".uexp") || catalogFilePath.Contains(".ubulk"))
                    {
                        JohnWick.MyAsset = new PakAsset(catalogFilePath.Substring(0, catalogFilePath.LastIndexOf('.')));
                        try
                        {
                            if (JohnWick.MyAsset.GetSerialized() != null)
                            {
                                ThePak.CurrentUsedItem = value;
                                dynamic AssetData  = JsonConvert.DeserializeObject(JohnWick.MyAsset.GetSerialized());
                                JArray  AssetArray = JArray.FromObject(AssetData);

                                switch (value)
                                {
                                case "DA_Featured_Glider_ID_070_DarkViking":
                                case "DA_Featured_CID_319_Athena_Commando_F_Nautilus":
                                    JToken tileImage = AssetArray[0]["TileImage"];
                                    if (tileImage != null)
                                    {
                                        JToken resourceObject = tileImage["ResourceObject"];
                                        if (resourceObject != null)
                                        {
                                            string textureFile = resourceObject.Value <string>();

                                            ItemIconPath = JohnWick.AssetToTexture2D(textureFile);
                                        }
                                    }
                                    break;

                                default:
                                    JToken detailsImage = AssetArray[0]["DetailsImage"];
                                    if (detailsImage != null)
                                    {
                                        JToken resourceObject = detailsImage["ResourceObject"];
                                        if (resourceObject != null)
                                        {
                                            string textureFile = resourceObject.Value <string>();

                                            ItemIconPath = JohnWick.AssetToTexture2D(textureFile);
                                        }
                                    }
                                    break;
                                }

                                // There is no featured image (as legends pack, shadow pack...)
                                if (string.IsNullOrEmpty(ItemIconPath) || ItemIconPath.Contains("Athena\\Prototype\\Textures\\"))
                                {
                                    GetItemIcon(theItem);
                                }
                            }
                        }
                        catch (JsonSerializationException)
                        {
                            //do not crash when JsonSerialization does weird stuff
                        }
                    }
                }
            }
            else
            {
                GetItemIcon(theItem);
            }
        }
Beispiel #29
0
        /// <summary>
        /// extract quest and add description, count, reward item, reward quantity to List<BundleInfoEntry> BundleData
        /// loop if stage exist
        /// </summary>
        /// <param name="questFile"></param>
        private static void getQuestData(string questFile, JToken questInfo)
        {
            try
            {
                string questFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[questFile], questFile);
                if (questFilePath != null)
                {
                    if (questFilePath.Contains(".uasset") || questFilePath.Contains(".uexp") || questFilePath.Contains(".ubulk"))
                    {
                        JohnWick.MyAsset = new PakAsset(questFilePath.Substring(0, questFilePath.LastIndexOf('.')));
                        try
                        {
                            if (JohnWick.MyAsset.GetSerialized() != null)
                            {
                                new UpdateMyState("Parsing " + questFile + "...", "Waiting").ChangeProcessState();

                                //prestige challenge check
                                JToken questUnlockType = questInfo["QuestUnlockType"];
                                string unlockType      = string.Empty;
                                if (questUnlockType != null)
                                {
                                    unlockType = questUnlockType.Value <string>();
                                }

                                dynamic AssetData  = JsonConvert.DeserializeObject(JohnWick.MyAsset.GetSerialized());
                                JArray  AssetArray = JArray.FromObject(AssetData);

                                //fortbyte check
                                JToken rewards        = AssetArray[0]["Rewards"];
                                JToken assetTypeToken = null;
                                bool   isFortbyte     = false;
                                if (rewards != null)
                                {
                                    JArray rewardsArray = rewards.Value <JArray>();
                                    assetTypeToken = rewardsArray.Where(item => item["ItemPrimaryAssetId"]["PrimaryAssetType"]["Name"].Value <string>().Equals("Token")).FirstOrDefault();
                                    if (assetTypeToken != null)
                                    {
                                        isFortbyte = rewardsArray.Any(item => item["ItemPrimaryAssetId"]["PrimaryAssetName"].Value <string>().Equals("AthenaFortbyte"));
                                    }
                                }

                                JToken objectives = AssetArray[0]["Objectives"];
                                if (objectives != null)
                                {
                                    long   questCount        = 0;
                                    string descriptionKey    = string.Empty;
                                    string descriptionSource = string.Empty;

                                    JArray objectivesArray = objectives.Value <JArray>();
                                    foreach (JToken token in objectivesArray)
                                    {
                                        //quest count
                                        JToken count = token["Count"];
                                        if (count != null)
                                        {
                                            questCount = count.Value <long>();
                                            JToken objectiveCompletionCount = AssetArray[0]["ObjectiveCompletionCount"];
                                            if (objectiveCompletionCount != null && objectiveCompletionCount.Value <long>() > 0)
                                            {
                                                questCount = objectiveCompletionCount.Value <long>();
                                            }
                                        }

                                        //quest description
                                        JToken description = token["Description"];
                                        if (description != null)
                                        {
                                            JToken key          = description["key"];
                                            JToken sourceString = description["source_string"];
                                            if (key != null && sourceString != null)
                                            {
                                                descriptionKey    = key.Value <string>();
                                                descriptionSource = sourceString.Value <string>();
                                            }
                                        }
                                        JToken descriptionMain = AssetArray[0]["Description"];
                                        if (descriptionMain != null)
                                        {
                                            JToken key          = descriptionMain["key"];
                                            JToken sourceString = descriptionMain["source_string"];
                                            if (key != null && sourceString != null)
                                            {
                                                descriptionKey    = key.Value <string>();
                                                descriptionSource = sourceString.Value <string>();
                                            }
                                        }
                                    }

                                    string questDescription = SearchResource.getTextByKey(descriptionKey, descriptionSource);
                                    if (string.IsNullOrEmpty(questDescription))
                                    {
                                        questDescription = " ";
                                    }

                                    if (rewards != null && !isFortbyte)
                                    {
                                        //quest rewards
                                        JArray rewardsArray = rewards.Value <JArray>();
                                        try
                                        {
                                            string rewardId       = rewardsArray.Where(item => !item["ItemPrimaryAssetId"]["PrimaryAssetType"]["Name"].Value <string>().Equals("Quest") && !item["ItemPrimaryAssetId"]["PrimaryAssetType"]["Name"].Value <string>().Equals("Token")).FirstOrDefault()["ItemPrimaryAssetId"]["PrimaryAssetName"].Value <string>();
                                            string rewardQuantity = rewardsArray.Where(item => !item["ItemPrimaryAssetId"]["PrimaryAssetType"]["Name"].Value <string>().Equals("Quest") && !item["ItemPrimaryAssetId"]["PrimaryAssetType"]["Name"].Value <string>().Equals("Token")).FirstOrDefault()["Quantity"].Value <string>();

                                            BundleInfoEntry currentData    = new BundleInfoEntry(questDescription, questCount, rewardId, rewardQuantity, unlockType);
                                            bool            isAlreadyAdded = BundleData.Any(item => item.questDescr.Equals(currentData.questDescr, StringComparison.InvariantCultureIgnoreCase) && item.questCount == currentData.questCount);
                                            if (!isAlreadyAdded)
                                            {
                                                BundleData.Add(currentData);
                                            }
                                        }
                                        catch (NullReferenceException)
                                        {
                                            JToken hiddenRewards = AssetArray[0]["HiddenRewards"];
                                            if (hiddenRewards != null)
                                            {
                                                string rewardId       = hiddenRewards[0]["TemplateId"].Value <string>();
                                                string rewardQuantity = hiddenRewards[0]["Quantity"].Value <string>();

                                                BundleInfoEntry currentData    = new BundleInfoEntry(questDescription, questCount, rewardId, rewardQuantity, unlockType);
                                                bool            isAlreadyAdded = BundleData.Any(item => item.questDescr.Equals(currentData.questDescr, StringComparison.InvariantCultureIgnoreCase) && item.questCount == currentData.questCount);
                                                if (!isAlreadyAdded)
                                                {
                                                    BundleData.Add(currentData);
                                                }
                                            }
                                        }

                                        //quest stage
                                        foreach (JToken token in rewardsArray)
                                        {
                                            string qAssetType = token["ItemPrimaryAssetId"]["PrimaryAssetType"]["Name"].Value <string>();
                                            string qAssetName = token["ItemPrimaryAssetId"]["PrimaryAssetName"].Value <string>();

                                            if (qAssetType == "Quest")
                                            {
                                                getQuestData(qAssetName, questInfo);
                                            }
                                        }
                                    }
                                    else if (isFortbyte && assetTypeToken != null)
                                    {
                                        //thank you Quest_BR_S9_Fortbyte_04
                                        JToken weight      = AssetArray[0]["Weight"];
                                        JToken weightToUse = null;
                                        if (weight != null)
                                        {
                                            weightToUse = weight;
                                        }

                                        BundleInfoEntry currentData    = new BundleInfoEntry(questDescription, questCount, assetTypeToken["ItemPrimaryAssetId"]["PrimaryAssetName"].Value <string>(), weightToUse == null ? "01" : weightToUse.Value <string>(), unlockType);
                                        bool            isAlreadyAdded = BundleData.Any(item => item.questDescr.Equals(currentData.questDescr, StringComparison.InvariantCultureIgnoreCase) && item.questCount == currentData.questCount);
                                        if (!isAlreadyAdded)
                                        {
                                            BundleData.Add(currentData);
                                        }
                                    }
                                    else
                                    {
                                        BundleInfoEntry currentData    = new BundleInfoEntry(questDescription, questCount, "", "", unlockType);
                                        bool            isAlreadyAdded = BundleData.Any(item => item.questDescr.Equals(currentData.questDescr, StringComparison.InvariantCultureIgnoreCase) && item.questCount == currentData.questCount);
                                        if (!isAlreadyAdded)
                                        {
                                            BundleData.Add(currentData);
                                        }
                                    }
                                }
                            }
                        }
                        catch (JsonSerializationException)
                        {
                            //do not crash when JsonSerialization does weird stuff
                        }
                    }
                }
            }
            catch (KeyNotFoundException)
            {
                new UpdateMyConsole("Can't extract " + questFile, Color.Crimson, true).AppendToConsole();
            }
        }
Beispiel #30
0
        private static void drawHeader(Bitmap myBitmap, JToken myBundle)
        {
            bool   isSXBanner        = false;
            string bundleDisplayName = BundleInfos.getBundleDisplayName(myItem);
            string lastFolder        = BundleInfos.getLastFolder(BundlePath);

            JToken displayStyle = myBundle["DisplayStyle"];

            if (displayStyle != null)
            {
                if (Settings.Default.isChallengesTheme)
                {
                    string[] colorParts = Settings.Default.challengesColors.Split(',');
                    headerColor = Color.FromArgb(255, Int32.Parse(colorParts[0]), Int32.Parse(colorParts[1]), Int32.Parse(colorParts[2]));
                }
                else
                {
                    headerColor = BundleInfos.getSecondaryColor(myBundle);
                }

                JToken customBackground = displayStyle["CustomBackground"];
                JToken displayImage     = displayStyle["DisplayImage"];
                if (customBackground != null)
                {
                    JToken assetPathName = customBackground["asset_path_name"];
                    if (assetPathName != null)
                    {
                        if (assetPathName.Value <string>().Contains("/Game/Athena/UI/Challenges/Art/MissionTileImages/") && !ThePak.CurrentUsedItem.Equals("QuestBundle_S10_SeasonX"))
                        {
                            isSXBanner = true;
                            string textureFile   = Path.GetFileName(assetPathName.Value <string>()).Substring(0, Path.GetFileName(assetPathName.Value <string>()).LastIndexOf('.'));
                            Image  challengeIcon = Resources.unknown512;
                            string textureAsset  = JohnWick.AssetToTexture2D(textureFile);;
                            if (!string.IsNullOrEmpty(textureAsset))
                            {
                                using (var bmpTemp = new Bitmap(textureAsset))
                                {
                                    challengeIcon = new Bitmap(bmpTemp);
                                }
                            }

                            toDrawOn.FillRectangle(new SolidBrush(headerColor), new Rectangle(-1, -1, myBitmap.Width + 1, 257));
                            if (Settings.Default.isChallengesTheme && File.Exists(Settings.Default.challengesBannerFileName))
                            {
                                Image banner       = Image.FromFile(Settings.Default.challengesBannerFileName);
                                var   opacityImage = ImageUtilities.SetImageOpacity(banner, (float)Settings.Default.challengesOpacity / 1000);
                                toDrawOn.DrawImage(ImageUtilities.ResizeImage(opacityImage, 1024, 256), 0, 0);
                            }
                            else
                            {
                                var opacityImage = ImageUtilities.SetImageOpacity(challengeIcon, (float)0.3);
                                toDrawOn.DrawImage(opacityImage, new Point(0, 0));
                            }
                        }
                    }
                }
                if (!isSXBanner)
                {
                    if (displayImage != null)
                    {
                        JToken assetPathName = displayImage["asset_path_name"];
                        if (assetPathName != null)
                        {
                            string textureFile   = Path.GetFileName(assetPathName.Value <string>()).Substring(0, Path.GetFileName(assetPathName.Value <string>()).LastIndexOf('.'));
                            Image  challengeIcon = Resources.unknown512;
                            string textureAsset  = JohnWick.AssetToTexture2D(textureFile);
                            if (!string.IsNullOrEmpty(textureAsset))
                            {
                                using (var bmpTemp = new Bitmap(textureAsset))
                                {
                                    challengeIcon = new Bitmap(bmpTemp);
                                }
                            }

                            toDrawOn.FillRectangle(new SolidBrush(headerColor), new Rectangle(-1, -1, myBitmap.Width + 1, 257));
                            if (Settings.Default.isChallengesTheme)
                            {
                                if (File.Exists(Settings.Default.challengesBannerFileName))
                                {
                                    Image banner       = Image.FromFile(Settings.Default.challengesBannerFileName);
                                    var   opacityImage = ImageUtilities.SetImageOpacity(banner, (float)Settings.Default.challengesOpacity / 1000);
                                    toDrawOn.DrawImage(ImageUtilities.ResizeImage(opacityImage, 1024, 256), 0, 0);
                                }
                            }

                            toDrawOn.DrawImage(ImageUtilities.ResizeImage(challengeIcon, 256, 256), new Point(0, 0));
                        }
                    }
                    else
                    {
                        toDrawOn.FillRectangle(new SolidBrush(headerColor), new Rectangle(-1, -1, myBitmap.Width + 1, 257));
                        if (Settings.Default.isChallengesTheme)
                        {
                            if (File.Exists(Settings.Default.challengesBannerFileName))
                            {
                                Image banner       = Image.FromFile(Settings.Default.challengesBannerFileName);
                                var   opacityImage = ImageUtilities.SetImageOpacity(banner, (float)Settings.Default.challengesOpacity / 1000);
                                toDrawOn.DrawImage(ImageUtilities.ResizeImage(opacityImage, 1024, 256), 0, 0);
                            }
                        }
                    }
                }
            }
            else
            {
                if (Settings.Default.isChallengesTheme)
                {
                    string[] colorParts = Settings.Default.challengesColors.Split(',');
                    headerColor = Color.FromArgb(255, Int32.Parse(colorParts[0]), Int32.Parse(colorParts[1]), Int32.Parse(colorParts[2]));
                }
                else
                {
                    headerColor = getRandomColor();
                }

                toDrawOn.FillRectangle(new SolidBrush(headerColor), new Rectangle(-1, -1, myBitmap.Width + 1, 257));
                if (Settings.Default.isChallengesTheme)
                {
                    if (File.Exists(Settings.Default.challengesBannerFileName))
                    {
                        Image banner       = Image.FromFile(Settings.Default.challengesBannerFileName);
                        var   opacityImage = ImageUtilities.SetImageOpacity(banner, (float)Settings.Default.challengesOpacity / 1000);
                        toDrawOn.DrawImage(ImageUtilities.ResizeImage(opacityImage, 1024, 256), 0, 0);
                    }
                }
            }

            GraphicsPath gp = new GraphicsPath();

            gp.StartFigure();
            gp.AddLine(0, 256, myBitmap.Width, 256);
            gp.AddLine(myBitmap.Width, 256, myBitmap.Width, 241);
            gp.AddLine(myBitmap.Width, 241, myBitmap.Width / 2 + 25, 236);
            gp.AddLine(myBitmap.Width / 2 + 25, 236, myBitmap.Width / 2 + 35, 249);
            gp.AddLine(myBitmap.Width / 2 + 35, 249, 0, 241);
            gp.CloseFigure();
            toDrawOn.FillPath(new SolidBrush(ControlPaint.Light(headerColor)), gp);

            GraphicsPath p     = new GraphicsPath();
            Pen          myPen = new Pen(ControlPaint.Light(headerColor, (float)0.2), 3);

            myPen.LineJoin = LineJoin.Round; //needed to avoid spikes
            p.AddString(
                lastFolder,
                Settings.Default.IconLanguage == "Japanese" ? FontUtilities.pfc.Families[2] : FontUtilities.pfc.Families[1],
                (int)FontStyle.Regular, 30,
                new Point(isSXBanner || displayStyle == null ? 30 : 265, 70),
                FontUtilities.leftString
                );
            toDrawOn.DrawPath(myPen, p);
            toDrawOn.FillPath(new SolidBrush(ControlPaint.Dark(headerColor, (float)0.05)), p);

            toDrawOn.DrawString(bundleDisplayName, new Font(Settings.Default.IconLanguage == "Japanese" ? FontUtilities.pfc.Families[2] : FontUtilities.pfc.Families[1], 40), new SolidBrush(Color.White), new Point(isSXBanner || displayStyle == null ? 25 : 260, 105));

            toDrawOn.FillRectangle(new SolidBrush(ControlPaint.Dark(headerColor, (float)0.1)), new Rectangle(-1, 255, myBitmap.Width + 1, myBitmap.Height));
        }