diff --git a/AutoDuty/AutoDuty.cs b/AutoDuty/AutoDuty.cs index c2a3e2ef..1f5e8a9b 100644 --- a/AutoDuty/AutoDuty.cs +++ b/AutoDuty/AutoDuty.cs @@ -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); @@ -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); } diff --git a/AutoDuty/Windows/BuildTab.cs b/AutoDuty/Windows/BuildTab.cs index 09e29e62..3faff928 100644 --- a/AutoDuty/Windows/BuildTab.cs +++ b/AutoDuty/Windows/BuildTab.cs @@ -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; } @@ -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 _arguments = []; private static string _argumentsString = string.Empty; private static string _argumentHint = string.Empty; @@ -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))) @@ -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; @@ -247,7 +251,7 @@ private static void DrawButtons() } } - private unsafe static void DrawAddActionUIPopup() + private static unsafe void DrawAddActionUIPopup() { if (_action == null) { @@ -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); @@ -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; @@ -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 = ("", "", ""); @@ -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; @@ -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); @@ -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) { @@ -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); + } + } } } diff --git a/AutoDuty/Windows/MainWindow.cs b/AutoDuty/Windows/MainWindow.cs index 70f1da35..57e1b9ed 100644 --- a/AutoDuty/Windows/MainWindow.cs +++ b/AutoDuty/Windows/MainWindow.cs @@ -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