code refactor + images for currencies

This commit is contained in:
Camille 2022-09-14 18:35:53 +02:00
parent f563fb778f
commit d0e239a0c1
33 changed files with 500 additions and 433 deletions

View File

@ -1,14 +0,0 @@
using System;
namespace CurrencyAlert.Enum
{
internal class CategoryAttribute : Attribute
{
public CategoryAttribute(string v)
{
Value = v;
}
public string Value { get; }
}
}

View File

@ -1,14 +0,0 @@
using System;
namespace CurrencyAlert
{
internal class DefaultThresholdAttribute : Attribute
{
public DefaultThresholdAttribute(int v)
{
Value = v;
}
public int Value { get; }
}
}

View File

@ -1,14 +0,0 @@
using System;
namespace CurrencyAlert
{
internal class ItemIDAttribute : Attribute
{
public ItemIDAttribute(int v)
{
Value = v;
}
public int Value { get; }
}
}

View File

@ -1,14 +0,0 @@
using System;
namespace CurrencyAlert.Enum
{
internal class NameAttribute : Attribute
{
public NameAttribute(string v)
{
Value = v;
}
public string Value { get; }
}
}

View File

@ -1,40 +1,38 @@
using CurrencyAlert.Enum; using CurrencyAlert.Helper;
using Dalamud.Configuration; using CurrencyAlert.Provider;
using Dalamud.Plugin; using Dalamud.Configuration;
using System; using Dalamud.Plugin;
using System.Collections.Generic; using System;
using System.Collections.Generic;
namespace CurrencyAlert
{ namespace CurrencyAlert
[Serializable] {
public class Configuration : IPluginConfiguration [Serializable]
{ public class Configuration : IPluginConfiguration
public int Version { get; set; } = 5; {
public int Version { get; set; } = 5;
public Dictionary<Currency, bool> AlertEnabled { get; set; } = new Dictionary<Currency, bool>();
public Dictionary<Currency, int> Threshold { get; set; } = new Dictionary<Currency , int>(); public bool UiLocked { get; set; } = false;
public Dictionary<int, bool> AlertEnabled { get; } = new Dictionary<int, bool>();
[NonSerialized] public Dictionary<int, int> Threshold { get; } = new Dictionary<int, int>();
private DalamudPluginInterface? pluginInterface;
public Configuration()
public Configuration() {
{ foreach (var currency in CurrencyProvider.Instance.GetAll())
EnumHelper.Each<Currency>(currency => {
{ this.AlertEnabled[currency.Id] = true;
this.AlertEnabled[currency] = true; this.Threshold[currency.Id] = currency.DefaultThreshold;
var defaultValue = EnumHelper.GetAttributeOfType<DefaultThresholdAttribute>(currency); }
this.Threshold[currency] = defaultValue.Value; }
});
} public void Initialize()
{
public void Initialize(DalamudPluginInterface pluginInterface)
{ }
this.pluginInterface = pluginInterface;
} public void Save()
{
public void Save() PluginHelper.PluginInterface.SavePluginConfig(this);
{ }
this.pluginInterface!.SavePluginConfig(this); }
} }
}
}

View File

@ -1,62 +1,67 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<Authors></Authors> <Authors></Authors>
<Company></Company> <Company></Company>
<Version>0.3.3.1</Version> <Version>0.4.0.0</Version>
<Description>Currency Alert</Description> <Description>Currency Alert</Description>
<Copyright></Copyright> <Copyright></Copyright>
<PackageProjectUrl>https://github.com/Lharz/xiv-currency-alert</PackageProjectUrl> <PackageProjectUrl>https://github.com/Lharz/xiv-currency-alert</PackageProjectUrl>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework> <TargetFramework>net6.0-windows</TargetFramework>
<Platforms>x64</Platforms> <Platforms>x64</Platforms>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly> <ProduceReferenceAssembly>false</ProduceReferenceAssembly>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile> <RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<DalamudLibPath>$(appdata)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath> <DalamudLibPath>$(appdata)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath>
<RepositoryUrl>https://github.com/Lharz/xiv-currency-alert</RepositoryUrl> <RepositoryUrl>https://github.com/Lharz/xiv-currency-alert</RepositoryUrl>
<RepositoryType>git</RepositoryType> <RepositoryType>git</RepositoryType>
</PropertyGroup> <BaseOutputPath>bin\</BaseOutputPath>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.8" /> <PackageReference Include="DalamudPackager" Version="2.1.8" />
<Reference Include="FFXIVClientStructs"> <Reference Include="FFXIVClientStructs">
<HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath> <HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath>
<Private>false</Private> <Private>false</Private>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json"> <Reference Include="Newtonsoft.Json">
<HintPath>$(DalamudLibPath)Newtonsoft.Json.dll</HintPath> <HintPath>$(DalamudLibPath)Newtonsoft.Json.dll</HintPath>
<Private>false</Private> <Private>false</Private>
</Reference> </Reference>
<Reference Include="Dalamud"> <Reference Include="Dalamud">
<HintPath>$(DalamudLibPath)Dalamud.dll</HintPath> <HintPath>$(DalamudLibPath)Dalamud.dll</HintPath>
<Private>false</Private> <Private>false</Private>
</Reference> </Reference>
<Reference Include="ImGui.NET"> <Reference Include="ImGui.NET">
<HintPath>$(DalamudLibPath)ImGui.NET.dll</HintPath> <HintPath>$(DalamudLibPath)ImGui.NET.dll</HintPath>
<Private>false</Private> <Private>false</Private>
</Reference> </Reference>
<Reference Include="ImGuiScene"> <Reference Include="ImGuiScene">
<HintPath>$(DalamudLibPath)ImGuiScene.dll</HintPath> <HintPath>$(DalamudLibPath)ImGuiScene.dll</HintPath>
<Private>false</Private> <Private>false</Private>
</Reference> </Reference>
<Reference Include="Lumina"> <Reference Include="Lumina">
<HintPath>$(DalamudLibPath)Lumina.dll</HintPath> <HintPath>$(DalamudLibPath)Lumina.dll</HintPath>
<Private>false</Private> <Private>false</Private>
</Reference> </Reference>
<Reference Include="Lumina.Excel"> <Reference Include="Lumina.Excel">
<HintPath>$(DalamudLibPath)Lumina.Excel.dll</HintPath> <HintPath>$(DalamudLibPath)Lumina.Excel.dll</HintPath>
<Private>false</Private> <Private>false</Private>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Content Include="images\**" Link="images\%(RecursiveDir)\%(Filename)%(Extension)" CopyToOutputDirectory="Always" />
</ItemGroup>
</Project> </Project>

View File

@ -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());
}
}
}

View File

@ -0,0 +1,9 @@
namespace CurrencyAlert.Enum
{
public enum Category
{
Common,
Battle,
Other
}
}

View File

@ -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
}
}

View File

@ -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
}
}

View File

@ -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
{
/// <summary>
/// Gets an attribute on an enum field value
/// </summary>
/// <typeparam name="T">The type of the attribute you want to retrieve</typeparam>
/// <param name="enumVal">The enum value</param>
/// <returns>The attribute of type T that exists on the enum value</returns>
/// <example><![CDATA[string desc = myEnumVariable.GetAttributeOfType<DescriptionAttribute>().Description;]]></example>
public static T GetAttributeOfType<T>(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<T>(Action<T> action)
{
foreach (var item in System.Enum.GetValues(typeof(T)))
action((T)item);
}
}
}

View File

@ -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;
}
}
}
}

View File

@ -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!;
}
}

View File

@ -1,89 +1,108 @@
using CurrencyAlert.Enum; using CurrencyAlert.Helper;
using Dalamud.Game.Command; using CurrencyAlert.Provider;
using Dalamud.Game.Gui; using Dalamud.Game.Command;
using Dalamud.IoC; using Dalamud.Game.Gui;
using Dalamud.Plugin; using Dalamud.IoC;
using FFXIVClientStructs.FFXIV.Client.Game; using Dalamud.Plugin;
using System.IO; using FFXIVClientStructs.FFXIV.Client.Game;
using System.Reflection; using ImGuiNET;
using Newtonsoft.Json;
namespace CurrencyAlert using System;
{ using System.Reflection;
public sealed class Plugin : IDalamudPlugin
{ namespace CurrencyAlert
public string Name => "Currency Alert"; {
public sealed class Plugin : IDalamudPlugin
private const string commandName = "/currencyalert"; {
public string Name => "Currency Alert";
private DalamudPluginInterface PluginInterface { get; init; }
private CommandManager CommandManager { get; init; } private const string commandName = "/currencyalert";
private Configuration Configuration { get; init; }
private PluginUI PluginUI { get; init; } private Configuration Configuration { get; init; }
private PluginUI PluginUI { get; init; }
[PluginService] public static ChatGui Chat { get; private set; } = null!;
[PluginService] public static ChatGui Chat { get; private set; } = null!;
public Plugin(
[RequiredVersion("1.0")] DalamudPluginInterface pluginInterface, private bool LoggedIn => PluginHelper.ClientState.LocalPlayer != null && PluginHelper.ClientState.LocalContentId != 0;
[RequiredVersion("1.0")] CommandManager commandManager)
{ public Plugin(DalamudPluginInterface pluginInterface)
this.PluginInterface = pluginInterface; {
this.CommandManager = commandManager; pluginInterface.Create<PluginHelper>();
this.Configuration = this.PluginInterface.GetPluginConfig() as Configuration ?? new Configuration(); try
this.Configuration.Initialize(this.PluginInterface); {
this.Configuration = PluginHelper.PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
var assemblyLocation = Assembly.GetExecutingAssembly().Location; }
this.PluginUI = new PluginUI(this.Configuration); catch (Exception e)
{
this.CommandManager.AddHandler(commandName, new CommandInfo(OnCommand) this.Configuration = new Configuration();
{ this.Configuration.Save();
HelpMessage = "Lets you configure alert thresholds for various currencies"
}); PluginHelper.Chat.Print("Your CurrencyAlert configuration has been reset because of compatibility issues. Please check the plugin configuration window.");
}
this.PluginInterface.UiBuilder.Draw += DrawUI;
this.PluginInterface.UiBuilder.OpenConfigUi += DrawConfigUI; this.Configuration.Initialize();
}
var assemblyLocation = Assembly.GetExecutingAssembly().Location;
public void Dispose() this.PluginUI = new PluginUI(this.Configuration);
{
this.PluginUI.Dispose(); PluginHelper.CommandManager.AddHandler(commandName, new CommandInfo(OnCommand)
this.CommandManager.RemoveHandler(commandName); {
} HelpMessage = "Lets you configure alert thresholds for various currencies"
});
private void OnCommand(string command, string args)
{ PluginHelper.PluginInterface.UiBuilder.Draw += DrawUI;
this.DrawConfigUI(); PluginHelper.PluginInterface.UiBuilder.OpenConfigUi += DrawConfigUI;
} }
private void DrawUI() public void Dispose()
{ {
// TODO: move this logic elsewhere this.PluginUI.Dispose();
unsafe PluginHelper.CommandManager.RemoveHandler(commandName);
{ }
InventoryManager* inventoryManager = InventoryManager.Instance();
private void OnCommand(string command, string args)
EnumHelper.Each<Currency>(currency => {
{ this.DrawConfigUI();
var itemID = EnumHelper.GetAttributeOfType<ItemIDAttribute>(currency).Value; }
int quantity = inventoryManager->GetInventoryItemCount((uint)itemID);
private void DrawUI()
if (this.Configuration.AlertEnabled[currency] && quantity >= this.Configuration.Threshold[currency]) {
{ if (!this.LoggedIn)
this.PluginUI.AlertVisible[currency] = true; return;
}
else this.UpdateAlerts();
{
this.PluginUI.AlertVisible[currency] = false; this.PluginUI.Draw();
} }
});
} private void UpdateAlerts()
{
this.PluginUI.Draw(); // TODO: move this logic elsewhere
} // TODO: do this only every X seconds
unsafe
private void DrawConfigUI() {
{ InventoryManager* inventoryManager = InventoryManager.Instance();
this.PluginUI.SettingsVisible = true;
} 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;
}
}
}

View File

@ -1,111 +1,145 @@
using CurrencyAlert.Enum; using CurrencyAlert.Provider;
using Dalamud.Game.Gui; using ImGuiNET;
using Dalamud.IoC; using System;
using FFXIVClientStructs.FFXIV.Client.Game; using System.Collections.Generic;
using ImGuiNET; using System.Numerics;
using System;
using System.Collections.Generic; namespace CurrencyAlert
using System.Numerics; {
class PluginUI : IDisposable
namespace CurrencyAlert {
{ private Configuration configuration;
class PluginUI : IDisposable
{ private bool settingsVisible = false;
private Configuration configuration; public bool SettingsVisible
{
private bool settingsVisible = false; get { return settingsVisible; }
public bool SettingsVisible set { settingsVisible = value; }
{ }
get { return settingsVisible; } public Dictionary<int, bool> AlertVisible { get; set; } = new Dictionary<int, bool>();
set { settingsVisible = value; }
} public PluginUI(Configuration configuration)
public Dictionary<Currency, bool> AlertVisible { get; set; } = new Dictionary<Currency, bool>(); {
this.configuration = configuration;
public PluginUI(Configuration configuration)
{ foreach (var currency in CurrencyProvider.Instance.GetAll())
this.configuration = configuration; {
this.AlertVisible[currency.Id] = false;
EnumHelper.Each<Currency>(currency => this.AlertVisible[currency] = false); }
} }
public void Dispose() public void Dispose()
{ {
} }
public void Draw() public void Draw()
{ {
DrawMainWindow(); DrawMainWindow();
if (this.SettingsVisible) if (this.SettingsVisible)
DrawSettingsWindow(); DrawSettingsWindow();
} }
public void DrawMainWindow() public void DrawMainWindow()
{ {
EnumHelper.Each<Currency>(currency => foreach (var currency in CurrencyProvider.Instance.GetAll())
{ {
if (!this.AlertVisible[currency]) if (!this.AlertVisible[currency.Id])
return; continue;
ImGui.SetNextWindowSize(new Vector2(375, 10), ImGuiCond.FirstUseEver); ImGui.SetNextWindowSize(new Vector2(375, 10), ImGuiCond.FirstUseEver);
ImGui.SetNextWindowSizeConstraints(new Vector2(375, 10), new Vector2(float.MaxValue, float.MaxValue)); ImGui.SetNextWindowSizeConstraints(new Vector2(375, 10), new Vector2(float.MaxValue, float.MaxValue));
var isVisible = this.AlertVisible[currency]; var isVisible = this.AlertVisible[currency.Id];
if (ImGui.Begin("Currency Alert", ref isVisible, var guiOptions = ImGuiWindowFlags.NoScrollbar |
ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse |
ImGuiWindowFlags.NoScrollWithMouse | ImGuiWindowFlags.AlwaysAutoResize |
ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoTitleBar |
ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoFocusOnAppearing;
ImGuiWindowFlags.NoFocusOnAppearing
)) if (configuration.UiLocked)
{ guiOptions |= ImGuiWindowFlags.NoMove;
var name = EnumHelper.GetAttributeOfType<NameAttribute>(currency).Value;
ImGui.Text($"You need to spend your {name}"); if (ImGui.Begin("Currency Alert", ref isVisible, guiOptions))
} {
ImGui.Text($"You need to spend your");
ImGui.End();
}); if (currency.Image != null)
} {
ImGui.SameLine();
public void DrawSettingsWindow() ImGui.Image(currency.Image.ImGuiHandle, new Vector2(22, 22));
{ }
ImGui.SetNextWindowSize(new Vector2(700, 500), ImGuiCond.FirstUseEver);
if (ImGui.Begin("Currency Alert Configuration Window", ref this.settingsVisible)) ImGui.SameLine();
{
if (ImGui.BeginTabBar("AlertsConfiguration_Tabs")) ImGui.Text($"{currency.Name}");
{
EnumHelper.Each<Currency>(currency => ImGui.End();
{ }
var name = EnumHelper.GetAttributeOfType<NameAttribute>(currency).Value; }
var category = EnumHelper.GetAttributeOfType<CategoryAttribute>(currency).Value; }
var alertEnabled = this.configuration.AlertEnabled[currency];
public void DrawSettingsWindow()
if (ImGui.BeginTabItem(category)) {
{ ImGui.SetNextWindowSize(new Vector2(700, 500), ImGuiCond.FirstUseEver);
if (ImGui.Checkbox($"{name} Alert Enabled", ref alertEnabled)) if (ImGui.Begin("Currency Alert Configuration Window", ref this.settingsVisible))
{ {
this.configuration.AlertEnabled[currency] = alertEnabled; var uiLocked = this.configuration.UiLocked;
this.configuration.Save();
} if (ImGui.Checkbox("Lock alert window", ref uiLocked))
{
var thresholdValue = this.configuration.Threshold[currency]; this.configuration.UiLocked = uiLocked;
this.configuration.Save();
if (ImGui.InputInt($"{name} Threshold Value", ref thresholdValue, 1, 1, }
this.configuration.AlertEnabled[currency] ? ImGuiInputTextFlags.None : ImGuiInputTextFlags.ReadOnly))
{ if (ImGui.BeginTabBar("AlertsConfiguration_Tabs"))
this.configuration.Threshold[currency] = thresholdValue; {
this.configuration.Save(); foreach (var currency in CurrencyProvider.Instance.GetAll())
} {
var name = currency.Name;
ImGui.EndTabItem(); var category = currency.Category;
} var alertEnabled = this.configuration.AlertEnabled[currency.Id];
});
} if (ImGui.BeginTabItem(category.ToString()))
} {
if (currency.Image != null)
ImGui.End(); {
} 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();
}
}
}
}

View File

@ -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<Currency> currencies;
public CurrencyProvider()
{
currencies = new List<Currency>
{
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<Currency> GetAll()
{
return currencies;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

BIN
CurrencyAlert/images/20.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

BIN
CurrencyAlert/images/21.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

BIN
CurrencyAlert/images/22.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

BIN
CurrencyAlert/images/25.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

BIN
CurrencyAlert/images/27.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

BIN
CurrencyAlert/images/28.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
CurrencyAlert/images/43.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
CurrencyAlert/images/44.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB