/// <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 } } } }
/// <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 } } } }
/// <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)); } }
/// <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); } }
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; } }
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); } }
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)); } }
/// <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); } } }
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); } }
/// <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)); } } } }
/// <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); } }
/// <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); } }
/// <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); } }
/// <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); } }
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)); }
/// <summary> /// draw the pretty header if DisplayStyle exist, else the pretty header but with random colors /// </summary> /// <param name="myBitmap"></param> /// <param name="myBundle"></param> public static void drawBackground(Bitmap myBitmap, ChallengeBundleIdParser myBundle) { if (Settings.Default.createIconForChallenges && myBundle.DisplayStyle != null) { //main header toDrawOn.FillRectangle(new SolidBrush(BundleInfos.getSecondaryColor(myBundle)), new Rectangle(0, 0, myBitmap.Width, 281)); //gradient at left and right main header LinearGradientBrush linGrBrush_left = new LinearGradientBrush(new Point(0, 282 / 2), new Point(282, 282 / 2), ControlPaint.Light(BundleInfos.getSecondaryColor(myBundle), (float)0.3), BundleInfos.getSecondaryColor(myBundle)); toDrawOn.FillRectangle(linGrBrush_left, new Rectangle(0, 0, 282, 282)); LinearGradientBrush linGrBrush_right = new LinearGradientBrush(new Point(2500, 282 / 2), new Point(1500, 282 / 2), ControlPaint.Light(BundleInfos.getSecondaryColor(myBundle), (float)0.3), BundleInfos.getSecondaryColor(myBundle)); toDrawOn.FillRectangle(linGrBrush_right, new Rectangle(1500, 0, 1000, 282)); //last folder with border GraphicsPath p = new GraphicsPath(); Pen myPen = new Pen(ControlPaint.Light(BundleInfos.getSecondaryColor(myBundle), (float)0.2), 3); myPen.LineJoin = LineJoin.Round; //needed to avoid spikes p.AddString(BundleInfos.getLastFolder(BundlePath), FontUtilities.pfc.Families[1], (int)FontStyle.Regular, 55, new Point(342, 40), FontUtilities.leftString); toDrawOn.DrawPath(myPen, p); toDrawOn.FillPath(new SolidBrush(ControlPaint.Dark(BundleInfos.getSecondaryColor(myBundle), (float)0.05)), p); //name toDrawOn.DrawString(BundleInfos.getBundleDisplayName(myItem), new Font(FontUtilities.pfc.Families[1], 115), new SolidBrush(Color.White), new Point(325, 70)); //image string textureFile = Path.GetFileName(myBundle.DisplayStyle.DisplayImage.AssetPathName).Substring(0, Path.GetFileName(myBundle.DisplayStyle.DisplayImage.AssetPathName).LastIndexOf('.')); Image challengeIcon; using (var bmpTemp = new Bitmap(JohnWick.AssetToTexture2D(textureFile))) { challengeIcon = new Bitmap(bmpTemp); } toDrawOn.DrawImage(ImageUtilities.ResizeImage(challengeIcon, 282, 282), new Point(40, 0)); //fill the rest toDrawOn.FillRectangle(new SolidBrush(ControlPaint.Dark(BundleInfos.getSecondaryColor(myBundle), (float)0.1)), new Rectangle(0, 271, myBitmap.Width, myBitmap.Height)); } else { Color myBaseColor = getRandomColor(); //main header toDrawOn.FillRectangle(new SolidBrush(myBaseColor), new Rectangle(0, 0, myBitmap.Width, 281)); //gradient at left and right main header LinearGradientBrush linGrBrush_left = new LinearGradientBrush(new Point(0, 282 / 2), new Point(282, 282 / 2), ControlPaint.Light(myBaseColor, (float)0.3), myBaseColor); toDrawOn.FillRectangle(linGrBrush_left, new Rectangle(0, 0, 282, 282)); LinearGradientBrush linGrBrush_right = new LinearGradientBrush(new Point(2500, 282 / 2), new Point(1500, 282 / 2), ControlPaint.Light(myBaseColor, (float)0.3), myBaseColor); toDrawOn.FillRectangle(linGrBrush_right, new Rectangle(1500, 0, 1000, 282)); //fill the rest toDrawOn.FillRectangle(new SolidBrush(ControlPaint.Dark(myBaseColor, (float)0.1)), new Rectangle(0, 271, myBitmap.Width, myBitmap.Height)); //last folder toDrawOn.DrawString(BundleInfos.getLastFolder(BundlePath), new Font(FontUtilities.pfc.Families[1], 42), new SolidBrush(ControlPaint.Dark(myBaseColor, (float)0.05)), new Point(40, 40)); //name toDrawOn.DrawString(BundleInfos.getBundleDisplayName(myItem), new Font(FontUtilities.pfc.Families[1], 115), new SolidBrush(Color.White), new Point(25, 70)); } }