From 0aa8a8b35032c1ae635ebf1d90a0c6882d3bc6e7 Mon Sep 17 00:00:00 2001 From: Camille Date: Thu, 20 Jan 2022 00:01:25 +0100 Subject: [PATCH] added missing currencies --- SamplePlugin/Attribute/CategoryAttribute.cs | 14 ++++++ .../{SlotAttribute.cs => ItemIDAttribute.cs} | 4 +- SamplePlugin/CurrencyAlert.csproj | 2 +- SamplePlugin/Enum/Currency.cs | 36 ++++++++++--- SamplePlugin/Plugin.cs | 12 +---- SamplePlugin/PluginUI.cs | 50 ++++++++++++------- 6 files changed, 79 insertions(+), 39 deletions(-) create mode 100644 SamplePlugin/Attribute/CategoryAttribute.cs rename SamplePlugin/Attribute/{SlotAttribute.cs => ItemIDAttribute.cs} (57%) diff --git a/SamplePlugin/Attribute/CategoryAttribute.cs b/SamplePlugin/Attribute/CategoryAttribute.cs new file mode 100644 index 0000000..2f57bcd --- /dev/null +++ b/SamplePlugin/Attribute/CategoryAttribute.cs @@ -0,0 +1,14 @@ +using System; + +namespace CurrencyAlert.Enum +{ + internal class CategoryAttribute : Attribute + { + public CategoryAttribute(string v) + { + Value = v; + } + + public string Value { get; } + } +} diff --git a/SamplePlugin/Attribute/SlotAttribute.cs b/SamplePlugin/Attribute/ItemIDAttribute.cs similarity index 57% rename from SamplePlugin/Attribute/SlotAttribute.cs rename to SamplePlugin/Attribute/ItemIDAttribute.cs index 22de5b9..5a29004 100644 --- a/SamplePlugin/Attribute/SlotAttribute.cs +++ b/SamplePlugin/Attribute/ItemIDAttribute.cs @@ -2,9 +2,9 @@ namespace CurrencyAlert { - internal class SlotAttribute : Attribute + internal class ItemIDAttribute : Attribute { - public SlotAttribute(int v) + public ItemIDAttribute(int v) { Value = v; } diff --git a/SamplePlugin/CurrencyAlert.csproj b/SamplePlugin/CurrencyAlert.csproj index eb2feaf..3a8903f 100644 --- a/SamplePlugin/CurrencyAlert.csproj +++ b/SamplePlugin/CurrencyAlert.csproj @@ -3,7 +3,7 @@ - 0.2.4.0 + 0.3.0.0 Currency Alert https://github.com/Lharz/xiv-currency-alert diff --git a/SamplePlugin/Enum/Currency.cs b/SamplePlugin/Enum/Currency.cs index 996f8cb..c7b14fb 100644 --- a/SamplePlugin/Enum/Currency.cs +++ b/SamplePlugin/Enum/Currency.cs @@ -8,19 +8,39 @@ namespace CurrencyAlert.Enum { public enum Currency { - [Name("Tomestones of Poetics"), Slot(6), DefaultThreshold(1400)] + [Name("Tomestones of Poetics"), ItemID(28), DefaultThreshold(1400), Category("Battle")] TomestoneOfPoetics, - [Name("Tomestones of Astronomy"), Slot(10), DefaultThreshold(1800)] + [Name("Tomestones of Aphorism"), ItemID(42), DefaultThreshold(1700), Category("Battle")] + TomestoneOfAphorism, + [Name("Tomestones of Astronomy"), ItemID(43), DefaultThreshold(1700), Category("Battle")] TomestoneOfAstronomy, - [Name("Storm Seals"), Slot(1), DefaultThreshold(75000)] + + [Name("Storm Seals"), ItemID(20), DefaultThreshold(75000), Category("Common")] StormSeal, - [Name("Serpent Seals"), Slot(2), DefaultThreshold(75000)] + [Name("Serpent Seals"), ItemID(21), DefaultThreshold(75000), Category("Common")] SerpentSeal, - [Name("Flame Seals"), Slot(3), DefaultThreshold(75000)] + [Name("Flame Seals"), ItemID(22), DefaultThreshold(75000), Category("Common")] FlameSeal, - [Name("Wolf Marks"), Slot(4), DefaultThreshold(18000)] + + [Name("Wolf Marks"), ItemID(25), DefaultThreshold(18000), Category("Battle")] WolfMark, - [Name("Allied Seals"), Slot(8), DefaultThreshold(3500)] - AlliedSeal + + [Name("Allied Seals"), ItemID(27), DefaultThreshold(3500), Category("Battle")] + AlliedSeal, + [Name("Centurio Seals"), ItemID(10307), DefaultThreshold(3500), Category("Battle")] + CenturioSeal, + [Name("Sack of Nuts"), ItemID(26533), DefaultThreshold(3500), Category("Battle")] + SackOfNut, + + [Name("White Crafters' Scrip"), ItemID(25199), DefaultThreshold(1500), Category("Other")] + WhiteCraftersScrip, + [Name("Purple Crafters' Scrip"), ItemID(33913), DefaultThreshold(1500), Category("Other")] + PurpleCraftersScrip, + [Name("White Gatherers' Scrip"), ItemID(25200), DefaultThreshold(1500), Category("Other")] + WhiteGatherersScrip, + [Name("Purple Gatherers' Scrip"), ItemID(33914), DefaultThreshold(1500), Category("Other")] + PurpleGatherersScrip, + [Name("Skybuilders' Scrip"), ItemID(28063), DefaultThreshold(7500), Category("Other")] + SkybuildersScrip } } diff --git a/SamplePlugin/Plugin.cs b/SamplePlugin/Plugin.cs index 722adeb..d0e2544 100644 --- a/SamplePlugin/Plugin.cs +++ b/SamplePlugin/Plugin.cs @@ -61,19 +61,11 @@ namespace CurrencyAlert unsafe { InventoryManager* inventoryManager = InventoryManager.Instance(); - InventoryContainer* currencyContainer = inventoryManager->GetInventoryContainer(InventoryType.Currency); EnumHelper.Each(currency => { - var slot = EnumHelper.GetAttributeOfType(currency).Value; - InventoryItem* item = currencyContainer->GetInventorySlot((int)slot); - - if (item == null) - { - return; // TODO: write a log somewhere - } - - uint quantity = item->Quantity; + var itemID = EnumHelper.GetAttributeOfType(currency).Value; + int quantity = inventoryManager->GetInventoryItemCount((uint)itemID); if (this.Configuration.AlertEnabled[currency] && quantity >= this.Configuration.Threshold[currency]) { diff --git a/SamplePlugin/PluginUI.cs b/SamplePlugin/PluginUI.cs index 3855e9c..0572fef 100644 --- a/SamplePlugin/PluginUI.cs +++ b/SamplePlugin/PluginUI.cs @@ -80,30 +80,39 @@ namespace CurrencyAlert public void DrawSettingsWindow() { - ImGui.SetNextWindowSize(new Vector2(400, 600), ImGuiCond.Always); + ImGui.SetNextWindowSize(new Vector2(700, 500), ImGuiCond.Always); if (ImGui.Begin("Currency Alert Configuration Window", ref this.settingsVisible, - ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse)) + ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollWithMouse)) { - EnumHelper.Each(currency => + if (ImGui.BeginTabBar("AlertsConfiguration_Tabs")) { - var name = EnumHelper.GetAttributeOfType(currency).Value; - var alertEnabled = this.configuration.AlertEnabled[currency]; - - if (ImGui.Checkbox($"{name} Alert Enabled", ref alertEnabled)) + EnumHelper.Each(currency => { - this.configuration.AlertEnabled[currency] = alertEnabled; - this.configuration.Save(); - } + var name = EnumHelper.GetAttributeOfType(currency).Value; + var category = EnumHelper.GetAttributeOfType(currency).Value; + var alertEnabled = this.configuration.AlertEnabled[currency]; - var thresholdValue = this.configuration.Threshold[currency]; + if (ImGui.BeginTabItem(category)) + { + if (ImGui.Checkbox($"{name} Alert Enabled", ref alertEnabled)) + { + this.configuration.AlertEnabled[currency] = alertEnabled; + this.configuration.Save(); + } - if (ImGui.InputInt($"{name} Threshold Value", ref thresholdValue, 1, 1, - this.configuration.AlertEnabled[currency] ? ImGuiInputTextFlags.None : ImGuiInputTextFlags.ReadOnly)) - { - this.configuration.Threshold[currency] = thresholdValue; - this.configuration.Save(); - } - }); + var thresholdValue = this.configuration.Threshold[currency]; + + if (ImGui.InputInt($"{name} Threshold Value", ref thresholdValue, 1, 1, + this.configuration.AlertEnabled[currency] ? ImGuiInputTextFlags.None : ImGuiInputTextFlags.ReadOnly)) + { + this.configuration.Threshold[currency] = thresholdValue; + this.configuration.Save(); + } + + ImGui.EndTabItem(); + } + }); + } } #if DEBUG @@ -125,8 +134,13 @@ namespace CurrencyAlert { InventoryManager* inventoryManager = InventoryManager.Instance(); + ImGui.Text($"ItemID: 42 Value: {inventoryManager->GetInventoryItemCount(42)}"); + EnumHelper.Each(type => { + if (type != InventoryType.Currency) + return; + InventoryContainer* currencyContainer = inventoryManager->GetInventoryContainer(type); if (currencyContainer == null)