update readme
This commit is contained in:
73
README.md
73
README.md
@@ -27,77 +27,16 @@ public Plugin(DalamudPluginInterface pluginInterface)
|
|||||||
|
|
||||||
### Hook into Nameplates
|
### 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
|
```cs
|
||||||
public class NameplateFeature : IDisposable
|
var namePlateGui = Pilz.Dalamud.NamePlate.INamePlateGui.Instance;
|
||||||
{
|
|
||||||
public NameplateManager NameplateManager { get; init; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Occurs when a player nameplate is updated by the game.
|
|
||||||
/// </summary>
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
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<PlayerCharacter>(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
|
## Contribute
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user