Skip to content

Commit

Permalink
1.5.0.0
Browse files Browse the repository at this point in the history
7.0 update
PenumbraApi disabled until later notice.
  • Loading branch information
Kurochi51 committed Jul 3, 2024
1 parent b9db0c6 commit 73451d9
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 89 deletions.
2 changes: 1 addition & 1 deletion TickTracker/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ public class Configuration : IPluginConfiguration
public Vector4 GPNativeUiColor { get; set; } = new(0f, 0.570f, 0.855f, 1f);
public Vector4 GPIconColor { get; set; } = new(1f, 1f, 1f, 1f);

public void Save(DalamudPluginInterface pi) => pi.SavePluginConfig(this);
public void Save(IDalamudPluginInterface pi) => pi.SavePluginConfig(this);

Check failure on line 51 in TickTracker/Configuration.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'IDalamudPluginInterface' could not be found (are you missing a using directive or an assembly reference?)

}
2 changes: 1 addition & 1 deletion TickTracker/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

using System.Diagnostics.CodeAnalysis;
[assembly: SuppressMessage("Design", "MA0038:Make method static (deprecated, use CA1822 instead)", Justification = "Obsolete", Scope = "member", Target = "~M:TickTracker.Helpers.Utilities.IsAddonReady(FFXIVClientStructs.FFXIV.Component.GUI.AtkUnitBase*)~System.Boolean")]
[assembly: SuppressMessage("Design", "MA0038:Make method static (deprecated, use CA1822 instead)", Justification = "Obsolete", Scope = "member", Target = "~M:TickTracker.Helpers.Utilities.IsTarget(Dalamud.Game.ClientState.Objects.SubKinds.PlayerCharacter,FFXIVClientStructs.FFXIV.Client.Game.Character.Character*)~System.Boolean")]
[assembly: SuppressMessage("Design", "MA0038:Make method static (deprecated, use CA1822 instead)", Justification = "Obsolete", Scope = "member", Target = "~M:TickTracker.Helpers.Utilities.IsTarget(Dalamud.Game.ClientState.Objects.SubKinds.IPlayerCharacter,FFXIVClientStructs.FFXIV.Client.Game.Character.Character*)~System.Boolean")]
[assembly: SuppressMessage("Design", "MA0038:Make method static (deprecated, use CA1822 instead)", Justification = "Obsolete", Scope = "member", Target = "~M:TickTracker.Helpers.Utilities.AddonOverlap(FFXIVClientStructs.FFXIV.Component.GUI.AtkUnitBase*,TickTracker.Windows.BarWindowBase,System.Boolean)~System.Boolean")]
[assembly: SuppressMessage("Design", "MA0038:Make method static (deprecated, use CA1822 instead)", Justification = "Obsolete", Scope = "member", Target = "~M:TickTracker.NativeNodes.ImageNode.FreeResources(FFXIVClientStructs.FFXIV.Component.GUI.AtkUldPartsList*[])~System.Void")]
[assembly: SuppressMessage("Design", "MA0049:Type name should not match containing namespace", Justification = "...and I took that personally.", Scope = "type", Target = "~T:TickTracker.TickTracker")]
2 changes: 1 addition & 1 deletion TickTracker/Helpers/NativeUi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static uint Get(string name, int index = 0)
for (var i = 0; i < uldManager->NodeListCount; i++)
{
var n = uldManager->NodeList[i];
if (n->NodeID != nodeId || (type != null && n->Type != type.Value))
if (n->NodeId != nodeId || (type != null && n->Type != type.Value))
{
continue;
}
Expand Down
14 changes: 7 additions & 7 deletions TickTracker/Helpers/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
using Lumina.Excel.GeneratedSheets2;
using FFXIVClientStructs.FFXIV.Component.GUI;
using FFXIVClientStructs.FFXIV.Client.Game.Character;
using Dalamud;
using Dalamud.Game;
using Dalamud.Plugin;
using Dalamud.Plugin.Services;
using Dalamud.Game.ClientState.Conditions;
Expand All @@ -27,7 +27,7 @@ namespace TickTracker.Helpers;
/// <summary>
/// A class that contains different helper functions necessary for this plugin's operation
/// </summary>
public partial class Utilities(DalamudPluginInterface _pluginInterface,
public partial class Utilities(IDalamudPluginInterface _pluginInterface,

Check failure on line 30 in TickTracker/Helpers/Utilities.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'IDalamudPluginInterface' could not be found (are you missing a using directive or an assembly reference?)
Configuration _config,
ICondition _condition,
IDataManager _dataManager,
Expand Down Expand Up @@ -59,7 +59,7 @@ public partial class Utilities(DalamudPluginInterface _pluginInterface,
/// </summary>
public FrozenSet<string> RegenNullKeywords { get; } = CreateFrozenSet("null", "nullified", "stop", "stopped");

private readonly DalamudPluginInterface pluginInterface = _pluginInterface;
private readonly IDalamudPluginInterface pluginInterface = _pluginInterface;

Check failure on line 62 in TickTracker/Helpers/Utilities.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'IDalamudPluginInterface' could not be found (are you missing a using directive or an assembly reference?)
private readonly Configuration config = _config;
private readonly ICondition condition = _condition;
private readonly IDataManager dataManager = _dataManager;
Expand Down Expand Up @@ -179,7 +179,7 @@ public bool InIgnoredInstances()
{
return false;
}
return (TerritoryIntendedUseType)territory.TerritoryIntendedUse is TerritoryIntendedUseType.Diadem;
return (TerritoryIntendedUseType)territory.TerritoryIntendedUse.Row is TerritoryIntendedUseType.Diadem;
}

/// <summary>
Expand All @@ -204,10 +204,10 @@ public unsafe bool IsAddonReady(AtkUnitBase* addon)
/// <summary>
/// Check if <paramref name="sourceCharacter"/> is currently targeting <paramref name="targetCharacter"/>, whether it's manually set, or the result of using an action.
/// </summary>
public unsafe bool IsTarget(PlayerCharacter targetCharacter, Character* sourceCharacter)
public unsafe bool IsTarget(IPlayerCharacter targetCharacter, Character* sourceCharacter)

Check failure on line 207 in TickTracker/Helpers/Utilities.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'IPlayerCharacter' could not be found (are you missing a using directive or an assembly reference?)
{
ITuple sourceTarget = (sourceCharacter->GetCastInfo()->CastTargetID, sourceCharacter->GetSoftTargetId().ObjectID, sourceCharacter->GetTargetId(), sourceCharacter->Gaze.Controller.GazesSpan[0].TargetInfo.TargetId.ObjectID);
var targetID = (object)targetCharacter.ObjectId;
ITuple sourceTarget = (sourceCharacter->GetCastInfo()->TargetId.ObjectId, sourceCharacter->GetSoftTargetId().ObjectId, sourceCharacter->GetTargetId(), sourceCharacter->LookAt.Controller.Params[0].TargetParam.TargetId.ObjectId);
var targetID = (object)targetCharacter.EntityId;
for (var i = 0; i < sourceTarget.Length; i++)
{
var sourceTargetID = sourceTarget[i];
Expand Down
8 changes: 4 additions & 4 deletions TickTracker/IPC/PenumbraApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

namespace TickTracker.IPC;

public sealed class PenumbraApi : IDisposable
/*public sealed class PenumbraApi : IDisposable
{
private readonly IPluginLog log;
private readonly DalamudPluginInterface pluginInterface;
private readonly IDalamudPluginInterface pluginInterface;
private readonly ApiVersion apiVersion;
private readonly GetEnabledState getEnabledState;
Expand Down Expand Up @@ -58,7 +58,7 @@ private bool penumbraModsEnabled
}
}
public PenumbraApi(DalamudPluginInterface _pluginInterface, IPluginLog _pluginLog)
public PenumbraApi(IDalamudPluginInterface _pluginInterface, IPluginLog _pluginLog)
{
log = _pluginLog;
pluginInterface = _pluginInterface;
Expand Down Expand Up @@ -149,4 +149,4 @@ public void Dispose()
init.Dispose();
disposed.Dispose();
}
}
}*/
16 changes: 8 additions & 8 deletions TickTracker/NativeNodes/ImageNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace TickTracker.NativeNodes;

public sealed unsafe class ImageNode : IDisposable
{
public required uint NodeID { get; set; }
public required uint NodeId { get; set; }
public NodeType Type { get; } = NodeType.Image;
public NodeFlags NodeFlags { get; set; } = NodeFlags.AnchorTop | NodeFlags.AnchorLeft | NodeFlags.Enabled | NodeFlags.Visible | NodeFlags.EmitsEvents;
public uint DrawFlags { get; set; } = 1;
Expand Down Expand Up @@ -266,7 +266,7 @@ public void CreateCompleteImageNode(int partsListIndex, bool hqTexture = false,
}

imageNode->AtkResNode.Type = Type;
imageNode->AtkResNode.NodeID = NodeID;
imageNode->AtkResNode.NodeId = NodeId;
imageNode->PartsList = atkPartsList;

imageNode->PartId = 0;
Expand All @@ -282,15 +282,15 @@ public void CreateCompleteImageNode(int partsListIndex, bool hqTexture = false,
imageNodeParent = parent;
NativeUi.LinkNodeAfterTargetNode(&imageNode->AtkResNode, parent->GetAsAtkComponentNode(), targetNode);
}
nodePosition.X = imageNode->AtkResNode.GetX();
nodePosition.Y = imageNode->AtkResNode.GetY();
nodePosition.X = imageNode->AtkResNode.GetXFloat();
nodePosition.Y = imageNode->AtkResNode.GetYFloat();
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetNodePosition(float X, float Y)
{
imageNode->AtkResNode.SetX(X);
imageNode->AtkResNode.SetY(Y);
imageNode->AtkResNode.SetXFloat(X);
imageNode->AtkResNode.SetYFloat(Y);
}

public void ResetNodePosition()
Expand All @@ -300,8 +300,8 @@ public void ResetNodePosition()
log.Error("Image node not initialised");
return;
}
imageNode->AtkResNode.SetX(nodePosition.X);
imageNode->AtkResNode.SetY(nodePosition.Y);
imageNode->AtkResNode.SetXFloat(nodePosition.X);
imageNode->AtkResNode.SetYFloat(nodePosition.Y);
}

/// <summary>
Expand Down
85 changes: 40 additions & 45 deletions TickTracker/TickTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public sealed class TickTracker : IDalamudPlugin
[Signature("48 89 5C 24 ?? 48 89 6C 24 ?? 56 48 83 EC 20 83 3D ?? ?? ?? ?? ?? 41 0F B6 E8 48 8B DA 8B F1 0F 84 ?? ?? ?? ?? 48 89 7C 24 ??", DetourName = nameof(ActorTickUpdate))]
private readonly Hook<ReceiveActorUpdateDelegate>? receiveActorUpdateHook = null;

private readonly DalamudPluginInterface pluginInterface;
private readonly IDalamudPluginInterface pluginInterface;

Check failure on line 63 in TickTracker/TickTracker.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'IDalamudPluginInterface' could not be found (are you missing a using directive or an assembly reference?)
private readonly Configuration config;
private readonly Utilities utilities;
private readonly IClientState clientState;
Expand Down Expand Up @@ -100,11 +100,11 @@ public sealed class TickTracker : IDalamudPlugin
private bool syncAvailable = true, nullSheet = true;
private uint lastHPValue, lastMPValue, lastGPValue;
private Task? loadingTask;
private PenumbraApi? penumbraApi;
//private PenumbraApi? penumbraApi;
private unsafe AtkUnitBase* NameplateAddon => (AtkUnitBase*)gameGui.GetAddonByName("NamePlate");
private unsafe AtkUnitBase* ParamWidget => (AtkUnitBase*)gameGui.GetAddonByName("_ParameterWidget");

public TickTracker(DalamudPluginInterface _pluginInterface,
public TickTracker(IDalamudPluginInterface _pluginInterface,

Check failure on line 107 in TickTracker/TickTracker.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'IDalamudPluginInterface' could not be found (are you missing a using directive or an assembly reference?)
IClientState _clientState,
IFramework _framework,
IGameGui _gameGui,
Expand Down Expand Up @@ -135,16 +135,17 @@ public sealed class TickTracker : IDalamudPlugin
throw new NotSupportedException("Hook not found in current game version. The plugin is non functional.");
}
receiveActorUpdateHook.Enable();

cts = new CancellationTokenSource();

var tickerUld = pluginInterface.UiBuilder.LoadUld(ParamWidgetUldPath);
primaryTickerNode = new ImageNode(_dataManager, log, tickerUld)
{
NodeID = primaryTickerImageID,
NodeId = primaryTickerImageID,
};
secondaryTickerNode = new ImageNode(_dataManager, log, tickerUld)
{
NodeID = secondaryTickerImageID,
NodeId = secondaryTickerImageID,
};
tickerUld.Dispose();

Expand Down Expand Up @@ -176,6 +177,7 @@ public sealed class TickTracker : IDalamudPlugin

private void PenumbraCheck()
{
/*
try
{
var plo = pluginInterface.InstalledPlugins.SingleOrDefault(gon => gon.InternalName.Equals("Penumbra", StringComparison.Ordinal));
Expand Down Expand Up @@ -216,12 +218,13 @@ private void PenumbraCheck()
log.Error("Penumbra IPC failed. {ex}", ex.Message);
}
}
*/
}

private void InitializeWindows()
{
DebugWindow = new DebugWindow(pluginInterface);
ConfigWindow = new ConfigWindow(pluginInterface, config, DebugWindow, penumbraApi);
ConfigWindow = new ConfigWindow(pluginInterface, config, DebugWindow);//, penumbraApi);
HPBarWindow = new HPBar(clientState, log, utilities, config);
MPBarWindow = new MPBar(clientState, log, utilities, config);
GPBarWindow = new GPBar(clientState, log, utilities, config);
Expand Down Expand Up @@ -259,7 +262,7 @@ private unsafe void InitializeResolution()
private void OnFrameworkUpdate(IFramework _framework)
{
#if DEBUG
DevWindowThings(clientState?.LocalPlayer, (DateTime.UtcNow - DateTime.UnixEpoch).TotalSeconds, MPBarWindow);
DevWindowThings(clientState?.LocalPlayer, (DateTime.UtcNow - DateTime.UnixEpoch).TotalSeconds, barWindows);
#endif
if (clientState is { IsLoggedIn: false } or { IsPvPExcludingDen: true } || nullSheet)
{
Expand Down Expand Up @@ -310,7 +313,7 @@ private void OnFrameworkUpdate(IFramework _framework)
UpdateBarState(player);
}

private void ProcessTicks(double currentTime, PlayerCharacter player)
private void ProcessTicks(double currentTime, IPlayerCharacter player)

Check failure on line 316 in TickTracker/TickTracker.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'IPlayerCharacter' could not be found (are you missing a using directive or an assembly reference?)
{
var statusList = player.StatusList.ToList();
// HP section
Expand Down Expand Up @@ -456,16 +459,17 @@ private void ParseStatusSheet(IEnumerable<Lumina.Excel.GeneratedSheets2.Status>
/// HP = *(int*)packetData;
/// MP = *((ushort*)packetData + 2);
/// GP = *((short*)packetData + 3); // Goes up to 10000 and is tracked and updated at all times
private unsafe void ActorTickUpdate(uint objectId, uint* packetData, byte unkByte)
/// player.address + 0x2258 = accountId
private unsafe void ActorTickUpdate(uint entityId, uint* packetData, byte unkByte)
{
receiveActorUpdateHook!.Original(objectId, packetData, unkByte);
receiveActorUpdateHook!.Original(entityId, packetData, unkByte);
try
{
if (clientState is not { LocalPlayer: { } player })
{
return;
}
if (objectId != player.ObjectId)
if (entityId != player.EntityId)
{
return;
}
Expand All @@ -482,7 +486,7 @@ private unsafe void ActorTickUpdate(uint objectId, uint* packetData, byte unkByt
}
}

private unsafe void UpdateBarState(PlayerCharacter player)
private unsafe void UpdateBarState(IPlayerCharacter player)

Check failure on line 489 in TickTracker/TickTracker.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'IPlayerCharacter' could not be found (are you missing a using directive or an assembly reference?)
{
var jobId = player.ClassJob.Id;
var althideForMeleeRangedDPS = meleeAndRangedDPS.Contains(jobId);
Expand All @@ -499,7 +503,7 @@ private unsafe void UpdateBarState(PlayerCharacter player)
HPBarWindow.IsOpen = !config.LockBar || (shouldShowHPBar && config.HPVisible);
MPBarWindow.IsOpen = !config.LockBar || (shouldShowMPBar && config.MPVisible && !hideForGPBar);
GPBarWindow.IsOpen = !config.LockBar || (shouldShowGPBar && config.GPVisible);
if (penumbraAvailable && penumbraApi is not null && penumbraApi.NativeUiBanned)
/*if (penumbraAvailable && penumbraApi is not null && penumbraApi.NativeUiBanned)
{
if (primaryTickerNode.imageNode is not null)
{
Expand All @@ -510,7 +514,7 @@ private unsafe void UpdateBarState(PlayerCharacter player)
secondaryTickerNode.DestroyNode();
}
return;
}
}*/
if (utilities.IsAddonReady(ParamWidget) && ParamWidget->UldManager.LoadedState is AtkLoadState.Loaded && ParamWidget->IsVisible)
{
DrawNativePrimary(shouldShowHPBar);
Expand Down Expand Up @@ -602,40 +606,31 @@ private unsafe void CheckBarCollision(AddonEvent type, AddonArgs args)
}

#if DEBUG
private unsafe void DevWindowThings(PlayerCharacter? player, double currentTime, BarWindowBase window)
private unsafe void DevWindowThings(IPlayerCharacter? player, double currentTime, FrozenSet<BarWindowBase> windowList)
{
DevWindow.IsOpen = true;
if (penumbraAvailable && penumbraIpc is not null)
/*if (penumbraAvailable && penumbraApi is not null)
{
DevWindow.Print(nameof(penumbraIpc.NativeUiBanned) + " is " + penumbraIpc.NativeUiBanned);
}
if (player is not null)
DevWindow.Print(nameof(penumbraApi.NativeUiBanned) + " is " + penumbraApi.NativeUiBanned);
}*/
if (player is null)
{
DevWindow.Print(window.WindowName + ": " + player.CurrentHp.ToString() + " / " + player.MaxHp.ToString());
var shieldValue = player.ShieldPercentage * player.MaxHp / 100;
DevWindow.Print("Possible shield values for " + (player.Name.TextValue ?? "unknown") + " of " + shieldValue);
if (DevWindow.startBenchmark)
{
DevWindow.startBenchmark = false;
_ = Task.Run(() => DevWindow.BenchmarkSpawner(player, 1_000_000, healthRegenSet, disabledHealthRegenSet, manaRegenSet), cts.Token);
}
}
else if (DevWindow.startBenchmark)
{
DevWindow.startBenchmark = false;
log.Debug("Player and StatusManager is not available.");
return;
}
var cultureFormat = System.Globalization.CultureInfo.InvariantCulture;
DevWindow.Print($"Window open? {window.IsOpen}");
DevWindow.Print("Current Time: " + currentTime.ToString(cultureFormat));
DevWindow.Print("RegenActive: " + window.RegenActive.ToString());
DevWindow.Print("Progress: " + window.Progress.ToString(cultureFormat));
DevWindow.Print("NormalTick: " + window.Tick.ToString(cultureFormat));
DevWindow.Print("NormalUpdate: " + window.TickUpdate.ToString());
DevWindow.Print("Sync Value: " + syncValue.ToString(cultureFormat));
DevWindow.Print("Regen Value: " + regenValue.ToString(cultureFormat));
DevWindow.Print("Fast Value: " + fastValue.ToString(cultureFormat));
DevWindow.Print("Swapchain resolution: " + Resolution.X.ToString(cultureFormat) + "x" + Resolution.Y.ToString(cultureFormat));
foreach (var window in windowList)
{
DevWindow.Print($"{window.WindowName} open: {window.IsOpen}");
DevWindow.Print("Current Time: " + currentTime.ToString(cultureFormat));
DevWindow.Print("RegenActive: " + window.RegenActive.ToString());
DevWindow.Print("Progress: " + window.Progress.ToString(cultureFormat));
DevWindow.Print("NormalTick: " + window.Tick.ToString(cultureFormat));
DevWindow.Print("NormalUpdate: " + window.TickUpdate.ToString());
DevWindow.Print("Sync Value: " + syncValue.ToString(cultureFormat));
DevWindow.Print("Regen Value: " + regenValue.ToString(cultureFormat));
DevWindow.Print("Fast Value: " + fastValue.ToString(cultureFormat));
DevWindow.Print("Swapchain resolution: " + Resolution.X.ToString(cultureFormat) + "x" + Resolution.Y.ToString(cultureFormat));
}
}
#endif

Expand Down Expand Up @@ -700,7 +695,7 @@ private unsafe void HandleNativeNode(in ImageNode tickerNode, uint gaugeBarNodeI
{
tickerNode.imageNode->AtkResNode.SetWidth(0);
}
if (tickerNode.imageNode->AtkResNode.IsVisible)
if (tickerNode.imageNode->AtkResNode.IsVisible())
{
tickerNode.imageNode->AtkResNode.ToggleVisibility(visibility);
}
Expand Down Expand Up @@ -741,7 +736,7 @@ private unsafe void HandleNativeNode(in ImageNode tickerNode, uint gaugeBarNodeI
tickerNode.CreateCompleteImageNode(0, hq, gaugeBarNode, frameResNode);
if (tickerNode.imageNode is null)
{
log.Error("ImageNode {id} could not be created.", tickerNode.NodeID);
log.Error("ImageNode {id} could not be created.", tickerNode.NodeId);
failed = true;
return;
}
Expand All @@ -763,7 +758,7 @@ public void Dispose()
#endif
cts.Cancel();
cts.Dispose();
penumbraApi?.Dispose();
//penumbraApi?.Dispose();
receiveActorUpdateHook?.Disable();
receiveActorUpdateHook?.Dispose();
commandManager.RemoveHandler(CommandName);
Expand Down
6 changes: 3 additions & 3 deletions TickTracker/TickTracker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Authors></Authors>
<Company></Company>
<Version>1.4.4.0</Version>
<Version>1.5.0.0</Version>
<Description>A plugin that keeps track of HP/MP/GP ticks.</Description>
<Copyright></Copyright>
<PackageProjectUrl>https://github.com/Kurochi51/TickTracker</PackageProjectUrl>
Expand Down Expand Up @@ -38,8 +38,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.12" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.158">
<PackageReference Include="DalamudPackager" Version="2.1.13" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.159">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Loading

0 comments on commit 73451d9

Please sign in to comment.