Skip to content

Commit

Permalink
Added autofill by job (#199)
Browse files Browse the repository at this point in the history
* Update Metadata

* Update Metadata

* [improve] input character name from cross world party

* [add] auto fill by job button

---------

Co-authored-by: GitHub Action <noreply@nightmarexiv.com>
  • Loading branch information
Garume and GitHub Action authored Nov 23, 2024
1 parent ed4aea3 commit 0a5b742
Show file tree
Hide file tree
Showing 9 changed files with 955 additions and 355 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using ECommons.Hooks;
using ECommons.ImGuiMethods;
using ECommons.MathHelpers;
using ECommons.PartyFunctions;
using FFXIVClientStructs.FFXIV.Client.Game;
using ImGuiNET;
using Splatoon;
Expand Down Expand Up @@ -296,9 +297,10 @@ public override void OnSettingsDraw()
ImGui.SetNextItemWidth(150);
if (ImGui.BeginCombo("##partysel", "Select from party"))
{
foreach (var x in FakeParty.Get())
if (ImGui.Selectable(x.Name.ToString()))
C.PairCharacterName = x.Name.ToString();
foreach (var x in FakeParty.Get().Select(x => x.Name.ToString())
.Union(UniversalParty.Members.Select(x => x.Name)).ToHashSet())
if (ImGui.Selectable(x))
C.PairCharacterName = x;
ImGui.EndCombo();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@
using ECommons.Configuration;
using ECommons.DalamudServices;
using ECommons.DalamudServices.Legacy;
using ECommons.ExcelServices;
using ECommons.GameFunctions;
using ECommons.GameHelpers;
using ECommons.Hooks;
using ECommons.Hooks.ActionEffectTypes;
using ECommons.ImGuiMethods;
using ECommons.Logging;
using ECommons.MathHelpers;
using ECommons.PartyFunctions;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.UI.Info;
using ImGuiNET;
using Splatoon;
using Splatoon.SplatoonScripting;
Expand All @@ -45,6 +48,8 @@ public unsafe class P5_Death_of_the_Heavens : SplatoonScript
private Vector3 _lastPlayerPosition = Vector3.Zero;
private BaitType _myBait = BaitType.None;
private PlaystationMarker _myMarker = PlaystationMarker.Circle;
private readonly ImGuiEx.RealtimeDragDrop<Job> DragDrop = new("DragDropJob", x => x.ToString());

public override HashSet<uint>? ValidTerritories => [968];
private Config C => Controller.GetConfig<Config>();
public override Metadata? Metadata => new(5, "Garume");
Expand Down Expand Up @@ -121,6 +126,35 @@ private bool DrawPriorityList()
ImGui.SameLine();
ImGuiEx.Spacing();
if (ImGui.Button("Perform test")) SelfTest();
ImGui.SameLine();
if (ImGui.Button("Fill by job"))
{
HashSet<(string, Job)> party = [];
foreach (var x in FakeParty.Get())
party.Add((x.Name.ToString(), x.GetJob()));

var proxy = InfoProxyCrossRealm.Instance();
for (var i = 0; i < proxy->GroupCount; i++)
{
var group = proxy->CrossRealmGroups[i];
for (var c = 0; c < proxy->CrossRealmGroups[i].GroupMemberCount; c++)
{
var x = group.GroupMembers[c];
party.Add((x.Name.Read(), (Job)x.ClassJobId));
}
}

var index = 0;
foreach (var job in C.Jobs.Where(job => party.Any(x => x.Item2 == job)))
{
C.Priority[index] = party.First(x => x.Item2 == job).Item1;
index++;
}

for (var i = index; i < C.Priority.Length; i++)
C.Priority[i] = "";
}
ImGuiEx.Tooltip("The list is populated based on the job.\nYou can adjust the priority from the option header.");

ImGui.PushID("prio");
for (var i = 0; i < C.Priority.Length; i++)
Expand All @@ -134,9 +168,10 @@ private bool DrawPriorityList()
ImGui.SetNextItemWidth(150);
if (ImGui.BeginCombo("##partysel", "Select from party"))
{
foreach (var x in FakeParty.Get())
if (ImGui.Selectable(x.Name.ToString()))
C.Priority[i] = x.Name.ToString();
foreach (var x in FakeParty.Get().Select(x => x.Name.ToString())
.Union(UniversalParty.Members.Select(x => x.Name)).ToHashSet())
if (ImGui.Selectable(x))
C.Priority[i] = x;
ImGui.EndCombo();
}

Expand Down Expand Up @@ -188,6 +223,28 @@ public override void OnSettingsDraw()

ImGui.Unindent();

if (ImGuiEx.CollapsingHeader("Option"))
{
DragDrop.Begin();
foreach (var job in C.Jobs)
{
DragDrop.NextRow();
ImGui.Text(job.ToString());
ImGui.SameLine();

if (ThreadLoadImageHandler.TryGetIconTextureWrap((uint)job.GetIcon(), false, out var texture))
{
ImGui.Image(texture.ImGuiHandle, new Vector2(24f));
ImGui.SameLine();
}

ImGui.SameLine();
DragDrop.DrawButtonDummy(job, C.Jobs, C.Jobs.IndexOf(job));
}

DragDrop.End();
}

if (ImGui.CollapsingHeader("Debug"))
{
ImGui.Checkbox("Show Debug Message", ref C.ShowDebug);
Expand Down Expand Up @@ -572,6 +629,32 @@ private class Config : IEzConfig
{
public readonly Vector4 BaitColor1 = 0xFFFF00FF.ToVector4();
public readonly Vector4 BaitColor2 = 0xFFFFFF00.ToVector4();

public readonly List<Job> Jobs =
[
Job.PLD,
Job.WAR,
Job.DRK,
Job.GNB,
Job.WHM,
Job.SCH,
Job.AST,
Job.SGE,
Job.VPR,
Job.DRG,
Job.MNK,
Job.SAM,
Job.RPR,
Job.NIN,
Job.BRD,
Job.MCH,
Job.DNC,
Job.BLM,
Job.SMN,
Job.RDM,
Job.PCT
];

public bool LockFace = true;
public bool LockFaceEnableWhenNotMoving = true;
public Direction OrientationBase = Direction.North;
Expand All @@ -588,4 +671,4 @@ public static bool HasDoom(this IPlayerCharacter p)
{
return p.StatusList.Any(x => x.StatusId == 2976);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
using ECommons.Configuration;
using ECommons.DalamudServices;
using ECommons.DalamudServices.Legacy;
using ECommons.ExcelServices;
using ECommons.GameFunctions;
using ECommons.GameHelpers;
using ECommons.Hooks;
using ECommons.Hooks.ActionEffectTypes;
using ECommons.ImGuiMethods;
using ECommons.MathHelpers;
using ECommons.PartyFunctions;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.UI.Info;
using ImGuiNET;
using Splatoon;
using Splatoon.Serializables;
Expand All @@ -41,6 +44,8 @@ public class P6_Wroth_Flames : SplatoonScript

private readonly uint[] _heatTailCastIds = [27949, 27950];
private readonly uint[] _heatWingCastIds = [27947, 27948];
private readonly ImGuiEx.RealtimeDragDrop<Job> DragDrop = new("DragDropJob", x => x.ToString());

private int _redSphereCount;

private SafeSpreadDirection _safeSpreadDirection = SafeSpreadDirection.None;
Expand Down Expand Up @@ -91,7 +96,7 @@ public override void OnStartingCast(uint source, uint castId)
}
}
}

public override void OnDirectorUpdate(DirectorUpdateCategory category)
{
if (!C.ShouldCheckOnStart)
Expand All @@ -100,7 +105,7 @@ public override void OnDirectorUpdate(DirectorUpdateCategory category)
(category == DirectorUpdateCategory.Recommence && Controller.Phase == 2))
SelfTest();
}

private void SelfTest()
{
Svc.Chat.PrintChat(new XivChatEntry
Expand Down Expand Up @@ -318,7 +323,7 @@ public override void OnRemoveBuffEffect(uint sourceId, Status Status)
if (Status.StatusId == StackDebuffId) _state = State.End;
}

private bool DrawPriorityList()
private unsafe bool DrawPriorityList()
{
if (C.Priority.Length != 8)
C.Priority = ["", "", "", "", "", "", "", ""];
Expand All @@ -327,6 +332,35 @@ private bool DrawPriorityList()
ImGui.SameLine();
ImGuiEx.Spacing();
if (ImGui.Button("Perform test")) SelfTest();
ImGui.SameLine();
if (ImGui.Button("Fill by job"))
{
HashSet<(string, Job)> party = [];
foreach (var x in FakeParty.Get())
party.Add((x.Name.ToString(), x.GetJob()));

var proxy = InfoProxyCrossRealm.Instance();
for (var i = 0; i < proxy->GroupCount; i++)
{
var group = proxy->CrossRealmGroups[i];
for (var c = 0; c < proxy->CrossRealmGroups[i].GroupMemberCount; c++)
{
var x = group.GroupMembers[c];
party.Add((x.Name.Read(), (Job)x.ClassJobId));
}
}

var index = 0;
foreach (var job in C.Jobs.Where(job => party.Any(x => x.Item2 == job)))
{
C.Priority[index] = party.First(x => x.Item2 == job).Item1;
index++;
}

for (var i = index; i < C.Priority.Length; i++)
C.Priority[i] = "";
}
ImGuiEx.Tooltip("The list is populated based on the job.\nYou can adjust the priority from the option header.");

ImGui.PushID("prio");
for (var i = 0; i < C.Priority.Length; i++)
Expand All @@ -340,9 +374,10 @@ private bool DrawPriorityList()
ImGui.SetNextItemWidth(150);
if (ImGui.BeginCombo("##partysel", "Select from party"))
{
foreach (var x in FakeParty.Get())
if (ImGui.Selectable(x.Name.ToString()))
C.Priority[i] = x.Name.ToString();
foreach (var x in FakeParty.Get().Select(x => x.Name.ToString())
.Union(UniversalParty.Members.Select(x => x.Name)).ToHashSet())
if (ImGui.Selectable(x))
C.Priority[i] = x;
ImGui.EndCombo();
}

Expand Down Expand Up @@ -371,12 +406,32 @@ public override void OnSettingsDraw()
if (C.PrioritizeWest)
C.PrioritizeSecondRedBallDiagonal = false;
ImGui.Unindent();

ImGui.Text("Spread Settings");
ImGui.Indent();
DrawPriorityList();
ImGui.Unindent();

if (ImGuiEx.CollapsingHeader("Option"))
{
DragDrop.Begin();
foreach (var job in C.Jobs)
{
DragDrop.NextRow();
ImGui.Text(job.ToString());
ImGui.SameLine();

if (ThreadLoadImageHandler.TryGetIconTextureWrap((uint)job.GetIcon(), false, out var texture))
{
ImGui.Image(texture.ImGuiHandle, new Vector2(24f));
ImGui.SameLine();
}

ImGui.SameLine();
DragDrop.DrawButtonDummy(job, C.Jobs, C.Jobs.IndexOf(job));
}

DragDrop.End();
}
if (ImGuiEx.CollapsingHeader("Debug"))
{
ImGui.Text($"State: {_state}");
Expand Down Expand Up @@ -445,5 +500,30 @@ private class Config : IEzConfig
public bool PrioritizeWest;
public string[] Priority = ["", "", "", "", "", "", "", ""];
public bool ShouldCheckOnStart;

public List<Job> Jobs =
[
Job.PLD,
Job.WAR,
Job.DRK,
Job.GNB,
Job.WHM,
Job.SCH,
Job.AST,
Job.SGE,
Job.VPR,
Job.DRG,
Job.MNK,
Job.SAM,
Job.RPR,
Job.NIN,
Job.BRD,
Job.MCH,
Job.DNC,
Job.BLM,
Job.SMN,
Job.RDM,
Job.PCT
];
}
}
}
Loading

0 comments on commit 0a5b742

Please sign in to comment.