Skip to content

Commit

Permalink
[PR] Patch 7.0 support
Browse files Browse the repository at this point in the history
No functional changes.
  • Loading branch information
PrincessRTFM committed Jul 6, 2024
1 parent 389c105 commit 21902a6
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 42 deletions.
20 changes: 10 additions & 10 deletions PositionalGuide/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ public const int
/// Starts at front then goes clockwise up to index=7, then circle at index=8 and outer circle at index=9
/// </summary>
public Vector4[] LineColours { get; set; } = new Vector4[] {
new Vector4(1, 0, 0, 1), // front
new Vector4(1, 0, 0, 1), // front right
new Vector4(0, 0, 1, 1), // right
new Vector4(0, 1, 0, 1), // back right
new Vector4(0, 1, 0, 1), // back
new Vector4(0, 1, 0, 1), // back left
new Vector4(0, 0, 1, 1), // left
new Vector4(1, 0, 0, 1), // front left
new Vector4(1, 1, 0, 1), // circle default
new Vector4(1, 1, 0, 1), // outer circle default
new(1, 0, 0, 1), // front
new(1, 0, 0, 1), // front right
new(0, 0, 1, 1), // right
new(0, 1, 0, 1), // back right
new(0, 1, 0, 1), // back
new(0, 1, 0, 1), // back left
new(0, 0, 1, 1), // left
new(1, 0, 0, 1), // front left
new(1, 1, 0, 1), // circle default
new(1, 1, 0, 1), // outer circle default
};

public void Update() {
Expand Down
4 changes: 1 addition & 3 deletions PositionalGuide/ImGuitils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ namespace PrincessRTFM.PositionalGuide;
internal class ImGuitils {
public int TooltipPixelWrapWidth;

public ImGuitils(int tooltipPixelWrapWidth) {
this.TooltipPixelWrapWidth = tooltipPixelWrapWidth;
}
public ImGuitils(int tooltipPixelWrapWidth) => this.TooltipPixelWrapWidth = tooltipPixelWrapWidth;

public void Tooltip(string text) {
if (ImGui.IsItemHovered()) {
Expand Down
33 changes: 17 additions & 16 deletions PositionalGuide/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Game.Gui.Dtr;
using Dalamud.Interface.Internal.Notifications;
using Dalamud.Interface.ImGuiNotification;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Windowing;
using Dalamud.IoC;
Expand All @@ -27,7 +27,7 @@ public class Plugin: IDalamudPlugin {
// lineIndexToRad and circleSegmentIdxToRad are fixed and only need to be calculated once at the start,
// since neither the number of lines nor the number of circle segments change
private readonly float[] lineIndexToAngle = Enumerable.Range(Configuration.IndexFront, Configuration.IndexFrontLeft + 1).Select(idx => (float)(idx * Math.PI / 4)).ToArray();
private readonly float[] circleSegmentIdxToAngle = Enumerable.Range(0, circleSegmentCount).Select(idx => (float)(idx * (2.0 * Math.PI / circleSegmentCount))).ToArray();
private readonly float[] circleSegmentIdxToAngle = Enumerable.Range(0, circleSegmentCount).Select(idx => (float)(idx * (2.0 * Math.PI / circleSegmentCount))).ToArray();
private readonly Vector4[] circleSegmentIdxToColour = new Vector4[circleSegmentCount];

private enum CircleTypes { Target, Outer };
Expand All @@ -39,7 +39,7 @@ private enum CircleTypes { Target, Outer };

[PluginService] public static IGameGui Gui { get; private set; } = null!;
[PluginService] public static IChatGui Chat { get; private set; } = null!;
[PluginService] public static DalamudPluginInterface Interface { get; private set; } = null!;
[PluginService] public static IDalamudPluginInterface Interface { get; private set; } = null!;
[PluginService] public static ICommandManager Commands { get; private set; } = null!;
[PluginService] public static IClientState Client { get; private set; } = null!;
[PluginService] public static ITargetManager Targets { get; private set; } = null!;
Expand All @@ -50,7 +50,7 @@ private enum CircleTypes { Target, Outer };

private readonly WindowSystem windowSystem;
private readonly ConfigWindow configWindow;
private readonly DtrBarEntry dtrEntry;
private readonly IDtrBarEntry dtrEntry;

public Plugin(IDtrBar dtrBar) {
this.Config = Interface.GetPluginConfig() as Configuration ?? new();
Expand Down Expand Up @@ -117,10 +117,10 @@ internal void Draw() {
if (!this.Config.Enabled)
return;

if (Targets.Target is not BattleChara target)
if (Targets.Target is not IBattleNpc target)
return;

if (Client.LocalPlayer is not PlayerCharacter player)
if (Client.LocalPlayer is not IPlayerCharacter player)
return;

if (target.ObjectKind is ObjectKind.Player) {
Expand Down Expand Up @@ -174,16 +174,17 @@ internal void Draw() {
for (int lineIndex = Configuration.IndexFront; lineIndex <= Configuration.IndexFrontLeft; ++lineIndex) {
if (!this.Config.DrawGuides[lineIndex])
continue;
anyLineActive = true;
anyLineActive = true;

Vector3 rotated = RotatePoint(targetPos, guidelineBasePoint2, targetFacing + this.lineIndexToAngle[lineIndex]);
bool endpointOnScreen = Gui.WorldToScreen(rotated, out Vector2 coord);
if (limitEither) {
if (!targetOnScreen && !endpointOnScreen)
continue;
} else if (limitOuter && !endpointOnScreen) {
continue;
}
if (limitEither) {
if (!targetOnScreen && !endpointOnScreen)
continue;
}
else if (limitOuter && !endpointOnScreen) {
continue;
}
drawing.AddLine(centre, coord, ImGui.GetColorU32(this.Config.LineColours[lineIndex]), this.Config.LineThickness);
}

Expand Down Expand Up @@ -264,13 +265,13 @@ private void DrawCircle(ImDrawListPtr drawing, Vector3 targetPos, Vector3 basePo
case CircleTypes.Outer:
circleColour = this.Config.LineColours[Configuration.IndexOuterCircle];
forceCircleColour = this.Config.AlwaysUseCircleColours || this.Config.AlwaysUseCircleColoursOuter || !anyLineActive;
circleBasePoint += new Vector3(0, 0, this.Config.SoftOuterCircleRange);
circleBasePoint += new Vector3(0, 0, this.Config.SoftOuterCircleRange);
break;
}

Vector3 startPoint = RotatePoint(targetPos, circleBasePoint, targetFacing);
Vector3[] points = CirclePoints(targetPos, startPoint, this.circleSegmentIdxToAngle).ToArray();

(Vector2 point, bool render)[] screenPoints = new (Vector2 point, bool render)[points.Length];
for (int i = 0; i < points.Length; ++i) {
bool render = Gui.WorldToScreen(points[i], out Vector2 screenPoint);
Expand Down Expand Up @@ -310,7 +311,7 @@ private static Vector3 RotatePoint(Vector3 centre, Vector3 originalPoint, double

private static double AngleBetween(Vector2 vertex, Vector2 a, Vector2 b) => Math.Atan2(b.Y - vertex.Y, b.X - vertex.X) - Math.Atan2(a.Y - vertex.Y, a.X - vertex.X);
private static double AngleBetween(Vector3 vertex, Vector3 a, Vector3 b) => AngleBetween(new Vector2(vertex.X, vertex.Z), new Vector2(a.X, a.Z), new Vector2(b.X, b.Z));
private static float AngleDifference(float a, float b) => (float)(Math.Min(Math.Abs(a - b), Math.Abs(Math.Abs(a - b) - (2 * Math.PI))));
private static float AngleDifference(float a, float b) => (float)Math.Min(Math.Abs(a - b), Math.Abs(Math.Abs(a - b) - (2 * Math.PI)));

private static IEnumerable<Vector2> CirclePoints(Vector2 centre, Vector2 start, float[] angles) {
foreach (float angle in angles)
Expand Down
6 changes: 5 additions & 1 deletion PositionalGuide/dalamud.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<Import Project="framework.props" />

<ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.12" />
<PackageReference Include="DalamudPackager" Version="2.1.13" />
<Reference Include="Newtonsoft.Json">
<HintPath>$(DalamudLibPath)Newtonsoft.Json.dll</HintPath>
<Private>False</Private>
Expand Down Expand Up @@ -44,6 +44,10 @@
<HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="InteropGenerator.Runtime">
<HintPath>$(DalamudLibPath)InteropGenerator.Runtime.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>

<ItemGroup>
Expand Down
24 changes: 12 additions & 12 deletions PositionalGuide/packages.lock.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"version": 1,
"dependencies": {
"net8.0-windows7.0": {
"DalamudPackager": {
"type": "Direct",
"requested": "[2.1.12, )",
"resolved": "2.1.12",
"contentHash": "Sc0PVxvgg4NQjcI8n10/VfUQBAS4O+Fw2pZrAqBdRMbthYGeogzu5+xmIGCGmsEZ/ukMOBuAqiNiB5qA3MRalg=="
}
}
}
}
"version": 1,
"dependencies": {
"net8.0-windows7.0": {
"DalamudPackager": {
"type": "Direct",
"requested": "[2.1.13, )",
"resolved": "2.1.13",
"contentHash": "rMN1omGe8536f4xLMvx9NwfvpAc9YFFfeXJ1t4P4PE6Gu8WCIoFliR1sh07hM+bfODmesk/dvMbji7vNI+B/pQ=="
}
}
}
}

0 comments on commit 21902a6

Please sign in to comment.