name attribute

main
Camille 2022-01-06 10:56:52 +01:00
parent 577ced24a4
commit 74e44d7092
5 changed files with 101 additions and 91 deletions

View File

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

View File

@ -9,7 +9,7 @@ namespace CurrencyAlert
[Serializable] [Serializable]
public class Configuration : IPluginConfiguration public class Configuration : IPluginConfiguration
{ {
public int Version { get; set; } = 2; public int Version { get; set; } = 4;
public Dictionary<Currency, bool> AlertEnabled { get; set; } = new Dictionary<Currency, bool>(); public Dictionary<Currency, bool> AlertEnabled { get; set; } = new Dictionary<Currency, bool>();
public Dictionary<Currency, int> Threshold { get; set; } = new Dictionary<Currency , int>(); public Dictionary<Currency, int> Threshold { get; set; } = new Dictionary<Currency , int>();

View File

@ -8,25 +8,19 @@ namespace CurrencyAlert.Enum
{ {
public enum Currency public enum Currency
{ {
[Slot(1), DefaultThreshold(75000)] [Name("Tomestones of Poetics"), Slot(6), DefaultThreshold(1500)]
StormSeal,
[Slot(2), DefaultThreshold(75000)]
SerpentSeal,
[Slot(3), DefaultThreshold(75000)]
FlameSeal,
[Slot(4), DefaultThreshold(18000)]
WolfMark,
[Slot(6), DefaultThreshold(1500)]
TomestoneOfPoetics, TomestoneOfPoetics,
[Name("Tomestones of Astronomy"), Slot(10), DefaultThreshold(1500)]
[Slot(8), DefaultThreshold(3500)] TomestoneOfAstronomy,
AlliedSeal, [Name("Storm Seals"), Slot(1), DefaultThreshold(75000)]
StormSeal,
[Slot(10), DefaultThreshold(1500)] [Name("Serpent Seals"), Slot(2), DefaultThreshold(75000)]
TomestoneOfAstronomy 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
} }
} }

View File

@ -70,7 +70,8 @@ namespace CurrencyAlert
ImGuiWindowFlags.NoFocusOnAppearing ImGuiWindowFlags.NoFocusOnAppearing
)) ))
{ {
ImGui.Text($"You need to spend your {currency}"); var name = EnumHelper.GetAttributeOfType<NameAttribute>(currency).Value;
ImGui.Text($"You need to spend your {name}");
} }
ImGui.End(); ImGui.End();
@ -85,9 +86,10 @@ namespace CurrencyAlert
{ {
EnumHelper.Each<Currency>(currency => EnumHelper.Each<Currency>(currency =>
{ {
var name = EnumHelper.GetAttributeOfType<NameAttribute>(currency).Value;
var alertEnabled = this.configuration.AlertEnabled[currency]; 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.AlertEnabled[currency] = alertEnabled;
this.configuration.Save(); this.configuration.Save();
@ -95,7 +97,7 @@ namespace CurrencyAlert
var thresholdValue = this.configuration.Threshold[currency]; 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.AlertEnabled[currency] ? ImGuiInputTextFlags.None : ImGuiInputTextFlags.ReadOnly))
{ {
this.configuration.Threshold[currency] = thresholdValue; this.configuration.Threshold[currency] = thresholdValue;