From be3d07dd8b589f0ae23e7bc1a029d7771bd66a01 Mon Sep 17 00:00:00 2001 From: Camille Date: Wed, 19 Jan 2022 11:14:20 +0100 Subject: [PATCH] changed currencies default values --- SamplePlugin/CurrencyAlert.csproj | 4 +++- SamplePlugin/Enum/Currency.cs | 4 ++-- SamplePlugin/Plugin.cs | 9 ++++++++- SamplePlugin/PluginUI.cs | 26 ++++++++++++++++++-------- SamplePlugin/currencyAlert.json | 30 ++++++++++++++++++++++++++++++ 5 files changed, 61 insertions(+), 12 deletions(-) diff --git a/SamplePlugin/CurrencyAlert.csproj b/SamplePlugin/CurrencyAlert.csproj index e269565..328956a 100644 --- a/SamplePlugin/CurrencyAlert.csproj +++ b/SamplePlugin/CurrencyAlert.csproj @@ -3,7 +3,7 @@ - 0.2.2.0 + 0.2.2 Currency Alert https://github.com/Lharz/xiv-currency-alert @@ -22,6 +22,8 @@ $(appdata)\XIVLauncher\addon\Hooks\dev\ + https://github.com/Lharz/xiv-currency-alert + git diff --git a/SamplePlugin/Enum/Currency.cs b/SamplePlugin/Enum/Currency.cs index c3cff90..996f8cb 100644 --- a/SamplePlugin/Enum/Currency.cs +++ b/SamplePlugin/Enum/Currency.cs @@ -8,9 +8,9 @@ namespace CurrencyAlert.Enum { public enum Currency { - [Name("Tomestones of Poetics"), Slot(6), DefaultThreshold(1500)] + [Name("Tomestones of Poetics"), Slot(6), DefaultThreshold(1400)] TomestoneOfPoetics, - [Name("Tomestones of Astronomy"), Slot(10), DefaultThreshold(1500)] + [Name("Tomestones of Astronomy"), Slot(10), DefaultThreshold(1800)] TomestoneOfAstronomy, [Name("Storm Seals"), Slot(1), DefaultThreshold(75000)] StormSeal, diff --git a/SamplePlugin/Plugin.cs b/SamplePlugin/Plugin.cs index 4c5d728..722adeb 100644 --- a/SamplePlugin/Plugin.cs +++ b/SamplePlugin/Plugin.cs @@ -66,7 +66,14 @@ namespace CurrencyAlert EnumHelper.Each(currency => { var slot = EnumHelper.GetAttributeOfType(currency).Value; - uint quantity = currencyContainer->GetInventorySlot((int)slot)->Quantity; + InventoryItem* item = currencyContainer->GetInventorySlot((int)slot); + + if (item == null) + { + return; // TODO: write a log somewhere + } + + uint quantity = item->Quantity; if (this.Configuration.AlertEnabled[currency] && quantity >= this.Configuration.Threshold[currency]) { diff --git a/SamplePlugin/PluginUI.cs b/SamplePlugin/PluginUI.cs index e958050..3855e9c 100644 --- a/SamplePlugin/PluginUI.cs +++ b/SamplePlugin/PluginUI.cs @@ -88,7 +88,7 @@ namespace CurrencyAlert { var name = EnumHelper.GetAttributeOfType(currency).Value; var alertEnabled = this.configuration.AlertEnabled[currency]; - + if (ImGui.Checkbox($"{name} Alert Enabled", ref alertEnabled)) { this.configuration.AlertEnabled[currency] = alertEnabled; @@ -124,17 +124,27 @@ namespace CurrencyAlert unsafe { InventoryManager* inventoryManager = InventoryManager.Instance(); - InventoryContainer* currencyContainer = inventoryManager->GetInventoryContainer(InventoryType.Currency); - for (var i = 0; i < 100000; ++i) + EnumHelper.Each(type => { - var item = currencyContainer->GetInventorySlot(i); + InventoryContainer* currencyContainer = inventoryManager->GetInventoryContainer(type); - if (item == null) - continue; + if (currencyContainer == null) + { + return; // TODO: log something + } - ImGui.Text($"Index: {i} Value: {item->Quantity}"); - } + ImGui.Text($"----- {type.ToString()} -----"); + for (var i = 0; i < int.MaxValue; ++i) + { + var item = currencyContainer->GetInventorySlot(i); + + if (item == null) + break; + + ImGui.Text($"Index: {i} Value: {item->Quantity}"); + } + }); } } diff --git a/SamplePlugin/currencyAlert.json b/SamplePlugin/currencyAlert.json index b5f052f..38e8867 100644 --- a/SamplePlugin/currencyAlert.json +++ b/SamplePlugin/currencyAlert.json @@ -11,3 +11,33 @@ "tomestones" ] } +{ + "Disabled": true, + "Testing": false, + "InstalledFromUrl": null, + "Author": "Lharz", + "Name": "Currency Alert", + "Punchline": "Configure alerts upon reaching various currencies amount.", + "Description": "This plugin lets you setup alerts upon reaching configurable currencies amount (such as Poetics or Wolf Marks). You will never overcap your currencies now.", + "Tags": [ + "plugin", + "currency", + "tomestones" + ], + "IsHide": false, + "InternalName": "CurrencyAlert", + "AssemblyVersion": "0.2.2.0", + "TestingAssemblyVersion": null, + "IsTestingExclusive": false, + "RepoUrl": null, + "ApplicableVersion": "any", + "DalamudApiLevel": 4, + "DownloadCount": 0, + "LastUpdate": 0, + "DownloadLinkInstall": null, + "DownloadLinkUpdate": null, + "DownloadLinkTesting": null, + "LoadPriority": 0, + "ImageUrls": null, + "IconUrl": null +}