diff --git a/CurrencyAlert.sln b/CurrencyAlert.sln index a2466f5..6bc58db 100644 --- a/CurrencyAlert.sln +++ b/CurrencyAlert.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31919.166 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CurrencyAlert", "SamplePlugin\CurrencyAlert.csproj", "{13C812E9-0D42-4B95-8646-40EEBF30636F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CurrencyAlert", "CurrencyAlert\CurrencyAlert.csproj", "{13C812E9-0D42-4B95-8646-40EEBF30636F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/SamplePlugin/Attribute/CategoryAttribute.cs b/CurrencyAlert/Attribute/CategoryAttribute.cs similarity index 94% rename from SamplePlugin/Attribute/CategoryAttribute.cs rename to CurrencyAlert/Attribute/CategoryAttribute.cs index 2f57bcd..7b5ee31 100644 --- a/SamplePlugin/Attribute/CategoryAttribute.cs +++ b/CurrencyAlert/Attribute/CategoryAttribute.cs @@ -1,14 +1,14 @@ -using System; - -namespace CurrencyAlert.Enum -{ - internal class CategoryAttribute : Attribute - { - public CategoryAttribute(string v) - { - Value = v; - } - - public string Value { get; } - } -} +using System; + +namespace CurrencyAlert.Enum +{ + internal class CategoryAttribute : Attribute + { + public CategoryAttribute(string v) + { + Value = v; + } + + public string Value { get; } + } +} diff --git a/SamplePlugin/Attribute/DefaultThresholdAttribute.cs b/CurrencyAlert/Attribute/DefaultThresholdAttribute.cs similarity index 94% rename from SamplePlugin/Attribute/DefaultThresholdAttribute.cs rename to CurrencyAlert/Attribute/DefaultThresholdAttribute.cs index d3d4fad..5a3ee6b 100644 --- a/SamplePlugin/Attribute/DefaultThresholdAttribute.cs +++ b/CurrencyAlert/Attribute/DefaultThresholdAttribute.cs @@ -1,14 +1,14 @@ -using System; - -namespace CurrencyAlert -{ - internal class DefaultThresholdAttribute : Attribute - { - public DefaultThresholdAttribute(int v) - { - Value = v; - } - - public int Value { get; } - } +using System; + +namespace CurrencyAlert +{ + internal class DefaultThresholdAttribute : Attribute + { + public DefaultThresholdAttribute(int v) + { + Value = v; + } + + public int Value { get; } + } } \ No newline at end of file diff --git a/SamplePlugin/Attribute/ItemIDAttribute.cs b/CurrencyAlert/Attribute/ItemIDAttribute.cs similarity index 93% rename from SamplePlugin/Attribute/ItemIDAttribute.cs rename to CurrencyAlert/Attribute/ItemIDAttribute.cs index 5a29004..32f4a38 100644 --- a/SamplePlugin/Attribute/ItemIDAttribute.cs +++ b/CurrencyAlert/Attribute/ItemIDAttribute.cs @@ -1,14 +1,14 @@ -using System; - -namespace CurrencyAlert -{ - internal class ItemIDAttribute : Attribute - { - public ItemIDAttribute(int v) - { - Value = v; - } - - public int Value { get; } - } +using System; + +namespace CurrencyAlert +{ + internal class ItemIDAttribute : Attribute + { + public ItemIDAttribute(int v) + { + Value = v; + } + + public int Value { get; } + } } \ No newline at end of file diff --git a/SamplePlugin/Attribute/NameAttribute.cs b/CurrencyAlert/Attribute/NameAttribute.cs similarity index 94% rename from SamplePlugin/Attribute/NameAttribute.cs rename to CurrencyAlert/Attribute/NameAttribute.cs index f6c3a13..509a812 100644 --- a/SamplePlugin/Attribute/NameAttribute.cs +++ b/CurrencyAlert/Attribute/NameAttribute.cs @@ -1,14 +1,14 @@ -using System; - -namespace CurrencyAlert.Enum -{ - internal class NameAttribute : Attribute - { - public NameAttribute(string v) - { - Value = v; - } - - public string Value { get; } - } -} +using System; + +namespace CurrencyAlert.Enum +{ + internal class NameAttribute : Attribute + { + public NameAttribute(string v) + { + Value = v; + } + + public string Value { get; } + } +} diff --git a/SamplePlugin/Configuration.cs b/CurrencyAlert/Configuration.cs similarity index 96% rename from SamplePlugin/Configuration.cs rename to CurrencyAlert/Configuration.cs index d9a8e30..8fd565a 100644 --- a/SamplePlugin/Configuration.cs +++ b/CurrencyAlert/Configuration.cs @@ -1,40 +1,40 @@ -using CurrencyAlert.Enum; -using Dalamud.Configuration; -using Dalamud.Plugin; -using System; -using System.Collections.Generic; - -namespace CurrencyAlert -{ - [Serializable] - public class Configuration : IPluginConfiguration - { - public int Version { get; set; } = 4; - - public Dictionary AlertEnabled { get; set; } = new Dictionary(); - public Dictionary Threshold { get; set; } = new Dictionary(); - - [NonSerialized] - private DalamudPluginInterface? pluginInterface; - - public Configuration() - { - EnumHelper.Each(currency => - { - this.AlertEnabled[currency] = true; - var defaultValue = EnumHelper.GetAttributeOfType(currency); - this.Threshold[currency] = defaultValue.Value; - }); - } - - public void Initialize(DalamudPluginInterface pluginInterface) - { - this.pluginInterface = pluginInterface; - } - - public void Save() - { - this.pluginInterface!.SavePluginConfig(this); - } - } -} +using CurrencyAlert.Enum; +using Dalamud.Configuration; +using Dalamud.Plugin; +using System; +using System.Collections.Generic; + +namespace CurrencyAlert +{ + [Serializable] + public class Configuration : IPluginConfiguration + { + public int Version { get; set; } = 4; + + public Dictionary AlertEnabled { get; set; } = new Dictionary(); + public Dictionary Threshold { get; set; } = new Dictionary(); + + [NonSerialized] + private DalamudPluginInterface? pluginInterface; + + public Configuration() + { + EnumHelper.Each(currency => + { + this.AlertEnabled[currency] = true; + var defaultValue = EnumHelper.GetAttributeOfType(currency); + this.Threshold[currency] = defaultValue.Value; + }); + } + + public void Initialize(DalamudPluginInterface pluginInterface) + { + this.pluginInterface = pluginInterface; + } + + public void Save() + { + this.pluginInterface!.SavePluginConfig(this); + } + } +} diff --git a/SamplePlugin/CurrencyAlert.csproj b/CurrencyAlert/CurrencyAlert.csproj similarity index 83% rename from SamplePlugin/CurrencyAlert.csproj rename to CurrencyAlert/CurrencyAlert.csproj index f4bad42..535664b 100644 --- a/SamplePlugin/CurrencyAlert.csproj +++ b/CurrencyAlert/CurrencyAlert.csproj @@ -3,21 +3,22 @@ - 0.3.2.0 + 0.3.3.0 Currency Alert - https://github.com/Lharz/xiv-currency-alert + https://github.com/Lharz/xiv-currency-alert - net5.0-windows + net6.0-windows x64 enable latest true false false - $(AppData)\XIVLauncher\devPlugins\CurrencyAlert\ + true + true @@ -27,7 +28,7 @@ - + $(DalamudLibPath)FFXIVClientStructs.dll false diff --git a/SamplePlugin/Enum/Currency.cs b/CurrencyAlert/Enum/Currency.cs similarity index 97% rename from SamplePlugin/Enum/Currency.cs rename to CurrencyAlert/Enum/Currency.cs index 4bc9ccc..71abba7 100644 --- a/SamplePlugin/Enum/Currency.cs +++ b/CurrencyAlert/Enum/Currency.cs @@ -1,50 +1,50 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace CurrencyAlert.Enum -{ - public enum Currency - { - [Name("Tomestones of Poetics"), ItemID(28), DefaultThreshold(1400), Category("Battle")] - TomestoneOfPoetics, - [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"), ItemID(20), DefaultThreshold(75000), Category("Common")] - StormSeal, - [Name("Serpent Seals"), ItemID(21), DefaultThreshold(75000), Category("Common")] - SerpentSeal, - [Name("Flame Seals"), ItemID(22), DefaultThreshold(75000), Category("Common")] - FlameSeal, - - [Name("Wolf Marks"), ItemID(25), DefaultThreshold(18000), Category("Battle")] - WolfMark, - [Name("Trophy Crystals"), ItemID(36656), DefaultThreshold(18000), Category("Battle")] - TrophyCrystal, - - [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("Bicolor Gemstone"), ItemID(26807), DefaultThreshold(800), Category("Battle")] - BicolorGemstone, - - [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 - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CurrencyAlert.Enum +{ + public enum Currency + { + [Name("Tomestones of Poetics"), ItemID(28), DefaultThreshold(1400), Category("Battle")] + TomestoneOfPoetics, + [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"), ItemID(20), DefaultThreshold(75000), Category("Common")] + StormSeal, + [Name("Serpent Seals"), ItemID(21), DefaultThreshold(75000), Category("Common")] + SerpentSeal, + [Name("Flame Seals"), ItemID(22), DefaultThreshold(75000), Category("Common")] + FlameSeal, + + [Name("Wolf Marks"), ItemID(25), DefaultThreshold(18000), Category("Battle")] + WolfMark, + [Name("Trophy Crystals"), ItemID(36656), DefaultThreshold(18000), Category("Battle")] + TrophyCrystal, + + [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("Bicolor Gemstone"), ItemID(26807), DefaultThreshold(800), Category("Battle")] + BicolorGemstone, + + [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/Helper/EnumHelper.cs b/CurrencyAlert/Helper/EnumHelper.cs similarity index 97% rename from SamplePlugin/Helper/EnumHelper.cs rename to CurrencyAlert/Helper/EnumHelper.cs index 71d48e4..2936606 100644 --- a/SamplePlugin/Helper/EnumHelper.cs +++ b/CurrencyAlert/Helper/EnumHelper.cs @@ -1,32 +1,32 @@ - using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace CurrencyAlert -{ - public static class EnumHelper - { - /// - /// Gets an attribute on an enum field value - /// - /// The type of the attribute you want to retrieve - /// The enum value - /// The attribute of type T that exists on the enum value - /// ().Description;]]> - public static T GetAttributeOfType(this System.Enum enumVal) where T : System.Attribute - { - var type = enumVal.GetType(); - var memInfo = type.GetMember(enumVal.ToString()); - var attributes = memInfo[0].GetCustomAttributes(typeof(T), false); - return (attributes.Length > 0) ? (T)attributes[0] : null; - } - - public static void Each(Action action) - { - foreach (var item in System.Enum.GetValues(typeof(T))) - action((T)item); - } - } -} + using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CurrencyAlert +{ + public static class EnumHelper + { + /// + /// Gets an attribute on an enum field value + /// + /// The type of the attribute you want to retrieve + /// The enum value + /// The attribute of type T that exists on the enum value + /// ().Description;]]> + public static T GetAttributeOfType(this System.Enum enumVal) where T : System.Attribute + { + var type = enumVal.GetType(); + var memInfo = type.GetMember(enumVal.ToString()); + var attributes = memInfo[0].GetCustomAttributes(typeof(T), false); + return (attributes.Length > 0) ? (T)attributes[0] : null; + } + + public static void Each(Action action) + { + foreach (var item in System.Enum.GetValues(typeof(T))) + action((T)item); + } + } +} diff --git a/SamplePlugin/Plugin.cs b/CurrencyAlert/Plugin.cs similarity index 97% rename from SamplePlugin/Plugin.cs rename to CurrencyAlert/Plugin.cs index d0e2544..f53022c 100644 --- a/SamplePlugin/Plugin.cs +++ b/CurrencyAlert/Plugin.cs @@ -1,89 +1,89 @@ -using CurrencyAlert.Enum; -using Dalamud.Game.Command; -using Dalamud.Game.Gui; -using Dalamud.IoC; -using Dalamud.Plugin; -using FFXIVClientStructs.FFXIV.Client.Game; -using System.IO; -using System.Reflection; - -namespace CurrencyAlert -{ - public sealed class Plugin : IDalamudPlugin - { - public string Name => "Currency Alert"; - - private const string commandName = "/currencyalert"; - - private DalamudPluginInterface PluginInterface { get; init; } - private CommandManager CommandManager { get; init; } - private Configuration Configuration { get; init; } - private PluginUI PluginUI { get; init; } - - [PluginService] public static ChatGui Chat { get; private set; } = null!; - - public Plugin( - [RequiredVersion("1.0")] DalamudPluginInterface pluginInterface, - [RequiredVersion("1.0")] CommandManager commandManager) - { - this.PluginInterface = pluginInterface; - this.CommandManager = commandManager; - - this.Configuration = this.PluginInterface.GetPluginConfig() as Configuration ?? new Configuration(); - this.Configuration.Initialize(this.PluginInterface); - - var assemblyLocation = Assembly.GetExecutingAssembly().Location; - this.PluginUI = new PluginUI(this.Configuration); - - this.CommandManager.AddHandler(commandName, new CommandInfo(OnCommand) - { - HelpMessage = "Lets you configure alert thresholds for various currencies" - }); - - this.PluginInterface.UiBuilder.Draw += DrawUI; - this.PluginInterface.UiBuilder.OpenConfigUi += DrawConfigUI; - } - - public void Dispose() - { - this.PluginUI.Dispose(); - this.CommandManager.RemoveHandler(commandName); - } - - private void OnCommand(string command, string args) - { - this.DrawConfigUI(); - } - - private void DrawUI() - { - // TODO: move this logic elsewhere - unsafe - { - InventoryManager* inventoryManager = InventoryManager.Instance(); - - EnumHelper.Each(currency => - { - var itemID = EnumHelper.GetAttributeOfType(currency).Value; - int quantity = inventoryManager->GetInventoryItemCount((uint)itemID); - - if (this.Configuration.AlertEnabled[currency] && quantity >= this.Configuration.Threshold[currency]) - { - this.PluginUI.AlertVisible[currency] = true; - } - else - { - this.PluginUI.AlertVisible[currency] = false; - } - }); - } - - this.PluginUI.Draw(); - } - - private void DrawConfigUI() - { - this.PluginUI.SettingsVisible = true; - } - } -} +using CurrencyAlert.Enum; +using Dalamud.Game.Command; +using Dalamud.Game.Gui; +using Dalamud.IoC; +using Dalamud.Plugin; +using FFXIVClientStructs.FFXIV.Client.Game; +using System.IO; +using System.Reflection; + +namespace CurrencyAlert +{ + public sealed class Plugin : IDalamudPlugin + { + public string Name => "Currency Alert"; + + private const string commandName = "/currencyalert"; + + private DalamudPluginInterface PluginInterface { get; init; } + private CommandManager CommandManager { get; init; } + private Configuration Configuration { get; init; } + private PluginUI PluginUI { get; init; } + + [PluginService] public static ChatGui Chat { get; private set; } = null!; + + public Plugin( + [RequiredVersion("1.0")] DalamudPluginInterface pluginInterface, + [RequiredVersion("1.0")] CommandManager commandManager) + { + this.PluginInterface = pluginInterface; + this.CommandManager = commandManager; + + this.Configuration = this.PluginInterface.GetPluginConfig() as Configuration ?? new Configuration(); + this.Configuration.Initialize(this.PluginInterface); + + var assemblyLocation = Assembly.GetExecutingAssembly().Location; + this.PluginUI = new PluginUI(this.Configuration); + + this.CommandManager.AddHandler(commandName, new CommandInfo(OnCommand) + { + HelpMessage = "Lets you configure alert thresholds for various currencies" + }); + + this.PluginInterface.UiBuilder.Draw += DrawUI; + this.PluginInterface.UiBuilder.OpenConfigUi += DrawConfigUI; + } + + public void Dispose() + { + this.PluginUI.Dispose(); + this.CommandManager.RemoveHandler(commandName); + } + + private void OnCommand(string command, string args) + { + this.DrawConfigUI(); + } + + private void DrawUI() + { + // TODO: move this logic elsewhere + unsafe + { + InventoryManager* inventoryManager = InventoryManager.Instance(); + + EnumHelper.Each(currency => + { + var itemID = EnumHelper.GetAttributeOfType(currency).Value; + int quantity = inventoryManager->GetInventoryItemCount((uint)itemID); + + if (this.Configuration.AlertEnabled[currency] && quantity >= this.Configuration.Threshold[currency]) + { + this.PluginUI.AlertVisible[currency] = true; + } + else + { + this.PluginUI.AlertVisible[currency] = false; + } + }); + } + + this.PluginUI.Draw(); + } + + private void DrawConfigUI() + { + this.PluginUI.SettingsVisible = true; + } + } +} diff --git a/SamplePlugin/PluginUI.cs b/CurrencyAlert/PluginUI.cs similarity index 97% rename from SamplePlugin/PluginUI.cs rename to CurrencyAlert/PluginUI.cs index 604435b..1496636 100644 --- a/SamplePlugin/PluginUI.cs +++ b/CurrencyAlert/PluginUI.cs @@ -1,111 +1,111 @@ -using CurrencyAlert.Enum; -using Dalamud.Game.Gui; -using Dalamud.IoC; -using FFXIVClientStructs.FFXIV.Client.Game; -using ImGuiNET; -using System; -using System.Collections.Generic; -using System.Numerics; - -namespace CurrencyAlert -{ - class PluginUI : IDisposable - { - private Configuration configuration; - - private bool settingsVisible = false; - public bool SettingsVisible - { - get { return settingsVisible; } - set { settingsVisible = value; } - } - public Dictionary AlertVisible { get; set; } = new Dictionary(); - - public PluginUI(Configuration configuration) - { - this.configuration = configuration; - - EnumHelper.Each(currency => this.AlertVisible[currency] = false); - } - - public void Dispose() - { - - } - - public void Draw() - { - DrawMainWindow(); - - if (this.SettingsVisible) - DrawSettingsWindow(); - } - - public void DrawMainWindow() - { - EnumHelper.Each(currency => - { - if (!this.AlertVisible[currency]) - return; - - ImGui.SetNextWindowSize(new Vector2(375, 10), ImGuiCond.FirstUseEver); - ImGui.SetNextWindowSizeConstraints(new Vector2(375, 10), new Vector2(float.MaxValue, float.MaxValue)); - - var isVisible = this.AlertVisible[currency]; - - if (ImGui.Begin("Currency Alert", ref isVisible, - ImGuiWindowFlags.NoScrollbar | - ImGuiWindowFlags.NoScrollWithMouse | - ImGuiWindowFlags.AlwaysAutoResize | - ImGuiWindowFlags.NoTitleBar | - ImGuiWindowFlags.NoFocusOnAppearing - )) - { - var name = EnumHelper.GetAttributeOfType(currency).Value; - ImGui.Text($"You need to spend your {name}"); - } - - ImGui.End(); - }); - } - - public void DrawSettingsWindow() - { - ImGui.SetNextWindowSize(new Vector2(700, 500), ImGuiCond.FirstUseEver); - if (ImGui.Begin("Currency Alert Configuration Window", ref this.settingsVisible)) - { - if (ImGui.BeginTabBar("AlertsConfiguration_Tabs")) - { - EnumHelper.Each(currency => - { - var name = EnumHelper.GetAttributeOfType(currency).Value; - var category = EnumHelper.GetAttributeOfType(currency).Value; - var alertEnabled = this.configuration.AlertEnabled[currency]; - - if (ImGui.BeginTabItem(category)) - { - if (ImGui.Checkbox($"{name} Alert Enabled", ref alertEnabled)) - { - this.configuration.AlertEnabled[currency] = alertEnabled; - 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(); - } - }); - } - } - - ImGui.End(); - } - } -} +using CurrencyAlert.Enum; +using Dalamud.Game.Gui; +using Dalamud.IoC; +using FFXIVClientStructs.FFXIV.Client.Game; +using ImGuiNET; +using System; +using System.Collections.Generic; +using System.Numerics; + +namespace CurrencyAlert +{ + class PluginUI : IDisposable + { + private Configuration configuration; + + private bool settingsVisible = false; + public bool SettingsVisible + { + get { return settingsVisible; } + set { settingsVisible = value; } + } + public Dictionary AlertVisible { get; set; } = new Dictionary(); + + public PluginUI(Configuration configuration) + { + this.configuration = configuration; + + EnumHelper.Each(currency => this.AlertVisible[currency] = false); + } + + public void Dispose() + { + + } + + public void Draw() + { + DrawMainWindow(); + + if (this.SettingsVisible) + DrawSettingsWindow(); + } + + public void DrawMainWindow() + { + EnumHelper.Each(currency => + { + if (!this.AlertVisible[currency]) + return; + + ImGui.SetNextWindowSize(new Vector2(375, 10), ImGuiCond.FirstUseEver); + ImGui.SetNextWindowSizeConstraints(new Vector2(375, 10), new Vector2(float.MaxValue, float.MaxValue)); + + var isVisible = this.AlertVisible[currency]; + + if (ImGui.Begin("Currency Alert", ref isVisible, + ImGuiWindowFlags.NoScrollbar | + ImGuiWindowFlags.NoScrollWithMouse | + ImGuiWindowFlags.AlwaysAutoResize | + ImGuiWindowFlags.NoTitleBar | + ImGuiWindowFlags.NoFocusOnAppearing + )) + { + var name = EnumHelper.GetAttributeOfType(currency).Value; + ImGui.Text($"You need to spend your {name}"); + } + + ImGui.End(); + }); + } + + public void DrawSettingsWindow() + { + ImGui.SetNextWindowSize(new Vector2(700, 500), ImGuiCond.FirstUseEver); + if (ImGui.Begin("Currency Alert Configuration Window", ref this.settingsVisible)) + { + if (ImGui.BeginTabBar("AlertsConfiguration_Tabs")) + { + EnumHelper.Each(currency => + { + var name = EnumHelper.GetAttributeOfType(currency).Value; + var category = EnumHelper.GetAttributeOfType(currency).Value; + var alertEnabled = this.configuration.AlertEnabled[currency]; + + if (ImGui.BeginTabItem(category)) + { + if (ImGui.Checkbox($"{name} Alert Enabled", ref alertEnabled)) + { + this.configuration.AlertEnabled[currency] = alertEnabled; + 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(); + } + }); + } + } + + ImGui.End(); + } + } +} diff --git a/SamplePlugin/currencyAlert.json b/CurrencyAlert/currencyAlert.json similarity index 81% rename from SamplePlugin/currencyAlert.json rename to CurrencyAlert/currencyAlert.json index 38fc138..d6cdf14 100644 --- a/SamplePlugin/currencyAlert.json +++ b/CurrencyAlert/currencyAlert.json @@ -12,9 +12,5 @@ "other" ], "CategoryTags": null, - "AssemblyVersion": "0.3.2.0", "RepoUrl": "https://github.com/Lharz/xiv-currency-alert", - "DalamudApiLevel": 6, - "ImageUrls": null, - "IconUrl": null } diff --git a/CurrencyAlert/packages.lock.json b/CurrencyAlert/packages.lock.json new file mode 100644 index 0000000..9628a11 --- /dev/null +++ b/CurrencyAlert/packages.lock.json @@ -0,0 +1,13 @@ +{ + "version": 1, + "dependencies": { + "net6.0-windows7.0": { + "DalamudPackager": { + "type": "Direct", + "requested": "[2.1.8, )", + "resolved": "2.1.8", + "contentHash": "YqagNXs9InxmqkXzq7kLveImxnodkBEicAhydMXVp7dFjC7xb76U6zGgAax4/BWIWfZeWzr5DJyQSev31kj81A==" + } + } + } +} \ No newline at end of file