From a083e733e5ca60037f5cc3c373470181bd2a36c9 Mon Sep 17 00:00:00 2001 From: 0xE0D59 <0xE0D59@gmail.com> Date: Wed, 4 Aug 2021 06:26:34 +0200 Subject: [PATCH] Remove Seeds. Add helmet enchant price display in laboratory. --- .../API/PoeNinja/Classes/HelmetEnchants.cs | 4 +- Ninja Price/Main/CollectiveAPIData.cs | 2 +- Ninja Price/Main/DownloadJSONItems.cs | 16 ++++---- Ninja Price/Main/Render.cs | 40 +++++++++++++++++++ Ninja Price/Methods/Methods.cs | 28 ++++++++----- Ninja Price/Settings/Settings.cs | 4 ++ 6 files changed, 74 insertions(+), 20 deletions(-) diff --git a/Ninja Price/API/PoeNinja/Classes/HelmetEnchants.cs b/Ninja Price/API/PoeNinja/Classes/HelmetEnchants.cs index b90a225..c1c9106 100644 --- a/Ninja Price/API/PoeNinja/Classes/HelmetEnchants.cs +++ b/Ninja Price/API/PoeNinja/Classes/HelmetEnchants.cs @@ -7,13 +7,13 @@ public class HelmetEnchants public class Sparkline { public List data { get; set; } - public int totalChange { get; set; } + public double totalChange { get; set; } } public class LowConfidenceSparkline { public List data { get; set; } - public int totalChange { get; set; } + public double totalChange { get; set; } } public class Line diff --git a/Ninja Price/Main/CollectiveAPIData.cs b/Ninja Price/Main/CollectiveAPIData.cs index 41ef16a..53470d3 100644 --- a/Ninja Price/Main/CollectiveAPIData.cs +++ b/Ninja Price/Main/CollectiveAPIData.cs @@ -8,6 +8,7 @@ public class CollectiveApiData public DivinationCards.RootObject DivinationCards { get; set; } = new DivinationCards.RootObject(); public Essences.RootObject Essences { get; set; } = new Essences.RootObject(); public Fragments.RootObject Fragments { get; set; } = new Fragments.RootObject(); + public HelmetEnchants.RootObject HelmetEnchants { get; set; } = new HelmetEnchants.RootObject(); public Prophecies.RootObject Prophecies { get; set; } = new Prophecies.RootObject(); public UniqueAccessories.RootObject UniqueAccessories { get; set; } = new UniqueAccessories.RootObject(); @@ -23,7 +24,6 @@ public class CollectiveApiData public Oils.RootObject Oils { get; set; } = new Oils.RootObject(); public Incubators.RootObject Incubators { get; set; } = new Incubators.RootObject(); public DeliriumOrb.RootObject DeliriumOrb { get; set; } = new DeliriumOrb.RootObject(); - public Seeds.RootObject Seeds { get; set; } = new Seeds.RootObject(); public Invitations.RootObject Invitations { get; set; } = new Invitations.RootObject(); } } \ No newline at end of file diff --git a/Ninja Price/Main/DownloadJSONItems.cs b/Ninja Price/Main/DownloadJSONItems.cs index f82e96d..a643526 100644 --- a/Ninja Price/Main/DownloadJSONItems.cs +++ b/Ninja Price/Main/DownloadJSONItems.cs @@ -30,6 +30,7 @@ public partial class Main private const string DeliriumOrb_URL = "https://poe.ninja/api/data/itemoverview?type=DeliriumOrb&league="; private const string Seed_URL = "https://poe.ninja/api/data/itemoverview?type=Seed&league="; private const string Invitation_URL = "https://poe.ninja/api/data/ItemOverview?type=Invitation&league="; + private const string HelmetEnchants_URL = "https://poe.ninja/api/data/ItemOverview?type=HelmetEnchant&league="; private void GetJsonData(string league) { @@ -63,9 +64,8 @@ private void GetJsonData(string league) Api.Json.SaveSettingFile(NinjaDirectory + "Scarabs.json", JsonConvert.DeserializeObject(Api.DownloadFromUrl(Scarabs_URL + league))); Api.Json.SaveSettingFile(NinjaDirectory + "DeliriumOrbs.json", JsonConvert.DeserializeObject(Api.DownloadFromUrl(DeliriumOrb_URL + league))); Api.Json.SaveSettingFile(NinjaDirectory + "Invitations.json", JsonConvert.DeserializeObject(Api.DownloadFromUrl(Invitation_URL + league))); + Api.Json.SaveSettingFile(NinjaDirectory + "HelmetEnchants.json", JsonConvert.DeserializeObject(Api.DownloadFromUrl(HelmetEnchants_URL + league))); - // Not core, throw it at the bottom... - Api.Json.SaveSettingFile(NinjaDirectory + "Seeds.json", JsonConvert.DeserializeObject(Api.DownloadFromUrl(Seed_URL + league))); LogMessage("Finished Gathering Data from Poe.Ninja.", 5); UpdatingFromAPI = false; UpdatePoeNinjaData(); @@ -222,18 +222,18 @@ private void UpdatePoeNinjaData() newData.DeliriumOrb = JsonConvert.DeserializeObject(json); } - if (JsonExists("Seeds.json")) - using (var r = new StreamReader(NinjaDirectory + "Seeds.json")) + if (JsonExists("Invitations.json")) + using (var r = new StreamReader(NinjaDirectory + "Invitations.json")) { var json = r.ReadToEnd(); - newData.Seeds = JsonConvert.DeserializeObject(json); + newData.Invitations = JsonConvert.DeserializeObject(json); } - if (JsonExists("Invitations.json")) - using (var r = new StreamReader(NinjaDirectory + "Invitations.json")) + if (JsonExists("HelmetEnchants.json")) + using (var r = new StreamReader(NinjaDirectory + "HelmetEnchants.json")) { var json = r.ReadToEnd(); - newData.Invitations = JsonConvert.DeserializeObject(json); + newData.HelmetEnchants = JsonConvert.DeserializeObject(json); } CollectedData = newData; diff --git a/Ninja Price/Main/Render.cs b/Ninja Price/Main/Render.cs index d02f53e..8719849 100644 --- a/Ninja Price/Main/Render.cs +++ b/Ninja Price/Main/Render.cs @@ -274,6 +274,9 @@ public void DrawGraphics() // Inventory Value VisibleInventoryValue(); + if (Settings.HelmetEnchantPrices) + ShowHelmetEnchantPrices(); + if (!StashPanel.IsVisible) return; @@ -413,6 +416,43 @@ private void HighlightJunkUniques(CustomItem item) //Graphics.DrawFrame(item.Item.GetClientRect(), 2, Settings.HighlightColor.Value); } + + private void ShowHelmetEnchantPrices() + { + ExileCore.PoEMemory.Element GetElementByString(ExileCore.PoEMemory.Element element, string str) + { + if (string.IsNullOrWhiteSpace(str)) + return null; + + if (element.Text != null && element.Text.Contains(str)) + return element; + + return element.Children.Select(c => GetElementByString(c, str)).FirstOrDefault(e => e != null); + } + + var igui = GameController.Game.IngameState.IngameUi; + if (!igui.LabyrinthDivineFontPanel.IsVisible) return; + var triggerEnchantment = GetElementByString(igui.LabyrinthDivineFontPanel, "lvl "); + var enchantmentContainer = triggerEnchantment?.Parent?.Parent; + if(enchantmentContainer == null) return; + var enchants = enchantmentContainer.Children.Select(c => new {Name = c.Children[1].Text, ContainerElement = c}).AsEnumerable(); + if (!enchants.Any()) return; + foreach (var enchant in enchants) + { + var data = GetHelmetEnchantValue(enchant.Name); + if (data == null) continue; + var box = enchant.ContainerElement.GetClientRect(); + var drawBox = new RectangleF(box.X + box.Width, box.Y - 2, 65, box.Height); + var position = new Vector2(drawBox.Center.X, drawBox.Center.Y - 7); + + var textColor = data.PriceData.ExaltedPrice >= 1 ? Color.Black : Color.White; + var bgColor = data.PriceData.ExaltedPrice >= 1 ? Color.Goldenrod : Color.Black; + Graphics.DrawText(Math.Round((decimal) data.PriceData.ChaosValue, 2).ToString() + "c", position, textColor, FontAlign.Center); + Graphics.DrawBox(drawBox, bgColor); + Graphics.DrawFrame(drawBox, Color.Black, 1); + } + } + //private void PropheccyDisplay() //{ // if (!Settings.ProphecyPrices) diff --git a/Ninja Price/Methods/Methods.cs b/Ninja Price/Methods/Methods.cs index ed4f2da..a02197f 100644 --- a/Ninja Price/Methods/Methods.cs +++ b/Ninja Price/Methods/Methods.cs @@ -362,15 +362,6 @@ public void GetValue(CustomItem item) item.PriceData.ChangeInLast7Days = (double)resonatorSearch.Sparkline.TotalChange; } - break; - case ItemTypes.HarvestSeeds: - var seedLevel = 76; // TODO Diffrentiate between ilvl 1+ and 76+ seeds. - var seedSearch = CollectedData.Seeds.Lines.Find(x => x.Name == item.BaseName && x.LevelRequired == seedLevel); - if (seedSearch != null) - { - item.PriceData.ChaosValue = item.CurrencyInfo.StackSize * (double)seedSearch.ChaosValue; - item.PriceData.ChangeInLast7Days = (double)seedSearch.Sparkline.TotalChange; - } break; case ItemTypes.Fossil: var fossilSearch = CollectedData.Fossils.Lines.Find(x => x.Name == item.BaseName); @@ -555,6 +546,25 @@ public bool ShouldUpdateValuesInventory() var value = item.ChaosValue; return value; } + + private CustomItem GetHelmetEnchantValue(string EnchantName) + { + if (string.IsNullOrWhiteSpace(EnchantName)) + return null; + + var enchantSearch = CollectedData.HelmetEnchants.lines.Find(x => x.name.ToLower().Contains(EnchantName.ToLower())); + return enchantSearch == null + ? null + : new CustomItem + { + PriceData = new ReleventPriceData + { + ChaosValue = enchantSearch.chaosValue, ExaltedPrice = enchantSearch.exaltedValue, + ItemType = ItemTypes.None, ChangeInLast7Days = enchantSearch.sparkline.totalChange + }, + BaseName = enchantSearch.name + }; + } private Vector4 ToImVector4(SharpDX.Vector4 vector) { diff --git a/Ninja Price/Settings/Settings.cs b/Ninja Price/Settings/Settings.cs index d9340cc..1ef7fff 100644 --- a/Ninja Price/Settings/Settings.cs +++ b/Ninja Price/Settings/Settings.cs @@ -34,6 +34,7 @@ public Settings() InventoryValueSignificantDigits = new RangeNode(5, 0, 10); HighlightUniqueJunk = new ToggleNode(true); + HelmetEnchantPrices = new ToggleNode(true); HighlightColor = new ColorNode(Color.AliceBlue); HighlightFontSize = new RangeNode(20, 0, 200); HighlightSignificantDigits = new RangeNode(5, 0, 10); @@ -149,6 +150,9 @@ public Settings() [Menu("Highlight Unique Junk", "Highlight unique items under X value (useful for quick-selling to vendor).", 5)] public ToggleNode HighlightUniqueJunk { get; set; } + [Menu("Helmet Enchant Prices", "Display helmet enchant prices while in the laboratory.).", 6)] + public ToggleNode HelmetEnchantPrices { get; set; } + [Menu("Size", "Size of the font used to draw the chaos value of the visible inventory.", 53, 5)] public RangeNode HighlightFontSize { get; set; }