Skip to content

BuildTab: Draw current node with guidemarkers #926

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 19, 2025
Merged
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
6 changes: 4 additions & 2 deletions AutoDuty/AutoDuty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,9 @@ private void UiBuilderOnDraw()

if (drawList != null)
{
if (Plugin.Configuration.PathDrawEnabled && this.Actions.Any() && (this.Indexer < 0 || !this.Actions[this.Indexer].Name.Equals("Boss") || Stage != Stage.Action))
BuildTab.DrawHelper(drawList);

if (Plugin.Configuration.PathDrawEnabled && CurrentTerritoryContent?.TerritoryType == Svc.ClientState.TerritoryType && this.Actions.Any() && (this.Indexer < 0 || !this.Actions[this.Indexer].Name.Equals("Boss") || Stage != Stage.Action))
{
Vector3 lastPos = Player.Position;
float stepCountFactor = (1f / this.Configuration.PathDrawStepCount);
Expand All @@ -331,7 +333,7 @@ private void UiBuilderOnDraw()
if (index > 0)
drawList.AddLine(lastPos, action.Position, 0f, ImGui.GetColorU32(new Vector4(0.8f, 0.8f, 0.8f, alpha)));
if (index == this.Indexer)
drawList.AddLine(Player.Position, action.Position, 0, ImGui.GetColorU32(new Vector4(0f, 1f, 1f, 1f)));
drawList.AddLine(Player.Position, action.Position, 0, 0x00FFFFFF);

drawList.AddText(action.Position, ImGui.GetColorU32(new Vector4(alpha + 0.25f)), index.ToString(), 20f);
}
Expand Down
72 changes: 60 additions & 12 deletions AutoDuty/Windows/BuildTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@
using AutoDuty.Data;
using static AutoDuty.Windows.MainWindow;
using System.Diagnostics;
using Dalamud.Interface.Utility;
using Pictomancy;

namespace AutoDuty.Windows
{
using System.Globalization;
using Dalamud.Utility.Numerics;

internal static class BuildTab
{
internal static List<(string, string, string)>? ActionsList { get; set; }
Expand All @@ -29,7 +34,7 @@ internal static class BuildTab
private static string _actionText = string.Empty;
private static string _note = string.Empty;
private static Vector3 _position = Vector3.Zero;
private static string _positionText = string.Empty;
//private static string _positionText = string.Empty;
private static List<string> _arguments = [];
private static string _argumentsString = string.Empty;
private static string _argumentHint = string.Empty;
Expand All @@ -48,7 +53,7 @@ internal static class BuildTab
private static readonly ActionTag[] _actionTags = [ActionTag.None, ActionTag.Synced, ActionTag.Unsynced, ActionTag.W2W];
public static readonly JsonSerializerOptions jsonSerializerOptions = new() { WriteIndented = true, IgnoreReadOnlyProperties = true, IncludeFields = true };

internal unsafe static void Draw()
internal static unsafe void Draw()
{
SetCurrentTabName("BuildTab");
using (ImRaii.Disabled(Plugin.States.HasFlag(PluginState.Navigating) || Plugin.States.HasFlag(PluginState.Looping)))
Expand Down Expand Up @@ -159,7 +164,6 @@ private static void DrawButtons()
default:
break;
}
_positionText = _position.ToCustomString();
_argumentsString = _arguments.ToCustomString();
_action = new() { Name = _actionText, Position = _position, Arguments = _arguments, Note = _note, Tag = _actionTag };
_showAddActionUI = true;
Expand Down Expand Up @@ -247,7 +251,7 @@ private static void DrawButtons()
}
}

private unsafe static void DrawAddActionUIPopup()
private static unsafe void DrawAddActionUIPopup()
{
if (_action == null)
{
Expand Down Expand Up @@ -303,15 +307,24 @@ private unsafe static void DrawAddActionUIPopup()
ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X);
ImGui.InputTextWithHint("##Argument", _argumentHint, ref _argumentsString, 200);
}

using (ImRaii.Disabled(_comment))
{
if (ImGui.Button("Position:"))
_positionText = Player.Position.ToCustomString() == _positionText ? Vector3.Zero.ToCustomString() : Player.Position.ToCustomString();
_position = (_position - Player.Position).LengthSquared() <= 0.1f ? Vector3.Zero : Player.Position;

ImGui.SameLine();
ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X);
ImGui.InputText("##Position", ref _positionText, 200);
ImGui.PushItemWidth(145 * ImGuiHelpers.GlobalScale);
//ImGui.InputText("##Position", ref _positionText, 200);
ImGui.InputFloat("X##PositionX", ref _position.X, 0.1f, 1f);
ImGui.SameLine();
ImGui.InputFloat("Y##PositionY", ref _position.Y, 0.1f, 1f);
ImGui.SameLine();
ImGui.InputFloat("Z##PositionZ", ref _position.Z, 0.1f, 1f);


}

ImGui.Text("Note:");
ImGui.SameLine();
ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X);
Expand All @@ -337,6 +350,8 @@ private unsafe static void DrawAddActionUIPopup()
}
}

private static bool guide = false;

private static void DrawBuildList()
{
if (!ImGui.BeginListBox("##BuildList", new Vector2(ImGui.GetContentRegionAvail().X, ImGui.GetContentRegionAvail().Y))) return;
Expand Down Expand Up @@ -372,7 +387,7 @@ private static void DrawBuildList()
_arguments = item.Value.Arguments;
_argumentsString = item.Value.Arguments.ToCustomString();
_position = item.Value.Position;
_positionText = _position.ToCustomString();
//_positionText = _position.ToCustomString();
_buildListSelected = item.Index;
_showAddActionUI = true;
_dropdownSelected = ("", "", "");
Expand All @@ -391,7 +406,7 @@ private static void DrawBuildList()
if (ImGui.IsItemActive() && !ImGui.IsItemHovered() && !_dragDrop)
_buildListSelected = item.Index;

if (_buildListSelected == item.Index && ImGui.IsMouseDown(ImGuiMouseButton.Left))
if (_buildListSelected == item.Index && ImGui.IsMouseDown(ImGuiMouseButton.Left) && !_showAddActionUI)
{
float mouseYDelta = ImGui.GetMouseDragDelta(0).Y;

Expand Down Expand Up @@ -447,7 +462,6 @@ private static void ClearAll()
_actionText = string.Empty;
_note = string.Empty;
_position = Vector3.Zero;
_positionText = string.Empty;
_arguments = [];
_argumentHint = string.Empty;
_dropdownSelected = (string.Empty, string.Empty, string.Empty);
Expand All @@ -468,7 +482,7 @@ private static void AddAction()
_action.Name = _actionText;
_action.Arguments = [.. _argumentsString.Split(",", StringSplitOptions.TrimEntries)];
_action.Tag = _actionTag;
_action.Position = !_comment && _positionText.TryGetVector3(out var position) ? position : Vector3.Zero;
_action.Position = !_comment ? _position : Vector3.Zero;
_action.Note = _comment && !_note.StartsWith("<--") && !_note.EndsWith("-->") ? $"<-- {_note} -->" : _note;
if (_buildListSelected == -1)
{
Expand All @@ -480,5 +494,39 @@ private static void AddAction()
ImGui.CloseCurrentPopup();
ClearAll();
}

public static void DrawHelper(PctDrawList drawList)
{
if (_showAddActionUI && _position.LengthSquared() > 0.1f)
{
drawList.AddCircle(_position, 1.25f, 0xFFFFFFFF, thickness: 2);
drawList.AddText(_position + Vector3.UnitZ * 1.1f, 0xFFFFFFFF, "+Z", 5f);
drawList.AddText(_position + Vector3.UnitZ * -1.1f, 0xFFFFFFFF, "-Z", 5f);

drawList.AddText(_position + Vector3.UnitX * 1.1f, 0xFFFFFFFF, "+X", 5f);
drawList.AddText(_position + Vector3.UnitX * -1.1f, 0xFFFFFFFF, "-X", 5f);

if(PlayerHelper.IsValid)
{
float playerY = Player.Position.Y;
float ydiff = (_position.Y - playerY);
if (MathF.Abs(ydiff) > 0.1f)
{
drawList.AddText(_position + Vector3.UnitY * MathF.Sign(ydiff), 0xFFFFFFFF, "Y-Diff: " + ydiff.ToString("F3", CultureInfo.CurrentCulture), 5f);

drawList.PathLineTo(_position);
drawList.PathLineTo(_position.WithY(playerY));
drawList.PathStroke(0xFFFFFFFF);
}
}

drawList.PathLineTo(_position - Vector3.UnitX);
drawList.PathLineTo(_position + Vector3.UnitX);
drawList.PathStroke(0xFFFFFFFF);
drawList.PathLineTo(_position - Vector3.UnitZ);
drawList.PathLineTo(_position + Vector3.UnitZ);
drawList.PathStroke(0xFFFFFFFF);
}
}
}
}
10 changes: 5 additions & 5 deletions AutoDuty/Windows/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -441,13 +441,13 @@ public static void EzTabBar(string id, string? KoFiTransparent, string openTabNa
}
if (ImGuiEx.BeginTabItem(x.name, openTabName == x.name ? ImGuiTabItemFlags.SetSelected : ImGuiTabItemFlags.None))
{
if (x.color != null)
{
if (x.color != null)
ImGui.PopStyleColor();
}
if (x.child) ImGui.BeginChild(x.name + "child");
if (x.child)
ImGui.BeginChild(x.name + "child");
x.function();
if (x.child) ImGui.EndChild();
if (x.child)
ImGui.EndChild();
ImGui.EndTabItem();
}
else
Expand Down