Initial release: HSUI v1.0.0.0 - HUD replacement with configurable hotbars
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Dalamud.Game.ClientState.Objects.Enums;
|
||||
using Dalamud.Game.ClientState.Objects.Types;
|
||||
|
||||
namespace HSUI.Helpers
|
||||
{
|
||||
internal class PetRenamerHelper
|
||||
{
|
||||
private Dictionary<ulong, string>? PetNicknamesDictionary;
|
||||
|
||||
#region Singleton
|
||||
public static void Initialize() { Instance = new PetRenamerHelper(); }
|
||||
|
||||
public static PetRenamerHelper Instance { get; private set; } = null!;
|
||||
|
||||
public PetRenamerHelper()
|
||||
{
|
||||
AssignShares();
|
||||
}
|
||||
|
||||
~PetRenamerHelper()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposing)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Plugin.PluginInterface.RelinquishData("PetRenamer.GameObjectRenameDict");
|
||||
|
||||
Instance = null!;
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void AssignShares()
|
||||
{
|
||||
try
|
||||
{
|
||||
PetNicknamesDictionary = Plugin.PluginInterface.GetOrCreateData("PetRenamer.GameObjectRenameDict", () => new Dictionary<ulong, string>());
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
private string? GetNameForActor(IGameObject actor)
|
||||
{
|
||||
if (PetNicknamesDictionary == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (PetNicknamesDictionary.TryGetValue(actor.GameObjectId, out string? nickname))
|
||||
{
|
||||
return nickname;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public string? GetPetName(IGameObject? actor)
|
||||
{
|
||||
if (actor == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (actor.ObjectKind != ObjectKind.Companion && actor.ObjectKind != ObjectKind.BattleNpc)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return GetNameForActor(actor);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user