Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions NamePlateDebuffs/AddonNamePlateHooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using FFXIVClientStructs.FFXIV.Client.Game.Character;
using FFXIVClientStructs.FFXIV.Client.System.Framework;
using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Component.GUI;
using System;
using System.Diagnostics;

Expand Down Expand Up @@ -34,8 +33,8 @@ public AddonNamePlateHooks(NamePlateDebuffsPlugin p)

public void Initialize()
{
_hookAddonNamePlateFinalize = new Hook<AddonNamePlateFinalizePrototype>(_plugin.Address.AddonNamePlateFinalizeAddress, AddonNamePlateFinalizeDetour);
_hookAddonNamePlateDraw = new Hook<AddonNamePlateDrawPrototype>(_plugin.Address.AddonNamePlateDrawAddress, AddonNamePlateDrawDetour);
_hookAddonNamePlateFinalize = NamePlateDebuffsPlugin.Hook.HookFromAddress<AddonNamePlateFinalizePrototype>(_plugin.Address.AddonNamePlateFinalizeAddress, AddonNamePlateFinalizeDetour);
_hookAddonNamePlateDraw = NamePlateDebuffsPlugin.Hook.HookFromAddress<AddonNamePlateDrawPrototype>(_plugin.Address.AddonNamePlateDrawAddress, AddonNamePlateDrawDetour);

_hookAddonNamePlateFinalize.Enable();
_hookAddonNamePlateDraw.Enable();
Expand Down Expand Up @@ -80,7 +79,7 @@ public void AddonNamePlateDrawDetour(AddonNamePlate* thisPtr)
return;
}

var framework = FFXIVClientStructs.FFXIV.Client.System.Framework.Framework.Instance();
var framework = Framework.Instance();
var ui3DModule = framework->GetUiModule()->GetUI3DModule();

for (int i = 0; i < ui3DModule->NamePlateObjectInfoCount; i++)
Expand Down Expand Up @@ -114,7 +113,7 @@ public void AddonNamePlateDrawDetour(AddonNamePlate* thisPtr)
_plugin.StatusNodeManager.HideUnusedStatus(npIndex, 0);
continue;
}
StatusManager targetStatus = ((BattleChara*)objectInfo->GameObject)->StatusManager;
StatusManager targetStatus = ((BattleChara*)objectInfo->GameObject)->GetStatusManager[0];

var statusArray = (Status*)targetStatus.Status;

Expand Down
5 changes: 2 additions & 3 deletions NamePlateDebuffs/NamePlateDebuffs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>NamePlateDebuffs</PackageId>
<Version>1.0.1.1</Version>
<Version>1.0.1.2</Version>
<Authors>aers, JHerig, squidmade</Authors>
<PackageProjectUrl>https://github.com/jherig/NamePlateDebuffs</PackageProjectUrl>
</PropertyGroup>
Expand All @@ -25,9 +25,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.10" />
<PackageReference Include="DalamudPackager" Version="2.1.12" />
</ItemGroup>

<ItemGroup>
<Reference Include="Dalamud">
<HintPath>$(DalamudLibPath)Dalamud.dll</HintPath>
Expand Down
68 changes: 29 additions & 39 deletions NamePlateDebuffs/NamePlateDebuffsPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
using Dalamud.Game.Command;
using Dalamud.IoC;
using Dalamud.Plugin;
using Lumina.Excel.GeneratedSheets;
using Dalamud.Plugin.Services;
using NamePlateDebuffs.StatusNode;
using System.Collections.Generic;
using Dalamud.Data;
using Dalamud.Game;
using Dalamud.Game.ClientState;
using Dalamud.IoC;
using Dalamud.Logging;


namespace NamePlateDebuffs
{
Expand All @@ -21,14 +18,17 @@ public class NamePlateDebuffsPlugin : IDalamudPlugin

[PluginService]
[RequiredVersion("1.0")]
public ClientState ClientState { get; private set; } = null!;
public IClientState ClientState { get; private set; } = null!;

[PluginService]
[RequiredVersion("1.0")]
public static CommandManager CommandManager { get; private set; } = null!;
public static ICommandManager CommandManager { get; private set; } = null!;

public DataManager DataManager { get; private set; } = null!;
public Framework Framework { get; private set; } = null!;
[PluginService] public static IDataManager DataManager { get; private set; } = null!;
[PluginService] public static IFramework Framework { get; private set; } = null!;
[PluginService] public static IPluginLog Log { get; private set; } = null!;
[PluginService] public static ISigScanner SigScanner { get; private set; } = null!;
[PluginService] public static IGameInteropProvider Hook { get; private set; } = null!;
public PluginAddressResolver Address { get; private set; } = null!;
public StatusNodeManager StatusNodeManager { get; private set; } = null!;
public static AddonNamePlateHooks Hooks { get; private set; } = null!;
Expand All @@ -37,25 +37,15 @@ public class NamePlateDebuffsPlugin : IDalamudPlugin

internal bool InPvp;

public NamePlateDebuffsPlugin(
ClientState clientState,
CommandManager commandManager,
DalamudPluginInterface pluginInterface,
DataManager dataManager,
Framework framework
)
public NamePlateDebuffsPlugin()
{
ClientState = clientState;
CommandManager = commandManager;
DataManager = dataManager;
Interface = pluginInterface;
Framework = framework;
// load or create config
Config = Interface.GetPluginConfig() as NamePlateDebuffsPluginConfig ?? new NamePlateDebuffsPluginConfig();
Config.Initialize(Interface);

Config = pluginInterface.GetPluginConfig() as NamePlateDebuffsPluginConfig ?? new NamePlateDebuffsPluginConfig();
Config.Initialize(pluginInterface);

Address = new PluginAddressResolver();
Address.Setup();
Address.Setup(SigScanner);

StatusNodeManager = new StatusNodeManager(this);

Expand All @@ -64,7 +54,7 @@ Framework framework

UI = new NamePlateDebuffsPluginUI(this);

ClientState.TerritoryChanged += OnTerritoryChange;
//ClientState.TerritoryChanged += OnTerritoryChange;

CommandManager.AddHandler("/npdebuffs", new CommandInfo(this.ToggleConfig)
{
Expand All @@ -73,26 +63,26 @@ Framework framework
}
public void Dispose()
{
ClientState.TerritoryChanged -= OnTerritoryChange;
//ClientState?.TerritoryChanged -= OnTerritoryChange;
CommandManager.RemoveHandler("/npdebuffs");

UI.Dispose();
Hooks.Dispose();
StatusNodeManager.Dispose();
}

private void OnTerritoryChange(object sender, ushort e)
{
try
{
TerritoryType territory = DataManager.GetExcelSheet<TerritoryType>()?.GetRow(e);
if (territory != null) InPvp = territory.IsPvpZone;
}
catch (KeyNotFoundException)
{
PluginLog.Warning("Could not get territory for current zone");
}
}
//private void OnTerritoryChange(object sender, ushort e)
//{
// try
// {
// TerritoryType? territory = DataManager.GetExcelSheet<TerritoryType>()?.GetRow(e);
// if (territory != null) InPvp = territory.IsPvpZone;
// }
// catch (KeyNotFoundException)
// {
// Log.Warning("Could not get territory for current zone");
// }
//}

private void ToggleConfig(string command, string args)
{
Expand Down
12 changes: 4 additions & 8 deletions NamePlateDebuffs/NamePlateDebuffsPluginConfig.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using Dalamud.Configuration;
using Dalamud.Plugin;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace NamePlateDebuffs
{
Expand Down Expand Up @@ -35,8 +31,8 @@ public class NamePlateDebuffsPluginConfig : IPluginConfiguration
public int DurationY = 23;
public int FontSize = 14;
public int DurationPadding = 2;
public Vector4 DurationTextColor = new Vector4(1, 1, 1, 1);
public Vector4 DurationEdgeColor = new Vector4(0, 0, 0, 1);
public Vector4 DurationTextColor = new(1, 1, 1, 1);
public Vector4 DurationEdgeColor = new(0, 0, 0, 1);

public void SetDefaults()
{
Expand Down Expand Up @@ -70,7 +66,7 @@ public void SetDefaults()
DurationEdgeColor.W = 1;
}

[NonSerialized] private DalamudPluginInterface _pluginInterface;
[NonSerialized] private DalamudPluginInterface? _pluginInterface;

public void Initialize(DalamudPluginInterface pluginInterface)
{
Expand All @@ -79,7 +75,7 @@ public void Initialize(DalamudPluginInterface pluginInterface)

public void Save()
{
_pluginInterface.SavePluginConfig(this);
_pluginInterface!.SavePluginConfig(this);
}
}
}
6 changes: 1 addition & 5 deletions NamePlateDebuffs/NamePlateDebuffsPluginUI.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using ImGuiNET;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
using Dalamud.Interface.Components;


namespace NamePlateDebuffs
{
Expand Down
15 changes: 4 additions & 11 deletions NamePlateDebuffs/PluginAddressResolver.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
using Dalamud.Game;
using Dalamud.Game.Internal;
using Dalamud.Plugin;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dalamud.Logging;

namespace NamePlateDebuffs
{
Expand All @@ -20,14 +13,14 @@ public class PluginAddressResolver : BaseAddressResolver

private const string AddonNamePlateDrawSignature = "0F B7 81 ?? ?? ?? ?? 4C 8B C1 66 C1 E0 06";

protected override void Setup64Bit(SigScanner scanner)
protected override void Setup64Bit(ISigScanner scanner)
{
AddonNamePlateFinalizeAddress = scanner.ScanText(AddonNamePlateFinalizeSignature);
AddonNamePlateDrawAddress = scanner.ScanText(AddonNamePlateDrawSignature);

PluginLog.Verbose("===== NamePlate Debuffs =====");
PluginLog.Verbose($"{nameof(AddonNamePlateFinalizeAddress)} {AddonNamePlateFinalizeAddress.ToInt64():X}");
PluginLog.Verbose($"{nameof(AddonNamePlateDrawAddress)} {AddonNamePlateDrawAddress.ToInt64():X}");
NamePlateDebuffsPlugin.Log.Verbose("===== NamePlate Debuffs =====");
NamePlateDebuffsPlugin.Log.Verbose($"{nameof(AddonNamePlateFinalizeAddress)} {AddonNamePlateFinalizeAddress.ToInt64():X}");
NamePlateDebuffsPlugin.Log.Verbose($"{nameof(AddonNamePlateDrawAddress)} {AddonNamePlateDrawAddress.ToInt64():X}");
}
}
}
22 changes: 10 additions & 12 deletions NamePlateDebuffs/StatusNode/StatusNode.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Dalamud.Logging;
using Dalamud.Plugin;
using FFXIVClientStructs.FFXIV.Client.System.Memory;
using FFXIVClientStructs.FFXIV.Client.System.Memory;
using FFXIVClientStructs.FFXIV.Component.GUI;

namespace NamePlateDebuffs.StatusNode
Expand Down Expand Up @@ -150,14 +148,14 @@ public void DestroyNodes()
var newResNode = (AtkResNode*)IMemorySpace.GetUISpace()->Malloc((ulong)sizeof(AtkResNode), 8);
if (newResNode == null)
{
PluginLog.Debug("Failed to allocate memory for res node");
NamePlateDebuffsPlugin.Log.Debug("Failed to allocate memory for res node");
return null;
}
IMemorySpace.Memset(newResNode, 0, (ulong)sizeof(AtkResNode));
newResNode->Ctor();

newResNode->Type = NodeType.Res;
newResNode->Flags = (short)(NodeFlags.AnchorLeft | NodeFlags.AnchorTop);
newResNode->NodeFlags = (NodeFlags.AnchorLeft | NodeFlags.AnchorTop);
newResNode->DrawFlags = 0;

return newResNode;
Expand All @@ -168,14 +166,14 @@ public void DestroyNodes()
var newImageNode = (AtkImageNode*)IMemorySpace.GetUISpace()->Malloc((ulong)sizeof(AtkImageNode), 8);
if (newImageNode == null)
{
PluginLog.Debug("Failed to allocate memory for image node");
NamePlateDebuffsPlugin.Log.Debug("Failed to allocate memory for image node");
return null;
}
IMemorySpace.Memset(newImageNode, 0, (ulong)sizeof(AtkImageNode));
newImageNode->Ctor();

newImageNode->AtkResNode.Type = NodeType.Image;
newImageNode->AtkResNode.Flags = (short)(NodeFlags.AnchorLeft | NodeFlags.AnchorTop | NodeFlags.UseDepthBasedPriority);
newImageNode->AtkResNode.NodeFlags = (NodeFlags.AnchorLeft | NodeFlags.AnchorTop | NodeFlags.UseDepthBasedPriority);
newImageNode->AtkResNode.DrawFlags = 0;

newImageNode->WrapMode = 1;
Expand All @@ -184,7 +182,7 @@ public void DestroyNodes()
var partsList = (AtkUldPartsList*)IMemorySpace.GetUISpace()->Malloc((ulong)sizeof(AtkUldPartsList), 8);
if (partsList == null)
{
PluginLog.Debug("Failed to allocate memory for parts list");
NamePlateDebuffsPlugin.Log.Debug("Failed to allocate memory for parts list");
newImageNode->AtkResNode.Destroy(true);
return null;
}
Expand All @@ -195,7 +193,7 @@ public void DestroyNodes()
var part = (AtkUldPart*)IMemorySpace.GetUISpace()->Malloc((ulong)sizeof(AtkUldPart), 8);
if (part == null)
{
PluginLog.Debug("Failed to allocate memory for part");
NamePlateDebuffsPlugin.Log.Debug("Failed to allocate memory for part");
IMemorySpace.Free(partsList, (ulong)sizeof(AtkUldPartsList));
newImageNode->AtkResNode.Destroy(true);
}
Expand All @@ -210,7 +208,7 @@ public void DestroyNodes()
var asset = (AtkUldAsset*)IMemorySpace.GetUISpace()->Malloc((ulong)sizeof(AtkUldAsset), 8);
if (asset == null)
{
PluginLog.Log("Failed to allocate memory for asset");
NamePlateDebuffsPlugin.Log.Debug("Failed to allocate memory for asset");
IMemorySpace.Free(part, (ulong)sizeof(AtkUldPart));
IMemorySpace.Free(partsList, (ulong)sizeof(AtkUldPartsList));
newImageNode->AtkResNode.Destroy(true);
Expand All @@ -233,14 +231,14 @@ public void DestroyNodes()
var newTextNode = (AtkTextNode*)IMemorySpace.GetUISpace()->Malloc((ulong)sizeof(AtkTextNode), 8);
if (newTextNode == null)
{
PluginLog.Debug("Failed to allocate memory for text node");
NamePlateDebuffsPlugin.Log.Debug("Failed to allocate memory for text node");
return null;
}
IMemorySpace.Memset(newTextNode, 0, (ulong)sizeof(AtkTextNode));
newTextNode->Ctor();

newTextNode->AtkResNode.Type = NodeType.Text;
newTextNode->AtkResNode.Flags = (short)(NodeFlags.AnchorLeft | NodeFlags.AnchorTop | NodeFlags.UseDepthBasedPriority);
newTextNode->AtkResNode.NodeFlags = (NodeFlags.AnchorLeft | NodeFlags.AnchorTop | NodeFlags.UseDepthBasedPriority);
newTextNode->AtkResNode.DrawFlags = 12;
newTextNode->AtkResNode.SetWidth(24);
newTextNode->AtkResNode.SetHeight(17);
Expand Down
9 changes: 4 additions & 5 deletions NamePlateDebuffs/StatusNode/StatusNodeGroup.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using Dalamud.Plugin;
using FFXIVClientStructs.FFXIV.Client.System.Memory;
using FFXIVClientStructs.FFXIV.Client.System.Memory;
using FFXIVClientStructs.FFXIV.Component.GUI;
using System;
using Dalamud.Logging;


namespace NamePlateDebuffs.StatusNode
{
Expand Down Expand Up @@ -154,14 +153,14 @@ public void SetupVisibility()
var newResNode = (AtkResNode*)IMemorySpace.GetUISpace()->Malloc((ulong)sizeof(AtkResNode), 8);
if (newResNode == null)
{
PluginLog.Debug("Failed to allocate memory for res node");
NamePlateDebuffsPlugin.Log.Debug("Failed to allocate memory for res node");
return null;
}
IMemorySpace.Memset(newResNode, 0, (ulong)sizeof(AtkResNode));
newResNode->Ctor();

newResNode->Type = NodeType.Res;
newResNode->Flags = (short)(NodeFlags.AnchorLeft | NodeFlags.AnchorTop);
newResNode->NodeFlags = (NodeFlags.AnchorLeft | NodeFlags.AnchorTop);
newResNode->DrawFlags = 0;

return newResNode;
Expand Down
Loading