From e9f34dfca99dd6e7e551ad3243de30834b8b4c65 Mon Sep 17 00:00:00 2001 From: Asval Date: Tue, 30 Jul 2019 16:42:02 +0200 Subject: [PATCH] added stw schematics icon --- .../IconGenerator/ItemGenerator/DrawText.cs | 99 +++++++-------- .../SchematicGenerator/SchematicIconDesign.cs | 118 +++++++++++++----- .../SchematicGenerator/SchematicItemInfos.cs | 2 +- README.md | 3 +- 4 files changed, 138 insertions(+), 84 deletions(-) diff --git a/FModel/Methods/IconGenerator/ItemGenerator/DrawText.cs b/FModel/Methods/IconGenerator/ItemGenerator/DrawText.cs index 9fba0fb8..48e3e623 100644 --- a/FModel/Methods/IconGenerator/ItemGenerator/DrawText.cs +++ b/FModel/Methods/IconGenerator/ItemGenerator/DrawText.cs @@ -28,60 +28,57 @@ namespace FModel public static void DrawTexts(JToken theItem, Graphics myGraphic, string mode) { - using (myGraphic) + SetTexts(theItem); + + DrawDisplayName(theItem, myGraphic); + DrawDescription(theItem, myGraphic); + + switch (mode) { - SetTexts(theItem); - - DrawDisplayName(theItem, myGraphic); - DrawDescription(theItem, myGraphic); - - switch (mode) - { - case "athIteDef": - DrawToLeft(ShortDescription, myGraphic); - DrawToRight(CosmeticSource, myGraphic); - break; - case "consAndWeap": - DrawToRight(ItemAction, myGraphic); - if (Checking.ExtractedFilePath.Contains("Items\\Consumables\\")) - { - DrawToLeft(MaxStackSize, myGraphic); - } - break; - case "variant": - DrawToLeft(ShortDescription, myGraphic); - DrawToRight(CosmeticId, myGraphic); - break; - case "stwHeroes": - DrawToRight(HeroType, myGraphic); - DrawPower(myGraphic); - break; - case "stwDefenders": - DrawToRight(DefenderType, myGraphic); - DrawPower(myGraphic); - break; - } - - JToken exportToken = theItem["export_type"]; - if (exportToken != null && exportToken.Value().Equals("AthenaItemWrapDefinition") && Checking.WasFeatured && ItemIcon.ItemIconPath.Contains("WeaponRenders")) - { - DrawAdditionalImage(theItem, myGraphic); - } - - JToken ammoToken = theItem["AmmoData"]; - if (ammoToken != null) - { - JToken assetPathName = ammoToken["asset_path_name"]; - if (assetPathName != null && assetPathName.Value().Contains("Ammo")) //TO AVOID TRIGGERING CONSUMABLES, NAME SHOULD CONTAIN "AMMO" + case "athIteDef": + DrawToLeft(ShortDescription, myGraphic); + DrawToRight(CosmeticSource, myGraphic); + break; + case "consAndWeap": + DrawToRight(ItemAction, myGraphic); + if (Checking.ExtractedFilePath.Contains("Items\\Consumables\\")) { - ItemIcon.GetAmmoData(assetPathName.Value(), myGraphic); - - DrawWeaponStat(WeaponDataTable, WeaponRowName, myGraphic); + DrawToLeft(MaxStackSize, myGraphic); } - } - - DrawCosmeticUff(theItem, myGraphic); + break; + case "variant": + DrawToLeft(ShortDescription, myGraphic); + DrawToRight(CosmeticId, myGraphic); + break; + case "stwHeroes": + DrawToRight(HeroType, myGraphic); + DrawPower(myGraphic); + break; + case "stwDefenders": + DrawToRight(DefenderType, myGraphic); + DrawPower(myGraphic); + break; } + + JToken exportToken = theItem["export_type"]; + if (exportToken != null && exportToken.Value().Equals("AthenaItemWrapDefinition") && Checking.WasFeatured && ItemIcon.ItemIconPath.Contains("WeaponRenders")) + { + DrawAdditionalImage(theItem, myGraphic); + } + + JToken ammoToken = theItem["AmmoData"]; + if (ammoToken != null) + { + JToken assetPathName = ammoToken["asset_path_name"]; + if (assetPathName != null && assetPathName.Value().Contains("Ammo")) //TO AVOID TRIGGERING CONSUMABLES, NAME SHOULD CONTAIN "AMMO" + { + ItemIcon.GetAmmoData(assetPathName.Value(), myGraphic); + + DrawWeaponStat(WeaponDataTable, WeaponRowName, myGraphic); + } + } + + DrawCosmeticUff(theItem, myGraphic); } /// @@ -541,7 +538,7 @@ namespace FModel { Image reload = Resources.reload64; myGraphic.DrawImage(ImageUtilities.ResizeImage(reload, 15, 15), new Point(50 + (clipSize.Value().Length * 7) + 47, 502)); //50=clipsize text position | for each clipsize letter we add 7 to x | 47=difference between 2 icons - myGraphic.DrawString(reloadTime + " " + SearchResource.getTextByKey("6BA53D764BA5CC13E821D2A807A72365", "seconds"), new Font(FontUtilities.pfc.Families[0], 11), new SolidBrush(Color.White), new Point(64 + (clipSize.Value().Length * 7) + 47, 503)); //64=50+icon size (-1 because that wasn't perfectly at the position i wanted) + myGraphic.DrawString(reloadTime.Value() + " " + SearchResource.getTextByKey("6BA53D764BA5CC13E821D2A807A72365", "seconds"), new Font(FontUtilities.pfc.Families[0], 11), new SolidBrush(Color.White), new Point(64 + (clipSize.Value().Length * 7) + 47, 503)); //64=50+icon size (-1 because that wasn't perfectly at the position i wanted) } DrawToRight(weaponName, myGraphic); diff --git a/FModel/Methods/IconGenerator/SchematicGenerator/SchematicIconDesign.cs b/FModel/Methods/IconGenerator/SchematicGenerator/SchematicIconDesign.cs index 9e3d8566..dac35a43 100644 --- a/FModel/Methods/IconGenerator/SchematicGenerator/SchematicIconDesign.cs +++ b/FModel/Methods/IconGenerator/SchematicGenerator/SchematicIconDesign.cs @@ -8,6 +8,7 @@ using System.Drawing.Drawing2D; using System.Drawing.Text; using System.IO; using System.Linq; +using System.Windows.Forms; namespace FModel { @@ -81,14 +82,14 @@ namespace FModel { if (JohnWick.MyAsset.GetSerialized() != null) { + new UpdateMyState("Drawing " + ingredientsFileName + "...", "Waiting").ChangeProcessState(); + dynamic AssetData = JsonConvert.DeserializeObject(JohnWick.MyAsset.GetSerialized()); JArray AssetArray = JArray.FromObject(AssetData); - JToken rarity = AssetData[0]["Rarity"]; - if (rarity != null) - { - fillSchematicIcon(rarity, i); - } + fillSchematicIcon(AssetData[0], i); + drawIngredientIcon(AssetData[0], i); + drawDisplayNameAndQuantity(AssetData[0], SchematicItemInfos.schematicInfoList[i].theIngredientQuantity, i); } } catch (JsonSerializationException) @@ -101,36 +102,91 @@ namespace FModel } } - public static void fillSchematicIcon(JToken rarity, int i) + private static void fillSchematicIcon(JToken AssetArray, int i) { - Color rarityColor; - switch(rarity.Value()) + Color rarityColor = new Color(); + JToken rarity = AssetArray["Rarity"]; + if (rarity != null) { - case "EFortRarity::Transcendent": - rarityColor = Color.FromArgb(255, 155, 39, 69); - break; - case "EFortRarity::Mythic": - rarityColor = Color.FromArgb(255, 170, 143, 47); - break; - case "EFortRarity::Legendary": - rarityColor = Color.FromArgb(255, 170, 96, 47); - break; - case "EFortRarity::Epic": - case "EFortRarity::Quality": - rarityColor = Color.FromArgb(255, 96, 47, 170); - break; - case "EFortRarity::Rare": - rarityColor = Color.FromArgb(255, 55, 92, 163); - break; - case "EFortRarity::Common": - rarityColor = Color.FromArgb(255, 109, 109, 109); - break; - default: - rarityColor = Color.FromArgb(255, 87, 155, 39); - break; + switch (rarity.Value()) + { + case "EFortRarity::Transcendent": + rarityColor = Color.FromArgb(255, 155, 39, 69); + break; + case "EFortRarity::Mythic": + rarityColor = Color.FromArgb(255, 170, 143, 47); + break; + case "EFortRarity::Legendary": + rarityColor = Color.FromArgb(255, 170, 96, 47); + break; + case "EFortRarity::Epic": + case "EFortRarity::Quality": + rarityColor = Color.FromArgb(255, 96, 47, 170); + break; + case "EFortRarity::Rare": + rarityColor = Color.FromArgb(255, 55, 92, 163); + break; + case "EFortRarity::Common": + rarityColor = Color.FromArgb(255, 109, 109, 109); + break; + } + } + else { rarityColor = Color.FromArgb(255, 87, 155, 39); } + + toDrawOn.FillRectangle(new SolidBrush(rarityColor), new Rectangle(0, 522 + (75 * i), schematicBitmap.Width, 75)); + Pen pen = new Pen(ControlPaint.Light(rarityColor), 4); + pen.Alignment = PenAlignment.Inset; //<-- this + toDrawOn.DrawRectangle(pen, new Rectangle(0, 522 + (75 * i), schematicBitmap.Width, 75)); + } + + private static void drawIngredientIcon(JToken AssetArray, int i) + { + ItemIcon.ItemIconPath = string.Empty; + ItemIcon.SearchAthIteDefIcon(AssetArray); + if (File.Exists(ItemIcon.ItemIconPath)) + { + Image itemIcon; + using (var bmpTemp = new Bitmap(ItemIcon.ItemIconPath)) + { + itemIcon = new Bitmap(bmpTemp); + } + toDrawOn.DrawImage(ImageUtilities.ResizeImage(itemIcon, 50, 50), new Point(10, 536 + (75 * i))); + } + else + { + Image itemIcon = Resources.unknown512; + toDrawOn.DrawImage(itemIcon, new Point(0, 0)); + } + } + + private static void drawDisplayNameAndQuantity(JToken AssetArray, string quantity, int i) + { + JToken displayName = AssetArray["DisplayName"]; + if (displayName != null) + { + JToken key = displayName["key"]; + JToken sourceString = displayName["source_string"]; + if (key != null && sourceString != null) + { + string text = SearchResource.getTextByKey(key.Value(), sourceString.Value()); + + toDrawOn.DrawString( + text, + new Font(Settings.Default.IconLanguage == "Japanese" ? FontUtilities.pfc.Families[2] : FontUtilities.pfc.Families[0], 25), + new SolidBrush(Color.White), + new Point(70, 545 + (75 * i)), + FontUtilities.leftString + ); + } } - toDrawOn.FillRectangle(new SolidBrush(rarityColor), new Rectangle(0, 447 + (75 * i), schematicBitmap.Width, 75)); + toDrawOn.DrawString( + quantity, + new Font(Settings.Default.IconLanguage == "Japanese" ? FontUtilities.pfc.Families[2] : FontUtilities.pfc.Families[0], 25), + new SolidBrush(Color.White), + new Point(502, 545 + (75 * i)), + FontUtilities.rightString + ); } } } diff --git a/FModel/Methods/IconGenerator/SchematicGenerator/SchematicItemInfos.cs b/FModel/Methods/IconGenerator/SchematicGenerator/SchematicItemInfos.cs index 1ba97997..06dec7e6 100644 --- a/FModel/Methods/IconGenerator/SchematicGenerator/SchematicItemInfos.cs +++ b/FModel/Methods/IconGenerator/SchematicGenerator/SchematicItemInfos.cs @@ -51,6 +51,7 @@ namespace FModel } } } + else { throw new ArgumentException("Not enough informations to create an icon about this schematic - Missing: \"CraftingRecipe\""); } return toReturn; } @@ -105,7 +106,6 @@ namespace FModel JToken quantity = token["Quantity"]; if (primaryAssetName != null && quantity != null) { - System.Diagnostics.Debug.WriteLine("\"" + primaryAssetName.Value() + "\"\t\t" + quantity.Value()); SchematicInfoEntry currentEntry = new SchematicInfoEntry(primaryAssetName.Value(), quantity.Value()); bool isAlreadyAdded = schematicInfoList.Any(item => item.theIngredientItemDefinition.Equals(currentEntry.theIngredientItemDefinition, StringComparison.InvariantCultureIgnoreCase) && item.theIngredientQuantity == currentEntry.theIngredientQuantity); if (!isAlreadyAdded) { schematicInfoList.Add(currentEntry); } diff --git a/README.md b/README.md index 45b0a160..d0b983fb 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -# FModel +# FModel + [![](https://img.shields.io/github/downloads/iAmAsval/FModel/total.svg?color=green&label=Total%20Downloads&logo=buzzfeed&logoColor=white)](https://github.com/iAmAsval/FModel/releases) [![](https://img.shields.io/github/downloads/iAmAsval/FModel/latest/total.svg?label=2.4.2.2&logo=buzzfeed&logoColor=white)](https://github.com/iAmAsval/FModel//releases/latest) [![](https://img.shields.io/badge/License-GPL-blue.svg?logo=gnu)](https://github.com/iAmAsval/FModel/blob/master/LICENSE)