From ab3bf20ffa8fb4ab843c1524cf0a59468bd51749 Mon Sep 17 00:00:00 2001 From: Pilzinsel64 Date: Wed, 17 Jul 2024 15:02:08 +0200 Subject: [PATCH] update readme --- README.md | 73 +++++-------------------------------------------------- 1 file changed, 6 insertions(+), 67 deletions(-) diff --git a/README.md b/README.md index ffa7b79..5047f22 100644 --- a/README.md +++ b/README.md @@ -27,77 +27,16 @@ public Plugin(DalamudPluginInterface pluginInterface) ### Hook into Nameplates -To edit the nameplate, you first need to hook and listen to the Game's updates. Also don't forget to unhook and dispose on unloading the plugins! +Nameplates has been reworked by @nebel and will be part of core Dalamud soon. + +Read more at: https://github.com/goatcorp/Dalamud/pull/1915 + +Use the new service already now via Pilz.Dalamud: ```cs -public class NameplateFeature : IDisposable -{ - public NameplateManager NameplateManager { get; init; } - - /// - /// Occurs when a player nameplate is updated by the game. - /// - public event PlayerNameplateUpdatedDelegate? PlayerNameplateUpdated; - - public NameplateFeature() - { - NameplateManager = new(); - NameplateManager.Hooks.AddonNamePlate_SetPlayerNameManaged += Hooks_AddonNamePlate_SetPlayerNameManaged; - } - - public void Dispose() - { - NameplateManager.Hooks.AddonNamePlate_SetPlayerNameManaged -= Hooks_AddonNamePlate_SetPlayerNameManaged; - NameplateManager.Dispose(); - } - - private void Hooks_AddonNamePlate_SetPlayerNameManaged(Pilz.Dalamud.Nameplates.EventArgs.AddonNamePlate_SetPlayerNameManagedEventArgs eventArgs) - { - } -} +var namePlateGui = Pilz.Dalamud.NamePlate.INamePlateGui.Instance; ``` -This is an example of editing the title to "Good Player", make the name italic and also force the title to always be above the name: - -```cs -private void Hooks_AddonNamePlate_SetPlayerNameManaged(Pilz.Dalamud.Nameplates.EventArgs.AddonNamePlate_SetPlayerNameManagedEventArgs eventArgs) -{ - try - { - // Get the referenced player object for the nameplate object - PlayerCharacter? playerCharacter = NameplateManager.GetNameplateGameObject(eventArgs.SafeNameplateObject); - - if (playerCharacter != null && playerCharacter.StatusFlags.HasFlag(StatusFlags.Friend)) - { - const string TEXT_GOOD_PLAYER = "Good Player"; - - // Create a new change - var nameplateChanges = new NameplateChanges(eventArgs); - - // Replace the title - var titleChange = nameplateChanges.GetChange(NameplateElements.Title, StringPosition.Replace); - titleChange.Payloads.Add(new TextPayload(TEXT_GOOD_PLAYER)); - - // Make the name italic - var nameChangeBefore = nameplateChanges.GetChange(NameplateElements.Name, StringPosition.Before); - nameChangeBefore.Payloads.Add(new EmphasisItalicPayload(true)); - - var nameChangeAfter = nameplateChanges.GetChange(NameplateElements.Name, StringPosition.After); - nameChangeAfter.Payloads.Add(new EmphasisItalicPayload(false)); - - // Forge the title to be always above the name (this we can edit directly) - eventArgs.IsTitleAboveName = true; - - // Apply the string changes! - NameplateUpdateFactory.ApplyNameplateChanges(new NameplateChangesProps(nameplateChanges)); - } - } - catch (Exception ex) - { - PluginLog.Error(ex, $"SetPlayerNameplateDetour"); - } -} -``` ## Contribute