Updates for Dalamud API 7 (FFXIV 6.2 and later) (#10)
* Move SamplePlugin to CurrencyAlert to match plugin name
* Adjustments for API 7
- Bump DalamudPackager to 2.1.8
- Switch to .Net 6
- Remove builds to devPlugins. Dalamud will be phasing this out Soon™️
* Modifications needed for DalamudPlugins D17
This commit is contained in:
parent
a0cbd0f460
commit
4efc071cce
@ -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
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
@ -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; }
|
||||
}
|
||||
}
|
@ -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; }
|
||||
}
|
||||
}
|
@ -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; }
|
||||
}
|
||||
}
|
@ -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<Currency, bool> AlertEnabled { get; set; } = new Dictionary<Currency, bool>();
|
||||
public Dictionary<Currency, int> Threshold { get; set; } = new Dictionary<Currency , int>();
|
||||
|
||||
[NonSerialized]
|
||||
private DalamudPluginInterface? pluginInterface;
|
||||
|
||||
public Configuration()
|
||||
{
|
||||
EnumHelper.Each<Currency>(currency =>
|
||||
{
|
||||
this.AlertEnabled[currency] = true;
|
||||
var defaultValue = EnumHelper.GetAttributeOfType<DefaultThresholdAttribute>(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<Currency, bool> AlertEnabled { get; set; } = new Dictionary<Currency, bool>();
|
||||
public Dictionary<Currency, int> Threshold { get; set; } = new Dictionary<Currency , int>();
|
||||
|
||||
[NonSerialized]
|
||||
private DalamudPluginInterface? pluginInterface;
|
||||
|
||||
public Configuration()
|
||||
{
|
||||
EnumHelper.Each<Currency>(currency =>
|
||||
{
|
||||
this.AlertEnabled[currency] = true;
|
||||
var defaultValue = EnumHelper.GetAttributeOfType<DefaultThresholdAttribute>(currency);
|
||||
this.Threshold[currency] = defaultValue.Value;
|
||||
});
|
||||
}
|
||||
|
||||
public void Initialize(DalamudPluginInterface pluginInterface)
|
||||
{
|
||||
this.pluginInterface = pluginInterface;
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
this.pluginInterface!.SavePluginConfig(this);
|
||||
}
|
||||
}
|
||||
}
|
@ -3,21 +3,22 @@
|
||||
<PropertyGroup>
|
||||
<Authors></Authors>
|
||||
<Company></Company>
|
||||
<Version>0.3.2.0</Version>
|
||||
<Version>0.3.3.0</Version>
|
||||
<Description>Currency Alert</Description>
|
||||
<Copyright></Copyright>
|
||||
<PackageProjectUrl>https://github.com/Lharz/xiv-currency-alert</PackageProjectUrl>
|
||||
<PackageProjectUrl>https://github.com/Lharz/xiv-currency-alert</PackageProjectUrl>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0-windows</TargetFramework>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Platforms>x64</Platforms>
|
||||
<Nullable>enable</Nullable>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<OutputPath>$(AppData)\XIVLauncher\devPlugins\CurrencyAlert\</OutputPath>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
@ -27,7 +28,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DalamudPackager" Version="2.1.6" />
|
||||
<PackageReference Include="DalamudPackager" Version="2.1.8" />
|
||||
<Reference Include="FFXIVClientStructs">
|
||||
<HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath>
|
||||
<Private>false</Private>
|
@ -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
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
/// <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);
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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>(currency =>
|
||||
{
|
||||
var itemID = EnumHelper.GetAttributeOfType<ItemIDAttribute>(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>(currency =>
|
||||
{
|
||||
var itemID = EnumHelper.GetAttributeOfType<ItemIDAttribute>(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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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<Currency, bool> AlertVisible { get; set; } = new Dictionary<Currency, bool>();
|
||||
|
||||
public PluginUI(Configuration configuration)
|
||||
{
|
||||
this.configuration = configuration;
|
||||
|
||||
EnumHelper.Each<Currency>(currency => this.AlertVisible[currency] = false);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
DrawMainWindow();
|
||||
|
||||
if (this.SettingsVisible)
|
||||
DrawSettingsWindow();
|
||||
}
|
||||
|
||||
public void DrawMainWindow()
|
||||
{
|
||||
EnumHelper.Each<Currency>(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<NameAttribute>(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>(currency =>
|
||||
{
|
||||
var name = EnumHelper.GetAttributeOfType<NameAttribute>(currency).Value;
|
||||
var category = EnumHelper.GetAttributeOfType<CategoryAttribute>(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<Currency, bool> AlertVisible { get; set; } = new Dictionary<Currency, bool>();
|
||||
|
||||
public PluginUI(Configuration configuration)
|
||||
{
|
||||
this.configuration = configuration;
|
||||
|
||||
EnumHelper.Each<Currency>(currency => this.AlertVisible[currency] = false);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
DrawMainWindow();
|
||||
|
||||
if (this.SettingsVisible)
|
||||
DrawSettingsWindow();
|
||||
}
|
||||
|
||||
public void DrawMainWindow()
|
||||
{
|
||||
EnumHelper.Each<Currency>(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<NameAttribute>(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>(currency =>
|
||||
{
|
||||
var name = EnumHelper.GetAttributeOfType<NameAttribute>(currency).Value;
|
||||
var category = EnumHelper.GetAttributeOfType<CategoryAttribute>(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();
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
13
CurrencyAlert/packages.lock.json
Normal file
13
CurrencyAlert/packages.lock.json
Normal file
@ -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=="
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user