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
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.0.31919.166
|
VisualStudioVersion = 17.0.31919.166
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
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
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace CurrencyAlert.Enum
|
namespace CurrencyAlert.Enum
|
||||||
{
|
{
|
||||||
internal class CategoryAttribute : Attribute
|
internal class CategoryAttribute : Attribute
|
||||||
{
|
{
|
||||||
public CategoryAttribute(string v)
|
public CategoryAttribute(string v)
|
||||||
{
|
{
|
||||||
Value = v;
|
Value = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Value { get; }
|
public string Value { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,14 +1,14 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace CurrencyAlert
|
namespace CurrencyAlert
|
||||||
{
|
{
|
||||||
internal class DefaultThresholdAttribute : Attribute
|
internal class DefaultThresholdAttribute : Attribute
|
||||||
{
|
{
|
||||||
public DefaultThresholdAttribute(int v)
|
public DefaultThresholdAttribute(int v)
|
||||||
{
|
{
|
||||||
Value = v;
|
Value = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Value { get; }
|
public int Value { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,14 +1,14 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace CurrencyAlert
|
namespace CurrencyAlert
|
||||||
{
|
{
|
||||||
internal class ItemIDAttribute : Attribute
|
internal class ItemIDAttribute : Attribute
|
||||||
{
|
{
|
||||||
public ItemIDAttribute(int v)
|
public ItemIDAttribute(int v)
|
||||||
{
|
{
|
||||||
Value = v;
|
Value = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Value { get; }
|
public int Value { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,14 +1,14 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace CurrencyAlert.Enum
|
namespace CurrencyAlert.Enum
|
||||||
{
|
{
|
||||||
internal class NameAttribute : Attribute
|
internal class NameAttribute : Attribute
|
||||||
{
|
{
|
||||||
public NameAttribute(string v)
|
public NameAttribute(string v)
|
||||||
{
|
{
|
||||||
Value = v;
|
Value = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Value { get; }
|
public string Value { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,40 +1,40 @@
|
|||||||
using CurrencyAlert.Enum;
|
using CurrencyAlert.Enum;
|
||||||
using Dalamud.Configuration;
|
using Dalamud.Configuration;
|
||||||
using Dalamud.Plugin;
|
using Dalamud.Plugin;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace CurrencyAlert
|
namespace CurrencyAlert
|
||||||
{
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class Configuration : IPluginConfiguration
|
public class Configuration : IPluginConfiguration
|
||||||
{
|
{
|
||||||
public int Version { get; set; } = 4;
|
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>();
|
||||||
|
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
private DalamudPluginInterface? pluginInterface;
|
private DalamudPluginInterface? pluginInterface;
|
||||||
|
|
||||||
public Configuration()
|
public Configuration()
|
||||||
{
|
{
|
||||||
EnumHelper.Each<Currency>(currency =>
|
EnumHelper.Each<Currency>(currency =>
|
||||||
{
|
{
|
||||||
this.AlertEnabled[currency] = true;
|
this.AlertEnabled[currency] = true;
|
||||||
var defaultValue = EnumHelper.GetAttributeOfType<DefaultThresholdAttribute>(currency);
|
var defaultValue = EnumHelper.GetAttributeOfType<DefaultThresholdAttribute>(currency);
|
||||||
this.Threshold[currency] = defaultValue.Value;
|
this.Threshold[currency] = defaultValue.Value;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize(DalamudPluginInterface pluginInterface)
|
public void Initialize(DalamudPluginInterface pluginInterface)
|
||||||
{
|
{
|
||||||
this.pluginInterface = pluginInterface;
|
this.pluginInterface = pluginInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Save()
|
public void Save()
|
||||||
{
|
{
|
||||||
this.pluginInterface!.SavePluginConfig(this);
|
this.pluginInterface!.SavePluginConfig(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,21 +3,22 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Authors></Authors>
|
<Authors></Authors>
|
||||||
<Company></Company>
|
<Company></Company>
|
||||||
<Version>0.3.2.0</Version>
|
<Version>0.3.3.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>net5.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>
|
||||||
<OutputPath>$(AppData)\XIVLauncher\devPlugins\CurrencyAlert\</OutputPath>
|
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||||
|
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
@ -27,7 +28,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="DalamudPackager" Version="2.1.6" />
|
<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>
|
@ -1,50 +1,50 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace CurrencyAlert.Enum
|
namespace CurrencyAlert.Enum
|
||||||
{
|
{
|
||||||
public enum Currency
|
public enum Currency
|
||||||
{
|
{
|
||||||
[Name("Tomestones of Poetics"), ItemID(28), DefaultThreshold(1400), Category("Battle")]
|
[Name("Tomestones of Poetics"), ItemID(28), DefaultThreshold(1400), Category("Battle")]
|
||||||
TomestoneOfPoetics,
|
TomestoneOfPoetics,
|
||||||
[Name("Tomestones of Aphorism"), ItemID(42), DefaultThreshold(1700), Category("Battle")]
|
[Name("Tomestones of Aphorism"), ItemID(42), DefaultThreshold(1700), Category("Battle")]
|
||||||
TomestoneOfAphorism,
|
TomestoneOfAphorism,
|
||||||
[Name("Tomestones of Astronomy"), ItemID(43), DefaultThreshold(1700), Category("Battle")]
|
[Name("Tomestones of Astronomy"), ItemID(43), DefaultThreshold(1700), Category("Battle")]
|
||||||
TomestoneOfAstronomy,
|
TomestoneOfAstronomy,
|
||||||
|
|
||||||
[Name("Storm Seals"), ItemID(20), DefaultThreshold(75000), Category("Common")]
|
[Name("Storm Seals"), ItemID(20), DefaultThreshold(75000), Category("Common")]
|
||||||
StormSeal,
|
StormSeal,
|
||||||
[Name("Serpent Seals"), ItemID(21), DefaultThreshold(75000), Category("Common")]
|
[Name("Serpent Seals"), ItemID(21), DefaultThreshold(75000), Category("Common")]
|
||||||
SerpentSeal,
|
SerpentSeal,
|
||||||
[Name("Flame Seals"), ItemID(22), DefaultThreshold(75000), Category("Common")]
|
[Name("Flame Seals"), ItemID(22), DefaultThreshold(75000), Category("Common")]
|
||||||
FlameSeal,
|
FlameSeal,
|
||||||
|
|
||||||
[Name("Wolf Marks"), ItemID(25), DefaultThreshold(18000), Category("Battle")]
|
[Name("Wolf Marks"), ItemID(25), DefaultThreshold(18000), Category("Battle")]
|
||||||
WolfMark,
|
WolfMark,
|
||||||
[Name("Trophy Crystals"), ItemID(36656), DefaultThreshold(18000), Category("Battle")]
|
[Name("Trophy Crystals"), ItemID(36656), DefaultThreshold(18000), Category("Battle")]
|
||||||
TrophyCrystal,
|
TrophyCrystal,
|
||||||
|
|
||||||
[Name("Allied Seals"), ItemID(27), DefaultThreshold(3500), Category("Battle")]
|
[Name("Allied Seals"), ItemID(27), DefaultThreshold(3500), Category("Battle")]
|
||||||
AlliedSeal,
|
AlliedSeal,
|
||||||
[Name("Centurio Seals"), ItemID(10307), DefaultThreshold(3500), Category("Battle")]
|
[Name("Centurio Seals"), ItemID(10307), DefaultThreshold(3500), Category("Battle")]
|
||||||
CenturioSeal,
|
CenturioSeal,
|
||||||
[Name("Sack of Nuts"), ItemID(26533), DefaultThreshold(3500), Category("Battle")]
|
[Name("Sack of Nuts"), ItemID(26533), DefaultThreshold(3500), Category("Battle")]
|
||||||
SackOfNut,
|
SackOfNut,
|
||||||
[Name("Bicolor Gemstone"), ItemID(26807), DefaultThreshold(800), Category("Battle")]
|
[Name("Bicolor Gemstone"), ItemID(26807), DefaultThreshold(800), Category("Battle")]
|
||||||
BicolorGemstone,
|
BicolorGemstone,
|
||||||
|
|
||||||
[Name("White Crafters' Scrip"), ItemID(25199), DefaultThreshold(1500), Category("Other")]
|
[Name("White Crafters' Scrip"), ItemID(25199), DefaultThreshold(1500), Category("Other")]
|
||||||
WhiteCraftersScrip,
|
WhiteCraftersScrip,
|
||||||
[Name("Purple Crafters' Scrip"), ItemID(33913), DefaultThreshold(1500), Category("Other")]
|
[Name("Purple Crafters' Scrip"), ItemID(33913), DefaultThreshold(1500), Category("Other")]
|
||||||
PurpleCraftersScrip,
|
PurpleCraftersScrip,
|
||||||
[Name("White Gatherers' Scrip"), ItemID(25200), DefaultThreshold(1500), Category("Other")]
|
[Name("White Gatherers' Scrip"), ItemID(25200), DefaultThreshold(1500), Category("Other")]
|
||||||
WhiteGatherersScrip,
|
WhiteGatherersScrip,
|
||||||
[Name("Purple Gatherers' Scrip"), ItemID(33914), DefaultThreshold(1500), Category("Other")]
|
[Name("Purple Gatherers' Scrip"), ItemID(33914), DefaultThreshold(1500), Category("Other")]
|
||||||
PurpleGatherersScrip,
|
PurpleGatherersScrip,
|
||||||
[Name("Skybuilders' Scrip"), ItemID(28063), DefaultThreshold(7500), Category("Other")]
|
[Name("Skybuilders' Scrip"), ItemID(28063), DefaultThreshold(7500), Category("Other")]
|
||||||
SkybuildersScrip
|
SkybuildersScrip
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,32 +1,32 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace CurrencyAlert
|
namespace CurrencyAlert
|
||||||
{
|
{
|
||||||
public static class EnumHelper
|
public static class EnumHelper
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets an attribute on an enum field value
|
/// Gets an attribute on an enum field value
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T">The type of the attribute you want to retrieve</typeparam>
|
/// <typeparam name="T">The type of the attribute you want to retrieve</typeparam>
|
||||||
/// <param name="enumVal">The enum value</param>
|
/// <param name="enumVal">The enum value</param>
|
||||||
/// <returns>The attribute of type T that exists on the enum value</returns>
|
/// <returns>The attribute of type T that exists on the enum value</returns>
|
||||||
/// <example><![CDATA[string desc = myEnumVariable.GetAttributeOfType<DescriptionAttribute>().Description;]]></example>
|
/// <example><![CDATA[string desc = myEnumVariable.GetAttributeOfType<DescriptionAttribute>().Description;]]></example>
|
||||||
public static T GetAttributeOfType<T>(this System.Enum enumVal) where T : System.Attribute
|
public static T GetAttributeOfType<T>(this System.Enum enumVal) where T : System.Attribute
|
||||||
{
|
{
|
||||||
var type = enumVal.GetType();
|
var type = enumVal.GetType();
|
||||||
var memInfo = type.GetMember(enumVal.ToString());
|
var memInfo = type.GetMember(enumVal.ToString());
|
||||||
var attributes = memInfo[0].GetCustomAttributes(typeof(T), false);
|
var attributes = memInfo[0].GetCustomAttributes(typeof(T), false);
|
||||||
return (attributes.Length > 0) ? (T)attributes[0] : null;
|
return (attributes.Length > 0) ? (T)attributes[0] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Each<T>(Action<T> action)
|
public static void Each<T>(Action<T> action)
|
||||||
{
|
{
|
||||||
foreach (var item in System.Enum.GetValues(typeof(T)))
|
foreach (var item in System.Enum.GetValues(typeof(T)))
|
||||||
action((T)item);
|
action((T)item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,89 +1,89 @@
|
|||||||
using CurrencyAlert.Enum;
|
using CurrencyAlert.Enum;
|
||||||
using Dalamud.Game.Command;
|
using Dalamud.Game.Command;
|
||||||
using Dalamud.Game.Gui;
|
using Dalamud.Game.Gui;
|
||||||
using Dalamud.IoC;
|
using Dalamud.IoC;
|
||||||
using Dalamud.Plugin;
|
using Dalamud.Plugin;
|
||||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace CurrencyAlert
|
namespace CurrencyAlert
|
||||||
{
|
{
|
||||||
public sealed class Plugin : IDalamudPlugin
|
public sealed class Plugin : IDalamudPlugin
|
||||||
{
|
{
|
||||||
public string Name => "Currency Alert";
|
public string Name => "Currency Alert";
|
||||||
|
|
||||||
private const string commandName = "/currencyalert";
|
private const string commandName = "/currencyalert";
|
||||||
|
|
||||||
private DalamudPluginInterface PluginInterface { get; init; }
|
private DalamudPluginInterface PluginInterface { get; init; }
|
||||||
private CommandManager CommandManager { get; init; }
|
private CommandManager CommandManager { get; init; }
|
||||||
private Configuration Configuration { get; init; }
|
private Configuration Configuration { get; init; }
|
||||||
private PluginUI PluginUI { 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(
|
public Plugin(
|
||||||
[RequiredVersion("1.0")] DalamudPluginInterface pluginInterface,
|
[RequiredVersion("1.0")] DalamudPluginInterface pluginInterface,
|
||||||
[RequiredVersion("1.0")] CommandManager commandManager)
|
[RequiredVersion("1.0")] CommandManager commandManager)
|
||||||
{
|
{
|
||||||
this.PluginInterface = pluginInterface;
|
this.PluginInterface = pluginInterface;
|
||||||
this.CommandManager = commandManager;
|
this.CommandManager = commandManager;
|
||||||
|
|
||||||
this.Configuration = this.PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
|
this.Configuration = this.PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
|
||||||
this.Configuration.Initialize(this.PluginInterface);
|
this.Configuration.Initialize(this.PluginInterface);
|
||||||
|
|
||||||
var assemblyLocation = Assembly.GetExecutingAssembly().Location;
|
var assemblyLocation = Assembly.GetExecutingAssembly().Location;
|
||||||
this.PluginUI = new PluginUI(this.Configuration);
|
this.PluginUI = new PluginUI(this.Configuration);
|
||||||
|
|
||||||
this.CommandManager.AddHandler(commandName, new CommandInfo(OnCommand)
|
this.CommandManager.AddHandler(commandName, new CommandInfo(OnCommand)
|
||||||
{
|
{
|
||||||
HelpMessage = "Lets you configure alert thresholds for various currencies"
|
HelpMessage = "Lets you configure alert thresholds for various currencies"
|
||||||
});
|
});
|
||||||
|
|
||||||
this.PluginInterface.UiBuilder.Draw += DrawUI;
|
this.PluginInterface.UiBuilder.Draw += DrawUI;
|
||||||
this.PluginInterface.UiBuilder.OpenConfigUi += DrawConfigUI;
|
this.PluginInterface.UiBuilder.OpenConfigUi += DrawConfigUI;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
this.PluginUI.Dispose();
|
this.PluginUI.Dispose();
|
||||||
this.CommandManager.RemoveHandler(commandName);
|
this.CommandManager.RemoveHandler(commandName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnCommand(string command, string args)
|
private void OnCommand(string command, string args)
|
||||||
{
|
{
|
||||||
this.DrawConfigUI();
|
this.DrawConfigUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawUI()
|
private void DrawUI()
|
||||||
{
|
{
|
||||||
// TODO: move this logic elsewhere
|
// TODO: move this logic elsewhere
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
InventoryManager* inventoryManager = InventoryManager.Instance();
|
InventoryManager* inventoryManager = InventoryManager.Instance();
|
||||||
|
|
||||||
EnumHelper.Each<Currency>(currency =>
|
EnumHelper.Each<Currency>(currency =>
|
||||||
{
|
{
|
||||||
var itemID = EnumHelper.GetAttributeOfType<ItemIDAttribute>(currency).Value;
|
var itemID = EnumHelper.GetAttributeOfType<ItemIDAttribute>(currency).Value;
|
||||||
int quantity = inventoryManager->GetInventoryItemCount((uint)itemID);
|
int quantity = inventoryManager->GetInventoryItemCount((uint)itemID);
|
||||||
|
|
||||||
if (this.Configuration.AlertEnabled[currency] && quantity >= this.Configuration.Threshold[currency])
|
if (this.Configuration.AlertEnabled[currency] && quantity >= this.Configuration.Threshold[currency])
|
||||||
{
|
{
|
||||||
this.PluginUI.AlertVisible[currency] = true;
|
this.PluginUI.AlertVisible[currency] = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.PluginUI.AlertVisible[currency] = false;
|
this.PluginUI.AlertVisible[currency] = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.PluginUI.Draw();
|
this.PluginUI.Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawConfigUI()
|
private void DrawConfigUI()
|
||||||
{
|
{
|
||||||
this.PluginUI.SettingsVisible = true;
|
this.PluginUI.SettingsVisible = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,111 +1,111 @@
|
|||||||
using CurrencyAlert.Enum;
|
using CurrencyAlert.Enum;
|
||||||
using Dalamud.Game.Gui;
|
using Dalamud.Game.Gui;
|
||||||
using Dalamud.IoC;
|
using Dalamud.IoC;
|
||||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
|
|
||||||
namespace CurrencyAlert
|
namespace CurrencyAlert
|
||||||
{
|
{
|
||||||
class PluginUI : IDisposable
|
class PluginUI : IDisposable
|
||||||
{
|
{
|
||||||
private Configuration configuration;
|
private Configuration configuration;
|
||||||
|
|
||||||
private bool settingsVisible = false;
|
private bool settingsVisible = false;
|
||||||
public bool SettingsVisible
|
public bool SettingsVisible
|
||||||
{
|
{
|
||||||
get { return settingsVisible; }
|
get { return settingsVisible; }
|
||||||
set { settingsVisible = value; }
|
set { settingsVisible = value; }
|
||||||
}
|
}
|
||||||
public Dictionary<Currency, bool> AlertVisible { get; set; } = new Dictionary<Currency, bool>();
|
public Dictionary<Currency, bool> AlertVisible { get; set; } = new Dictionary<Currency, bool>();
|
||||||
|
|
||||||
public PluginUI(Configuration configuration)
|
public PluginUI(Configuration configuration)
|
||||||
{
|
{
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
|
|
||||||
EnumHelper.Each<Currency>(currency => this.AlertVisible[currency] = 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 =>
|
EnumHelper.Each<Currency>(currency =>
|
||||||
{
|
{
|
||||||
if (!this.AlertVisible[currency])
|
if (!this.AlertVisible[currency])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
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];
|
||||||
|
|
||||||
if (ImGui.Begin("Currency Alert", ref isVisible,
|
if (ImGui.Begin("Currency Alert", ref isVisible,
|
||||||
ImGuiWindowFlags.NoScrollbar |
|
ImGuiWindowFlags.NoScrollbar |
|
||||||
ImGuiWindowFlags.NoScrollWithMouse |
|
ImGuiWindowFlags.NoScrollWithMouse |
|
||||||
ImGuiWindowFlags.AlwaysAutoResize |
|
ImGuiWindowFlags.AlwaysAutoResize |
|
||||||
ImGuiWindowFlags.NoTitleBar |
|
ImGuiWindowFlags.NoTitleBar |
|
||||||
ImGuiWindowFlags.NoFocusOnAppearing
|
ImGuiWindowFlags.NoFocusOnAppearing
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
var name = EnumHelper.GetAttributeOfType<NameAttribute>(currency).Value;
|
var name = EnumHelper.GetAttributeOfType<NameAttribute>(currency).Value;
|
||||||
ImGui.Text($"You need to spend your {name}");
|
ImGui.Text($"You need to spend your {name}");
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.End();
|
ImGui.End();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawSettingsWindow()
|
public void DrawSettingsWindow()
|
||||||
{
|
{
|
||||||
ImGui.SetNextWindowSize(new Vector2(700, 500), ImGuiCond.FirstUseEver);
|
ImGui.SetNextWindowSize(new Vector2(700, 500), ImGuiCond.FirstUseEver);
|
||||||
if (ImGui.Begin("Currency Alert Configuration Window", ref this.settingsVisible))
|
if (ImGui.Begin("Currency Alert Configuration Window", ref this.settingsVisible))
|
||||||
{
|
{
|
||||||
if (ImGui.BeginTabBar("AlertsConfiguration_Tabs"))
|
if (ImGui.BeginTabBar("AlertsConfiguration_Tabs"))
|
||||||
{
|
{
|
||||||
EnumHelper.Each<Currency>(currency =>
|
EnumHelper.Each<Currency>(currency =>
|
||||||
{
|
{
|
||||||
var name = EnumHelper.GetAttributeOfType<NameAttribute>(currency).Value;
|
var name = EnumHelper.GetAttributeOfType<NameAttribute>(currency).Value;
|
||||||
var category = EnumHelper.GetAttributeOfType<CategoryAttribute>(currency).Value;
|
var category = EnumHelper.GetAttributeOfType<CategoryAttribute>(currency).Value;
|
||||||
var alertEnabled = this.configuration.AlertEnabled[currency];
|
var alertEnabled = this.configuration.AlertEnabled[currency];
|
||||||
|
|
||||||
if (ImGui.BeginTabItem(category))
|
if (ImGui.BeginTabItem(category))
|
||||||
{
|
{
|
||||||
if (ImGui.Checkbox($"{name} 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
var thresholdValue = this.configuration.Threshold[currency];
|
var thresholdValue = this.configuration.Threshold[currency];
|
||||||
|
|
||||||
if (ImGui.InputInt($"{name} 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;
|
||||||
this.configuration.Save();
|
this.configuration.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.EndTabItem();
|
ImGui.EndTabItem();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.End();
|
ImGui.End();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,9 +12,5 @@
|
|||||||
"other"
|
"other"
|
||||||
],
|
],
|
||||||
"CategoryTags": null,
|
"CategoryTags": null,
|
||||||
"AssemblyVersion": "0.3.2.0",
|
|
||||||
"RepoUrl": "https://github.com/Lharz/xiv-currency-alert",
|
"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