diff --git a/CurrencyAlert/Attribute/CategoryAttribute.cs b/CurrencyAlert/Attribute/CategoryAttribute.cs deleted file mode 100644 index 7b5ee31..0000000 --- a/CurrencyAlert/Attribute/CategoryAttribute.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - -namespace CurrencyAlert.Enum -{ - internal class CategoryAttribute : Attribute - { - public CategoryAttribute(string v) - { - Value = v; - } - - public string Value { get; } - } -} diff --git a/CurrencyAlert/Attribute/DefaultThresholdAttribute.cs b/CurrencyAlert/Attribute/DefaultThresholdAttribute.cs deleted file mode 100644 index 5a3ee6b..0000000 --- a/CurrencyAlert/Attribute/DefaultThresholdAttribute.cs +++ /dev/null @@ -1,14 +0,0 @@ -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/CurrencyAlert/Attribute/ItemIDAttribute.cs b/CurrencyAlert/Attribute/ItemIDAttribute.cs deleted file mode 100644 index 32f4a38..0000000 --- a/CurrencyAlert/Attribute/ItemIDAttribute.cs +++ /dev/null @@ -1,14 +0,0 @@ -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/CurrencyAlert/Attribute/NameAttribute.cs b/CurrencyAlert/Attribute/NameAttribute.cs deleted file mode 100644 index 509a812..0000000 --- a/CurrencyAlert/Attribute/NameAttribute.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - -namespace CurrencyAlert.Enum -{ - internal class NameAttribute : Attribute - { - public NameAttribute(string v) - { - Value = v; - } - - public string Value { get; } - } -} diff --git a/CurrencyAlert/Configuration.cs b/CurrencyAlert/Configuration.cs index 626a3b4..a4ed233 100644 --- a/CurrencyAlert/Configuration.cs +++ b/CurrencyAlert/Configuration.cs @@ -1,40 +1,38 @@ -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; } = 5; - - 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.Helper; +using CurrencyAlert.Provider; +using Dalamud.Configuration; +using Dalamud.Plugin; +using System; +using System.Collections.Generic; + +namespace CurrencyAlert +{ + [Serializable] + public class Configuration : IPluginConfiguration + { + public int Version { get; set; } = 5; + + public bool UiLocked { get; set; } = false; + public Dictionary AlertEnabled { get; } = new Dictionary(); + public Dictionary Threshold { get; } = new Dictionary(); + + public Configuration() + { + foreach (var currency in CurrencyProvider.Instance.GetAll()) + { + this.AlertEnabled[currency.Id] = true; + this.Threshold[currency.Id] = currency.DefaultThreshold; + } + } + + public void Initialize() + { + + } + + public void Save() + { + PluginHelper.PluginInterface.SavePluginConfig(this); + } + } +} diff --git a/CurrencyAlert/CurrencyAlert.csproj b/CurrencyAlert/CurrencyAlert.csproj index 1a36924..e8e92a0 100644 --- a/CurrencyAlert/CurrencyAlert.csproj +++ b/CurrencyAlert/CurrencyAlert.csproj @@ -1,62 +1,67 @@  - - - - 0.3.3.1 - Currency Alert - - https://github.com/Lharz/xiv-currency-alert - + + + + 0.4.0.0 + Currency Alert + + https://github.com/Lharz/xiv-currency-alert + - - net6.0-windows - x64 - enable - latest - true - false - false - true - true - + + net6.0-windows + x64 + enable + latest + true + false + false + true + true + - - $(appdata)\XIVLauncher\addon\Hooks\dev\ - https://github.com/Lharz/xiv-currency-alert - git - + + $(appdata)\XIVLauncher\addon\Hooks\dev\ + https://github.com/Lharz/xiv-currency-alert + git + bin\ + - - - - $(DalamudLibPath)FFXIVClientStructs.dll - false - - - $(DalamudLibPath)Newtonsoft.Json.dll - false - - - $(DalamudLibPath)Dalamud.dll - false - - - $(DalamudLibPath)ImGui.NET.dll - false - - - $(DalamudLibPath)ImGuiScene.dll - false - - - $(DalamudLibPath)Lumina.dll - false - - - $(DalamudLibPath)Lumina.Excel.dll - false - - + + + + $(DalamudLibPath)FFXIVClientStructs.dll + false + + + $(DalamudLibPath)Newtonsoft.Json.dll + false + + + $(DalamudLibPath)Dalamud.dll + false + + + $(DalamudLibPath)ImGui.NET.dll + false + + + $(DalamudLibPath)ImGuiScene.dll + false + + + $(DalamudLibPath)Lumina.dll + false + + + $(DalamudLibPath)Lumina.Excel.dll + false + + + + + + diff --git a/CurrencyAlert/Entity/Currency.cs b/CurrencyAlert/Entity/Currency.cs new file mode 100644 index 0000000..31a46ae --- /dev/null +++ b/CurrencyAlert/Entity/Currency.cs @@ -0,0 +1,26 @@ +using CurrencyAlert.Enum; +using CurrencyAlert.Helper; +using ImGuiScene; + +namespace CurrencyAlert.Entity +{ + internal class Currency + { + public int Id { get; } + public string Name { get; } + public CurrencyType Type { get; } + public Category Category { get; } + public TextureWrap? Image { get; } + public int DefaultThreshold { get; } + + public Currency(int id, string name, CurrencyType type, Category category, int defaultThreshold) + { + Id = id; + Name = name; + Type = type; + Category = category; + DefaultThreshold = defaultThreshold; + Image = ImageHelper.LoadImage(id.ToString()); + } + } +} diff --git a/CurrencyAlert/Enum/Category.cs b/CurrencyAlert/Enum/Category.cs new file mode 100644 index 0000000..4759718 --- /dev/null +++ b/CurrencyAlert/Enum/Category.cs @@ -0,0 +1,9 @@ +namespace CurrencyAlert.Enum +{ + public enum Category + { + Common, + Battle, + Other + } +} diff --git a/CurrencyAlert/Enum/Currency.cs b/CurrencyAlert/Enum/Currency.cs deleted file mode 100644 index 984d514..0000000 --- a/CurrencyAlert/Enum/Currency.cs +++ /dev/null @@ -1,50 +0,0 @@ -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 Astronomy"), ItemID(43), DefaultThreshold(1700), Category("Battle")] - TomestoneOfAstronomy, - [Name("Tomestones of Causality"), ItemID(44), DefaultThreshold(1700), Category("Battle")] - TomestoneOfCausality, - - [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/CurrencyAlert/Enum/CurrencyType.cs b/CurrencyAlert/Enum/CurrencyType.cs new file mode 100644 index 0000000..851f84a --- /dev/null +++ b/CurrencyAlert/Enum/CurrencyType.cs @@ -0,0 +1,28 @@ +namespace CurrencyAlert.Enum +{ + public enum CurrencyType + { + TomestoneOfPoetics, + TomestoneOfAphorism, + TomestoneOfAstronomy, + TomestoneOfCausality, + + StormSeal, + SerpentSeal, + FlameSeal, + + WolfMark, + TrophyCrystal, + + AlliedSeal, + CenturioSeal, + SackOfNut, + BicolorGemstone, + + WhiteCraftersScrip, + PurpleCraftersScrip, + WhiteGatherersScrip, + PurpleGatherersScrip, + SkybuildersScrip + } +} diff --git a/CurrencyAlert/Helper/EnumHelper.cs b/CurrencyAlert/Helper/EnumHelper.cs deleted file mode 100644 index 2936606..0000000 --- a/CurrencyAlert/Helper/EnumHelper.cs +++ /dev/null @@ -1,32 +0,0 @@ - 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/CurrencyAlert/Helper/ImageHelper.cs b/CurrencyAlert/Helper/ImageHelper.cs new file mode 100644 index 0000000..2888bcc --- /dev/null +++ b/CurrencyAlert/Helper/ImageHelper.cs @@ -0,0 +1,24 @@ +using ImGuiScene; +using System; +using System.IO; + +namespace CurrencyAlert.Helper +{ + internal class ImageHelper + { + public static TextureWrap? LoadImage(string imageName) + { + var assemblyLocation = PluginHelper.PluginInterface.AssemblyLocation.DirectoryName!; + var imagePath = Path.Combine(assemblyLocation, $@"images\{imageName}.png"); + + try + { + return PluginHelper.PluginInterface.UiBuilder.LoadImage(imagePath); + } + catch (SystemException e) + { + return null; + } + } + } +} diff --git a/CurrencyAlert/Helper/PluginHelper.cs b/CurrencyAlert/Helper/PluginHelper.cs new file mode 100644 index 0000000..024c574 --- /dev/null +++ b/CurrencyAlert/Helper/PluginHelper.cs @@ -0,0 +1,16 @@ +using Dalamud.Game.ClientState; +using Dalamud.Game.Command; +using Dalamud.Game.Gui; +using Dalamud.IoC; +using Dalamud.Plugin; + +namespace CurrencyAlert.Helper +{ + internal class PluginHelper + { + [PluginService] public static DalamudPluginInterface PluginInterface { get; private set; } = null!; + [PluginService] public static ClientState ClientState { get; private set; } = null!; + [PluginService] public static CommandManager CommandManager { get; private set; } = null!; + [PluginService] public static ChatGui Chat { get; private set; } = null!; + } +} diff --git a/CurrencyAlert/Plugin.cs b/CurrencyAlert/Plugin.cs index f53022c..6371be0 100644 --- a/CurrencyAlert/Plugin.cs +++ b/CurrencyAlert/Plugin.cs @@ -1,89 +1,108 @@ -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.Helper; +using CurrencyAlert.Provider; +using Dalamud.Game.Command; +using Dalamud.Game.Gui; +using Dalamud.IoC; +using Dalamud.Plugin; +using FFXIVClientStructs.FFXIV.Client.Game; +using ImGuiNET; +using Newtonsoft.Json; +using System; +using System.Reflection; + +namespace CurrencyAlert +{ + public sealed class Plugin : IDalamudPlugin + { + public string Name => "Currency Alert"; + + private const string commandName = "/currencyalert"; + + private Configuration Configuration { get; init; } + private PluginUI PluginUI { get; init; } + + [PluginService] public static ChatGui Chat { get; private set; } = null!; + + private bool LoggedIn => PluginHelper.ClientState.LocalPlayer != null && PluginHelper.ClientState.LocalContentId != 0; + + public Plugin(DalamudPluginInterface pluginInterface) + { + pluginInterface.Create(); + + try + { + this.Configuration = PluginHelper.PluginInterface.GetPluginConfig() as Configuration ?? new Configuration(); + } + catch (Exception e) + { + this.Configuration = new Configuration(); + this.Configuration.Save(); + + PluginHelper.Chat.Print("Your CurrencyAlert configuration has been reset because of compatibility issues. Please check the plugin configuration window."); + } + + this.Configuration.Initialize(); + + var assemblyLocation = Assembly.GetExecutingAssembly().Location; + this.PluginUI = new PluginUI(this.Configuration); + + PluginHelper.CommandManager.AddHandler(commandName, new CommandInfo(OnCommand) + { + HelpMessage = "Lets you configure alert thresholds for various currencies" + }); + + PluginHelper.PluginInterface.UiBuilder.Draw += DrawUI; + PluginHelper.PluginInterface.UiBuilder.OpenConfigUi += DrawConfigUI; + } + + public void Dispose() + { + this.PluginUI.Dispose(); + PluginHelper.CommandManager.RemoveHandler(commandName); + } + + private void OnCommand(string command, string args) + { + this.DrawConfigUI(); + } + + private void DrawUI() + { + if (!this.LoggedIn) + return; + + this.UpdateAlerts(); + + this.PluginUI.Draw(); + } + + private void UpdateAlerts() + { + // TODO: move this logic elsewhere + // TODO: do this only every X seconds + unsafe + { + InventoryManager* inventoryManager = InventoryManager.Instance(); + + foreach (var currency in CurrencyProvider.Instance.GetAll()) + { + int quantity = inventoryManager->GetInventoryItemCount((uint)currency.Id); + + if (this.Configuration.AlertEnabled[currency.Id] && quantity >= this.Configuration.Threshold[currency.Id]) + { + this.PluginUI.AlertVisible[currency.Id] = true; + } + else + { + this.PluginUI.AlertVisible[currency.Id] = false; + } + } + } + } + + private void DrawConfigUI() + { + this.PluginUI.SettingsVisible = true; + } + } +} diff --git a/CurrencyAlert/PluginUI.cs b/CurrencyAlert/PluginUI.cs index 1496636..cd3a966 100644 --- a/CurrencyAlert/PluginUI.cs +++ b/CurrencyAlert/PluginUI.cs @@ -1,111 +1,145 @@ -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.Provider; +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; + + foreach (var currency in CurrencyProvider.Instance.GetAll()) + { + this.AlertVisible[currency.Id] = false; + } + } + + public void Dispose() + { + + } + + public void Draw() + { + DrawMainWindow(); + + if (this.SettingsVisible) + DrawSettingsWindow(); + } + + public void DrawMainWindow() + { + foreach (var currency in CurrencyProvider.Instance.GetAll()) + { + if (!this.AlertVisible[currency.Id]) + continue; + + 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.Id]; + + var guiOptions = ImGuiWindowFlags.NoScrollbar | + ImGuiWindowFlags.NoScrollWithMouse | + ImGuiWindowFlags.AlwaysAutoResize | + ImGuiWindowFlags.NoTitleBar | + ImGuiWindowFlags.NoFocusOnAppearing; + + if (configuration.UiLocked) + guiOptions |= ImGuiWindowFlags.NoMove; + + if (ImGui.Begin("Currency Alert", ref isVisible, guiOptions)) + { + ImGui.Text($"You need to spend your"); + + if (currency.Image != null) + { + ImGui.SameLine(); + ImGui.Image(currency.Image.ImGuiHandle, new Vector2(22, 22)); + } + + ImGui.SameLine(); + + ImGui.Text($"{currency.Name}"); + + ImGui.End(); + } + } + } + + public void DrawSettingsWindow() + { + ImGui.SetNextWindowSize(new Vector2(700, 500), ImGuiCond.FirstUseEver); + if (ImGui.Begin("Currency Alert Configuration Window", ref this.settingsVisible)) + { + var uiLocked = this.configuration.UiLocked; + + if (ImGui.Checkbox("Lock alert window", ref uiLocked)) + { + this.configuration.UiLocked = uiLocked; + this.configuration.Save(); + } + + if (ImGui.BeginTabBar("AlertsConfiguration_Tabs")) + { + foreach (var currency in CurrencyProvider.Instance.GetAll()) + { + var name = currency.Name; + var category = currency.Category; + var alertEnabled = this.configuration.AlertEnabled[currency.Id]; + + if (ImGui.BeginTabItem(category.ToString())) + { + if (currency.Image != null) + { + ImGui.Image(currency.Image.ImGuiHandle, new Vector2(22, 22)); + ImGui.SameLine(); + } + + ImGui.Text($"{currency.Name}"); + + if (ImGui.Checkbox($"Enabled##{name}", ref alertEnabled)) + { + this.configuration.AlertEnabled[currency.Id] = alertEnabled; + this.configuration.Save(); + } + + ImGui.SameLine(); + + var thresholdValue = this.configuration.Threshold[currency.Id]; + + if (ImGui.InputInt($"Threshold##{name}", ref thresholdValue, 1, 1, + this.configuration.AlertEnabled[currency.Id] ? ImGuiInputTextFlags.None : ImGuiInputTextFlags.ReadOnly)) + { + this.configuration.Threshold[currency.Id] = thresholdValue; + this.configuration.Save(); + } + + ImGui.Separator(); + + ImGui.EndTabItem(); + } + } + + ImGui.EndTabBar(); + } + + ImGui.End(); + } + } + } +} diff --git a/CurrencyAlert/Provider/CurrencyProvider.cs b/CurrencyAlert/Provider/CurrencyProvider.cs new file mode 100644 index 0000000..61c7511 --- /dev/null +++ b/CurrencyAlert/Provider/CurrencyProvider.cs @@ -0,0 +1,46 @@ +using CurrencyAlert.Entity; +using System.Collections.Generic; + +namespace CurrencyAlert.Provider +{ + internal sealed class CurrencyProvider + { + private static CurrencyProvider? instance = null; + public static CurrencyProvider Instance => instance ??= new CurrencyProvider(); + + private readonly List currencies; + + public CurrencyProvider() + { + currencies = new List + { + new Currency(28, "Tomestones of Poetics", Enum.CurrencyType.TomestoneOfPoetics, Enum.Category.Battle, 1400), + new Currency(43, "Tomestones of Astronomy", Enum.CurrencyType.TomestoneOfAstronomy, Enum.Category.Battle, 1700), + new Currency(44, "Tomestones of Causality", Enum.CurrencyType.TomestoneOfCausality, Enum.Category.Battle, 1700), + + new Currency(20, "Storm Seals", Enum.CurrencyType.StormSeal, Enum.Category.Common, 75000), + new Currency(21, "Serpent Seals", Enum.CurrencyType.SerpentSeal, Enum.Category.Common, 75000), + new Currency(22, "Flame Seals", Enum.CurrencyType.FlameSeal, Enum.Category.Common, 75000), + + new Currency(25, "Wolf Marks", Enum.CurrencyType.WolfMark, Enum.Category.Battle, 18000), + new Currency(36656, "Trophy Crystals", Enum.CurrencyType.TrophyCrystal, Enum.Category.Battle, 18000), + + new Currency(27, "Allied Seals", Enum.CurrencyType.AlliedSeal, Enum.Category.Battle, 3500), + new Currency(10307, "Centurio Seals", Enum.CurrencyType.CenturioSeal, Enum.Category.Battle, 3500), + new Currency(26533, "Sack of Nuts", Enum.CurrencyType.SackOfNut, Enum.Category.Battle, 3500), + new Currency(26807, "Bicolor Gemstone", Enum.CurrencyType.BicolorGemstone, Enum.Category.Battle, 800), + + new Currency(25199, "White Crafters' Scrip", Enum.CurrencyType.WhiteCraftersScrip, Enum.Category.Other, 1500), + new Currency(33913, "Purple Crafters' Scrip", Enum.CurrencyType.PurpleCraftersScrip, Enum.Category.Other, 1500), + new Currency(25200, "White Gatherers' Scrip", Enum.CurrencyType.WhiteGatherersScrip, Enum.Category.Other, 1500), + new Currency(33914, "Purple Gatherers' Scrip", Enum.CurrencyType.PurpleGatherersScrip, Enum.Category.Other, 1500), + new Currency(28063, "Skybuilders' Scrip", Enum.CurrencyType.SkybuildersScrip, Enum.Category.Other, 7500), + }; + } + + public IEnumerable GetAll() + { + return currencies; + } + } +} diff --git a/CurrencyAlert/images/10307.png b/CurrencyAlert/images/10307.png new file mode 100644 index 0000000..86f94b3 Binary files /dev/null and b/CurrencyAlert/images/10307.png differ diff --git a/CurrencyAlert/images/20.png b/CurrencyAlert/images/20.png new file mode 100644 index 0000000..cfca4a4 Binary files /dev/null and b/CurrencyAlert/images/20.png differ diff --git a/CurrencyAlert/images/21.png b/CurrencyAlert/images/21.png new file mode 100644 index 0000000..c1d7ad0 Binary files /dev/null and b/CurrencyAlert/images/21.png differ diff --git a/CurrencyAlert/images/22.png b/CurrencyAlert/images/22.png new file mode 100644 index 0000000..0ad4a96 Binary files /dev/null and b/CurrencyAlert/images/22.png differ diff --git a/CurrencyAlert/images/25.png b/CurrencyAlert/images/25.png new file mode 100644 index 0000000..fbc49be Binary files /dev/null and b/CurrencyAlert/images/25.png differ diff --git a/CurrencyAlert/images/25199.png b/CurrencyAlert/images/25199.png new file mode 100644 index 0000000..235de91 Binary files /dev/null and b/CurrencyAlert/images/25199.png differ diff --git a/CurrencyAlert/images/25200.png b/CurrencyAlert/images/25200.png new file mode 100644 index 0000000..e81ca60 Binary files /dev/null and b/CurrencyAlert/images/25200.png differ diff --git a/CurrencyAlert/images/26533.png b/CurrencyAlert/images/26533.png new file mode 100644 index 0000000..d77adb0 Binary files /dev/null and b/CurrencyAlert/images/26533.png differ diff --git a/CurrencyAlert/images/26807.png b/CurrencyAlert/images/26807.png new file mode 100644 index 0000000..8e54184 Binary files /dev/null and b/CurrencyAlert/images/26807.png differ diff --git a/CurrencyAlert/images/27.png b/CurrencyAlert/images/27.png new file mode 100644 index 0000000..ebe77e7 Binary files /dev/null and b/CurrencyAlert/images/27.png differ diff --git a/CurrencyAlert/images/28.png b/CurrencyAlert/images/28.png new file mode 100644 index 0000000..f0568dd Binary files /dev/null and b/CurrencyAlert/images/28.png differ diff --git a/CurrencyAlert/images/28063.png b/CurrencyAlert/images/28063.png new file mode 100644 index 0000000..2e125b8 Binary files /dev/null and b/CurrencyAlert/images/28063.png differ diff --git a/CurrencyAlert/images/33913.png b/CurrencyAlert/images/33913.png new file mode 100644 index 0000000..cfd29d3 Binary files /dev/null and b/CurrencyAlert/images/33913.png differ diff --git a/CurrencyAlert/images/33914.png b/CurrencyAlert/images/33914.png new file mode 100644 index 0000000..71ef183 Binary files /dev/null and b/CurrencyAlert/images/33914.png differ diff --git a/CurrencyAlert/images/36656.png b/CurrencyAlert/images/36656.png new file mode 100644 index 0000000..7af3775 Binary files /dev/null and b/CurrencyAlert/images/36656.png differ diff --git a/CurrencyAlert/images/43.png b/CurrencyAlert/images/43.png new file mode 100644 index 0000000..fac0d4b Binary files /dev/null and b/CurrencyAlert/images/43.png differ diff --git a/CurrencyAlert/images/44.png b/CurrencyAlert/images/44.png new file mode 100644 index 0000000..096ff6b Binary files /dev/null and b/CurrencyAlert/images/44.png differ