diff --git a/SamplePlugin/Attribute/NameAttribute.cs b/SamplePlugin/Attribute/NameAttribute.cs new file mode 100644 index 0000000..f6c3a13 --- /dev/null +++ b/SamplePlugin/Attribute/NameAttribute.cs @@ -0,0 +1,14 @@ +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/SamplePlugin/Configuration.cs index 55a9036..7b27c67 100644 --- a/SamplePlugin/Configuration.cs +++ b/SamplePlugin/Configuration.cs @@ -9,7 +9,7 @@ namespace CurrencyAlert [Serializable] public class Configuration : IPluginConfiguration { - public int Version { get; set; } = 2; + public int Version { get; set; } = 4; public Dictionary AlertEnabled { get; set; } = new Dictionary(); public Dictionary Threshold { get; set; } = new Dictionary(); @@ -29,7 +29,7 @@ namespace CurrencyAlert }); } - public void Save() + public void Save() { this.pluginInterface!.SavePluginConfig(this); } diff --git a/SamplePlugin/Enum/Currency.cs b/SamplePlugin/Enum/Currency.cs index 1c59e07..c3cff90 100644 --- a/SamplePlugin/Enum/Currency.cs +++ b/SamplePlugin/Enum/Currency.cs @@ -8,25 +8,19 @@ namespace CurrencyAlert.Enum { public enum Currency { - [Slot(1), DefaultThreshold(75000)] - StormSeal, - - [Slot(2), DefaultThreshold(75000)] - SerpentSeal, - - [Slot(3), DefaultThreshold(75000)] - FlameSeal, - - [Slot(4), DefaultThreshold(18000)] - WolfMark, - - [Slot(6), DefaultThreshold(1500)] + [Name("Tomestones of Poetics"), Slot(6), DefaultThreshold(1500)] TomestoneOfPoetics, - - [Slot(8), DefaultThreshold(3500)] - AlliedSeal, - - [Slot(10), DefaultThreshold(1500)] - TomestoneOfAstronomy + [Name("Tomestones of Astronomy"), Slot(10), DefaultThreshold(1500)] + TomestoneOfAstronomy, + [Name("Storm Seals"), Slot(1), DefaultThreshold(75000)] + StormSeal, + [Name("Serpent Seals"), Slot(2), DefaultThreshold(75000)] + SerpentSeal, + [Name("Flame Seals"), Slot(3), DefaultThreshold(75000)] + FlameSeal, + [Name("Wolf Marks"), Slot(4), DefaultThreshold(18000)] + WolfMark, + [Name("Allied Seals"), Slot(8), DefaultThreshold(3500)] + AlliedSeal } } diff --git a/SamplePlugin/Plugin.cs b/SamplePlugin/Plugin.cs index fba1b6f..d24cc7b 100644 --- a/SamplePlugin/Plugin.cs +++ b/SamplePlugin/Plugin.cs @@ -1,64 +1,64 @@ using CurrencyAlert.Enum; -using Dalamud.Game.Command; +using Dalamud.Game.Command; using Dalamud.Game.Gui; -using Dalamud.IoC; -using Dalamud.Plugin; +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); - - // you might normally want to embed resources and load them from the manifest stream - 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" +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); + + // you might normally want to embed resources and load them from the manifest stream + 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; + 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 + 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(); @@ -77,15 +77,15 @@ namespace CurrencyAlert { this.PluginUI.AlertVisible[currency] = false; } - }); - } - - this.PluginUI.Draw(); - } - - private void DrawConfigUI() - { - this.PluginUI.SettingsVisible = true; - } - } -} + }); + } + + this.PluginUI.Draw(); + } + + private void DrawConfigUI() + { + this.PluginUI.SettingsVisible = true; + } + } +} diff --git a/SamplePlugin/PluginUI.cs b/SamplePlugin/PluginUI.cs index adc4ed3..e958050 100644 --- a/SamplePlugin/PluginUI.cs +++ b/SamplePlugin/PluginUI.cs @@ -62,7 +62,7 @@ namespace CurrencyAlert var isVisible = this.AlertVisible[currency]; - if (ImGui.Begin("Currency Alert", ref isVisible, + if (ImGui.Begin("Currency Alert", ref isVisible, ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse | ImGuiWindowFlags.AlwaysAutoResize | @@ -70,7 +70,8 @@ namespace CurrencyAlert ImGuiWindowFlags.NoFocusOnAppearing )) { - ImGui.Text($"You need to spend your {currency}"); + var name = EnumHelper.GetAttributeOfType(currency).Value; + ImGui.Text($"You need to spend your {name}"); } ImGui.End(); @@ -85,9 +86,10 @@ namespace CurrencyAlert { EnumHelper.Each(currency => { + var name = EnumHelper.GetAttributeOfType(currency).Value; var alertEnabled = this.configuration.AlertEnabled[currency]; - if (ImGui.Checkbox($"{currency.ToString()} Alert Enabled", ref alertEnabled)) + if (ImGui.Checkbox($"{name} Alert Enabled", ref alertEnabled)) { this.configuration.AlertEnabled[currency] = alertEnabled; this.configuration.Save(); @@ -95,7 +97,7 @@ namespace CurrencyAlert var thresholdValue = this.configuration.Threshold[currency]; - if (ImGui.InputInt($"{currency.ToString()} Threshold Value", ref thresholdValue, 1, 1, + if (ImGui.InputInt($"{name} Threshold Value", ref thresholdValue, 1, 1, this.configuration.AlertEnabled[currency] ? ImGuiInputTextFlags.None : ImGuiInputTextFlags.ReadOnly)) { this.configuration.Threshold[currency] = thresholdValue;