Skip to content
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

Revert Interactable field for a different implementation in todo #554

Merged
merged 1 commit into from
Oct 7, 2024
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
3 changes: 1 addition & 2 deletions AutoDuty/AutoDuty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
using FFXIVClientStructs.FFXIV.Client.Game.UI;
using Serilog.Events;
using AutoDuty.Updater;
using System.Threading.Tasks;

namespace AutoDuty;

// TODO:
// Scrapped interable list, going to implement an internal list that when a interactable step end in fail, the Dataid gets add to the list and is scanned for from there on out, if found we goto it and get it, then remove from list.
// Need to expand AutoRepair to include check for level and stuff to see if you are eligible for self repair. and check for dark matter
// make config saving per character
// drap drop on build is jacked when theres scrolling
Expand Down Expand Up @@ -337,7 +337,6 @@ internal void LoadPath()

PathFile = path?.FilePath ?? "";
Actions = [.. path?.Actions];
Interactables = [.. path?.Interactables];
//Svc.Log.Info($"Loading Path: {CurrentPath} {ListBoxPOSText.Count}");
}
catch (Exception e)
Expand Down
3 changes: 0 additions & 3 deletions AutoDuty/Data/Classes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ public class PathFile
[JsonPropertyName("actions")]
public List<PathAction> Actions { get; set; } = [];

[JsonPropertyName("interactables")]
public uint[] Interactables { get; set; } = [];

[JsonPropertyName("meta")]
public PathFileMetaData Meta { get; set; } = new()
{
Expand Down
1 change: 0 additions & 1 deletion AutoDuty/Managers/ContentPathsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@ public PathFile PathFile
}

public List<PathAction> Actions => PathFile.Actions;
public uint[] Interactables => PathFile.Interactables;
public bool RevivalFound { get; private set; }
}
}
Expand Down
78 changes: 1 addition & 77 deletions AutoDuty/Windows/BuildTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ internal static class BuildTab
private static bool _scrollBottom = false;
private static string _changelog = string.Empty;
private static PathAction? _action = null;
private static HashSet<uint> _interactables = [];
private static string _actionText = string.Empty;
private static string _note = string.Empty;
private static Vector3 _position = Vector3.Zero;
Expand All @@ -41,8 +40,6 @@ internal static class BuildTab
private static bool _dragDrop = false;
private static bool _noArgument = false;
private static bool _comment = false;
private static int _interactableInput = 0;
private static int _interactableModify = -1;
private static Vector4 _argumentTextColor = new(1,1,1,1);
private static bool _deleteItem = false;
private static int _deleteItemIndex = -1;
Expand All @@ -61,7 +58,6 @@ internal unsafe static void Draw()
DrawSeperator();
DrawButtons();
DrawSeperator();
DrawInteractablesSet();
}
DrawBuildList();
}
Expand Down Expand Up @@ -219,7 +215,6 @@ private static void DrawButtons()
pathFile ??= new();

pathFile.Actions = [.. Plugin.Actions];
pathFile.Interactables = [.. _interactables];
string json = JsonSerializer.Serialize(pathFile, jsonSerializerOptions);
File.WriteAllText(Plugin.PathFile, json);
Plugin.CurrentPath = 0;
Expand Down Expand Up @@ -253,9 +248,7 @@ private unsafe static void DrawAddActionUIPopup()
{
if (ImGuiEx.ButtonWrapped(_addActionButton))
{
if (_action.Name == "Interactable" && !_addActionButton.Equals("Modify", StringComparison.InvariantCultureIgnoreCase))
ImGui.OpenPopup("InteractableAdd");
else if (_action.Name == "MoveToObject" || _action.Name == "Target")
if (_action.Name is "MoveToObject" or "Target" or "Interactable")
{
if (uint.TryParse(_arguments[0], out var dataId))
AddAction();
Expand All @@ -266,26 +259,6 @@ private unsafe static void DrawAddActionUIPopup()
AddAction();
}
}
if (ImGui.BeginPopup("InteractableAdd"))
{
if (ImGui.Selectable("Add to Path"))
{
if (uint.TryParse(_arguments[0], out var dataId))
AddAction();
else
ShowPopup("Error", "Interactable's must be uint's corresponding to the objects DataId", true);

}
if (ImGui.Selectable("Add to Special"))
{
if (uint.TryParse(_arguments[0], out var dataId))
_interactables.Add(dataId);
else
ShowPopup("Error", "Special interactable's must be uint's corresponding to the objects DataId", true);
}
ImGui.EndPopup();
}
DrawPopup(true);
ImGui.SameLine();
ImGuiEx.CheckboxWrapped("Dont Move", ref _dontMove);
ImGui.SameLine();
Expand Down Expand Up @@ -345,37 +318,6 @@ private unsafe static void DrawAddActionUIPopup()
}
}

private static void DrawInteractablesSet()
{
ImGui.TextWrapped("Special Interactables List:");
ImGuiComponents.HelpMarker("AutoDuty will attempt to interact with these objects under the following conditions:\n- The object exists in our ObjectTable\n- We are on or past the Interactable step in our path file for this object\n*Note* this should not be used for static GameObject's this is meant for those objects\nthat spawn in from an event such as killing some monsters");
if (!ImGui.BeginListBox("##InteractablesList", new Vector2(ImGui.GetContentRegionAvail().X, _interactables.Count > 0 ? ImGui.GetTextLineHeightWithSpacing() * _interactables.Count: ImGui.GetTextLineHeightWithSpacing() * (_interactables.Count + 1)))) return;

var removeItem = false;
var removeItemValue = 0u;

foreach (var item in _interactables.Select((Value, Index) => (Value, Index)))
{
ImGui.Selectable($"{item.Value}");
if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
{
Svc.Log.Info("Left");
_interactableModify = _interactableInput = (int)item.Value;
ImGui.OpenPopup("InputInteractable");
}
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
{
removeItem = true;
removeItemValue = item.Value;
}
}
InteractableInputPopup();
if (removeItem)
_interactables.Remove(removeItemValue);

ImGui.EndListBox();
}

private static void DrawBuildList()
{
if (!ImGui.BeginListBox("##BuildList", new Vector2(ImGui.GetContentRegionAvail().X, ImGui.GetContentRegionAvail().Y))) return;
Expand Down Expand Up @@ -457,24 +399,6 @@ private static void DrawBuildList()
ImGui.EndListBox();
}

private static void InteractableInputPopup()
{
if (ImGui.BeginPopup("InputInteractable"))
{
if (ImGui.Button(_interactableModify > -1 ? "Modify" : "Add"))
{
if (_interactableModify > -1)
_interactables.Remove((uint)_interactableModify);
_interactables.Add((uint)_interactableInput);
ImGui.CloseCurrentPopup();
}
ImGui.Text("Data Id:");
ImGui.SameLine();
ImGui.InputInt("##DataId", ref _interactableInput);
ImGui.EndPopup();
}
}

private static void ClearAll()
{
_actionText = string.Empty;
Expand Down