Skip to content

Commit

Permalink
Remove Seeds. Add helmet enchant price display in laboratory.
Browse files Browse the repository at this point in the history
  • Loading branch information
0xE0D59 committed Aug 4, 2021
1 parent 309025c commit a083e73
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Ninja Price/API/PoeNinja/Classes/HelmetEnchants.cs
Expand Up @@ -7,13 +7,13 @@ public class HelmetEnchants
public class Sparkline
{
public List<object> data { get; set; }
public int totalChange { get; set; }
public double totalChange { get; set; }
}

public class LowConfidenceSparkline
{
public List<object> data { get; set; }
public int totalChange { get; set; }
public double totalChange { get; set; }
}

public class Line
Expand Down
2 changes: 1 addition & 1 deletion Ninja Price/Main/CollectiveAPIData.cs
Expand Up @@ -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();
Expand All @@ -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();
}
}
16 changes: 8 additions & 8 deletions Ninja Price/Main/DownloadJSONItems.cs
Expand Up @@ -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)
{
Expand Down Expand Up @@ -63,9 +64,8 @@ private void GetJsonData(string league)
Api.Json.SaveSettingFile(NinjaDirectory + "Scarabs.json", JsonConvert.DeserializeObject<Scarab.RootObject>(Api.DownloadFromUrl(Scarabs_URL + league)));
Api.Json.SaveSettingFile(NinjaDirectory + "DeliriumOrbs.json", JsonConvert.DeserializeObject<DeliriumOrb.RootObject>(Api.DownloadFromUrl(DeliriumOrb_URL + league)));
Api.Json.SaveSettingFile(NinjaDirectory + "Invitations.json", JsonConvert.DeserializeObject<Invitations.RootObject>(Api.DownloadFromUrl(Invitation_URL + league)));
Api.Json.SaveSettingFile(NinjaDirectory + "HelmetEnchants.json", JsonConvert.DeserializeObject<HelmetEnchants.RootObject>(Api.DownloadFromUrl(HelmetEnchants_URL + league)));
// Not core, throw it at the bottom...
Api.Json.SaveSettingFile(NinjaDirectory + "Seeds.json", JsonConvert.DeserializeObject<Seeds.RootObject>(Api.DownloadFromUrl(Seed_URL + league)));
LogMessage("Finished Gathering Data from Poe.Ninja.", 5);
UpdatingFromAPI = false;
UpdatePoeNinjaData();
Expand Down Expand Up @@ -222,18 +222,18 @@ private void UpdatePoeNinjaData()
newData.DeliriumOrb = JsonConvert.DeserializeObject<DeliriumOrb.RootObject>(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<Seeds.RootObject>(json);
newData.Invitations = JsonConvert.DeserializeObject<Invitations.RootObject>(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<Invitations.RootObject>(json);
newData.HelmetEnchants = JsonConvert.DeserializeObject<HelmetEnchants.RootObject>(json);
}
CollectedData = newData;
Expand Down
40 changes: 40 additions & 0 deletions Ninja Price/Main/Render.cs
Expand Up @@ -274,6 +274,9 @@ public void DrawGraphics()
// Inventory Value
VisibleInventoryValue();

if (Settings.HelmetEnchantPrices)
ShowHelmetEnchantPrices();

if (!StashPanel.IsVisible)
return;

Expand Down Expand Up @@ -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)
Expand Down
28 changes: 19 additions & 9 deletions Ninja Price/Methods/Methods.cs
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
{
Expand Down
4 changes: 4 additions & 0 deletions Ninja Price/Settings/Settings.cs
Expand Up @@ -34,6 +34,7 @@ public Settings()
InventoryValueSignificantDigits = new RangeNode<int>(5, 0, 10);

HighlightUniqueJunk = new ToggleNode(true);
HelmetEnchantPrices = new ToggleNode(true);
HighlightColor = new ColorNode(Color.AliceBlue);
HighlightFontSize = new RangeNode<int>(20, 0, 200);
HighlightSignificantDigits = new RangeNode<int>(5, 0, 10);
Expand Down Expand Up @@ -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<int> HighlightFontSize { get; set; }

Expand Down

0 comments on commit a083e73

Please sign in to comment.