mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Add IDtrBar (#1276)
This commit is contained in:
parent
518fc348e1
commit
3fa8968027
2 changed files with 30 additions and 11 deletions
|
|
@ -6,6 +6,7 @@ using Dalamud.Configuration.Internal;
|
||||||
using Dalamud.Game.Text.SeStringHandling;
|
using Dalamud.Game.Text.SeStringHandling;
|
||||||
using Dalamud.IoC;
|
using Dalamud.IoC;
|
||||||
using Dalamud.IoC.Internal;
|
using Dalamud.IoC.Internal;
|
||||||
|
using Dalamud.Plugin.Services;
|
||||||
using FFXIVClientStructs.FFXIV.Client.System.Memory;
|
using FFXIVClientStructs.FFXIV.Client.System.Memory;
|
||||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
@ -18,7 +19,10 @@ namespace Dalamud.Game.Gui.Dtr;
|
||||||
[PluginInterface]
|
[PluginInterface]
|
||||||
[InterfaceVersion("1.0")]
|
[InterfaceVersion("1.0")]
|
||||||
[ServiceManager.BlockingEarlyLoadedService]
|
[ServiceManager.BlockingEarlyLoadedService]
|
||||||
public sealed unsafe class DtrBar : IDisposable, IServiceType
|
#pragma warning disable SA1015
|
||||||
|
[ResolveVia<IDtrBar>]
|
||||||
|
#pragma warning restore SA1015
|
||||||
|
public sealed unsafe class DtrBar : IDisposable, IServiceType, IDtrBar
|
||||||
{
|
{
|
||||||
private const uint BaseNodeId = 1000;
|
private const uint BaseNodeId = 1000;
|
||||||
|
|
||||||
|
|
@ -44,14 +48,7 @@ public sealed unsafe class DtrBar : IDisposable, IServiceType
|
||||||
this.configuration.QueueSave();
|
this.configuration.QueueSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc/>
|
||||||
/// Get a DTR bar entry.
|
|
||||||
/// This allows you to add your own text, and users to sort it.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="title">A user-friendly name for sorting.</param>
|
|
||||||
/// <param name="text">The text the entry shows.</param>
|
|
||||||
/// <returns>The entry object used to update, hide and remove the entry.</returns>
|
|
||||||
/// <exception cref="ArgumentException">Thrown when an entry with the specified title exists.</exception>
|
|
||||||
public DtrBarEntry Get(string title, SeString? text = null)
|
public DtrBarEntry Get(string title, SeString? text = null)
|
||||||
{
|
{
|
||||||
if (this.entries.Any(x => x.Title == title))
|
if (this.entries.Any(x => x.Title == title))
|
||||||
|
|
@ -134,7 +131,7 @@ public sealed unsafe class DtrBar : IDisposable, IServiceType
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private AtkUnitBase* GetDtr() => (AtkUnitBase*)this.gameGui.GetAddonByName("_DTR", 1).ToPointer();
|
private AtkUnitBase* GetDtr() => (AtkUnitBase*)this.gameGui.GetAddonByName("_DTR").ToPointer();
|
||||||
|
|
||||||
private void Update(Framework unused)
|
private void Update(Framework unused)
|
||||||
{
|
{
|
||||||
|
|
@ -293,7 +290,7 @@ public sealed unsafe class DtrBar : IDisposable, IServiceType
|
||||||
|
|
||||||
newTextNode->AtkResNode.NodeID = nodeId;
|
newTextNode->AtkResNode.NodeID = nodeId;
|
||||||
newTextNode->AtkResNode.Type = NodeType.Text;
|
newTextNode->AtkResNode.Type = NodeType.Text;
|
||||||
newTextNode->AtkResNode.Flags = (short)(NodeFlags.AnchorLeft | NodeFlags.AnchorTop);
|
newTextNode->AtkResNode.NodeFlags = NodeFlags.AnchorLeft | NodeFlags.AnchorTop;
|
||||||
newTextNode->AtkResNode.DrawFlags = 12;
|
newTextNode->AtkResNode.DrawFlags = 12;
|
||||||
newTextNode->AtkResNode.SetWidth(22);
|
newTextNode->AtkResNode.SetWidth(22);
|
||||||
newTextNode->AtkResNode.SetHeight(22);
|
newTextNode->AtkResNode.SetHeight(22);
|
||||||
|
|
|
||||||
22
Dalamud/Plugin/Services/IDtrBar.cs
Normal file
22
Dalamud/Plugin/Services/IDtrBar.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
using Dalamud.Game.Gui.Dtr;
|
||||||
|
using Dalamud.Game.Text.SeStringHandling;
|
||||||
|
|
||||||
|
namespace Dalamud.Plugin.Services;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Class used to interface with the server info bar.
|
||||||
|
/// </summary>
|
||||||
|
public interface IDtrBar
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Get a DTR bar entry.
|
||||||
|
/// This allows you to add your own text, and users to sort it.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="title">A user-friendly name for sorting.</param>
|
||||||
|
/// <param name="text">The text the entry shows.</param>
|
||||||
|
/// <returns>The entry object used to update, hide and remove the entry.</returns>
|
||||||
|
/// <exception cref="ArgumentException">Thrown when an entry with the specified title exists.</exception>
|
||||||
|
public DtrBarEntry Get(string title, SeString? text = null);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue