Skip to content

Commit

Permalink
Merge pull request #27 from FFXIV-CombatReborn/more-hotfixes
Browse files Browse the repository at this point in the history
More hotfixes
  • Loading branch information
NostraThomas99 authored Jun 1, 2024
2 parents 16a3402 + 4b345e7 commit 3600f6a
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 36 deletions.
5 changes: 2 additions & 3 deletions GatherBuddy/AutoGather/AutoGather.Movement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private void MoveToCloseNode()
CurrentDestination = NearestNode?.Position ?? null;
if (!Dalamud.Conditions[ConditionFlag.Mounted])
TaskManager.Enqueue(MountUp);
TaskManager.EnqueueDelay(1500);
TaskManager.EnqueueDelay(2500);
TaskManager.Enqueue(() => Navigate(ShouldFly));
TaskManager.Enqueue(WaitForDestination);
}
Expand Down Expand Up @@ -207,10 +207,9 @@ private void MoveToFarNode()
{
AutoStatus = "Moving to far node...";
CurrentDestination = farNode;
TaskManager.EnqueueDelay(500);
if (!Dalamud.Conditions[ConditionFlag.Mounted])
TaskManager.Enqueue(MountUp);
TaskManager.EnqueueDelay(1500);
TaskManager.EnqueueDelay(2500);
TaskManager.Enqueue(() => Navigate(ShouldFly));
TaskManager.Enqueue(WaitForDestination);
}
Expand Down
113 changes: 80 additions & 33 deletions GatherBuddy/Gui/Interface.ConfigTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,83 +57,125 @@ private static void DrawChatTypeSelector(string label, string description, XivCh
if (Widget.DrawChatTypeSelector(label, description, currentValue, setter))
GatherBuddy.Config.Save();
}

// Auto-Gather Config
public static void DrawAutoGatherBox()
=> DrawCheckbox("Enable Gathering Window Interaction (DISABLING THIS IS UNSUPPORTED)", "Toggle whether to automatically gather items. (Disable this for 'nav only mode')", GatherBuddy.Config.AutoGatherConfig.DoGathering, b => GatherBuddy.Config.AutoGatherConfig.DoGathering = b);
=> DrawCheckbox("Enable Gathering Window Interaction (DISABLING THIS IS UNSUPPORTED)",
"Toggle whether to automatically gather items. (Disable this for 'nav only mode')",
GatherBuddy.Config.AutoGatherConfig.DoGathering, b => GatherBuddy.Config.AutoGatherConfig.DoGathering = b);

public static void DrawMinimumGPGathering()
{
int tmp = (int)GatherBuddy.Config.AutoGatherConfig.MinimumGPForGathering;
ImGui.DragInt("Minimum GP for Gathering", ref tmp, 1, 0, 30000);
GatherBuddy.Config.AutoGatherConfig.MinimumGPForGathering = (uint)tmp;
if (ImGui.DragInt("Minimum GP for Gathering", ref tmp, 1, 0, 30000))
{
GatherBuddy.Config.AutoGatherConfig.MinimumGPForGathering = (uint)tmp;
GatherBuddy.Config.Save();
}
}

public static void DrawUseFlagBox()
=> DrawCheckbox("Disable flag navigation", "Whether or not to navigate to the flag on the map",
GatherBuddy.Config.AutoGatherConfig.DisableFlagPathing, b => GatherBuddy.Config.AutoGatherConfig.DisableFlagPathing = b);

public static void DrawFarNodeFilterDistance()
{
var tmp = GatherBuddy.Config.AutoGatherConfig.FarNodeFilterDistance;
ImGui.DragFloat("Far Node Filter Distance", ref tmp, 0.1f, 0.1f, 100f);
ImGuiUtil.HoverTooltip("When looking for non-empty nodes GBR will filter out any nodes that are closer to you than this. Prevents checking nodes you can already see are empty.");
GatherBuddy.Config.AutoGatherConfig.FarNodeFilterDistance = tmp;
if (ImGui.DragFloat("Far Node Filter Distance", ref tmp, 0.1f, 0.1f, 100f))
{
GatherBuddy.Config.AutoGatherConfig.FarNodeFilterDistance = tmp;
GatherBuddy.Config.Save();
}
ImGuiUtil.HoverTooltip(
"When looking for non-empty nodes GBR will filter out any nodes that are closer to you than this. Prevents checking nodes you can already see are empty.");
}

public static void DrawBYIIBox()
=> DrawCheckbox("Use BYII", "Toggle whether to use BYII for gathering.", GatherBuddy.Config.AutoGatherConfig.BYIIConfig.UseAction, b => GatherBuddy.Config.AutoGatherConfig.BYIIConfig.UseAction = b);
=> DrawCheckbox("Use BYII", "Toggle whether to use BYII for gathering.", GatherBuddy.Config.AutoGatherConfig.BYIIConfig.UseAction,
b => GatherBuddy.Config.AutoGatherConfig.BYIIConfig.UseAction = b);

public static void DrawBYIIMinGP()
{
int tmp = (int)GatherBuddy.Config.AutoGatherConfig.BYIIConfig.MinimumGP;
ImGui.DragInt("BYII Min GP", ref tmp, 1, 100, 30000);
GatherBuddy.Config.AutoGatherConfig.BYIIConfig.MinimumGP = (uint)tmp;
if (ImGui.DragInt("BYII Min GP", ref tmp, 1, 100, 30000))
{
GatherBuddy.Config.AutoGatherConfig.BYIIConfig.MinimumGP = (uint)tmp;
GatherBuddy.Config.Save();
}
}

public static void DrawBYIIMaxGP()
{
int tmp = (int)GatherBuddy.Config.AutoGatherConfig.BYIIConfig.MaximumGP;
ImGui.DragInt("BYII Max GP", ref tmp, 1, 100, 30000);
GatherBuddy.Config.AutoGatherConfig.BYIIConfig.MaximumGP = (uint)tmp;
if (ImGui.DragInt("BYII Max GP", ref tmp, 1, 100, 30000))
{
GatherBuddy.Config.AutoGatherConfig.BYIIConfig.MaximumGP = (uint)tmp;
GatherBuddy.Config.Save();
}
}

public static void DrawLuckBox()
=> DrawCheckbox("Use Luck", "Toggle whether to use Luck for gathering.", GatherBuddy.Config.AutoGatherConfig.LuckConfig.UseAction, b => GatherBuddy.Config.AutoGatherConfig.LuckConfig.UseAction = b);
=> DrawCheckbox("Use Luck", "Toggle whether to use Luck for gathering.", GatherBuddy.Config.AutoGatherConfig.LuckConfig.UseAction,
b => GatherBuddy.Config.AutoGatherConfig.LuckConfig.UseAction = b);

public static void DrawLuckMinGP()
{
int tmp = (int)GatherBuddy.Config.AutoGatherConfig.LuckConfig.MinimumGP;
ImGui.DragInt("Luck Min GP", ref tmp, 1, 200, 30000);
GatherBuddy.Config.AutoGatherConfig.LuckConfig.MinimumGP = (uint)tmp;
if (ImGui.DragInt("Luck Min GP", ref tmp, 1, 200, 30000))
{
GatherBuddy.Config.AutoGatherConfig.LuckConfig.MinimumGP = (uint)tmp;
GatherBuddy.Config.Save();
}
}

public static void DrawLuckMaxGP()
{
int tmp = (int)GatherBuddy.Config.AutoGatherConfig.LuckConfig.MaximumGP;
ImGui.DragInt("Luck Max GP", ref tmp, 1, 200, 30000);
GatherBuddy.Config.AutoGatherConfig.LuckConfig.MaximumGP = (uint)tmp;
if (ImGui.DragInt("Luck Max GP", ref tmp, 1, 200, 30000))
{
GatherBuddy.Config.AutoGatherConfig.LuckConfig.MaximumGP = (uint)tmp;
GatherBuddy.Config.Save();
}
}

public static void DrawMountUpDistance()
{
var tmp = GatherBuddy.Config.AutoGatherConfig.MountUpDistance;
ImGui.DragFloat("Mount Up Distance", ref tmp, 0.1f, 0.1f, 100f);
if (ImGui.DragFloat("Mount Up Distance", ref tmp, 0.1f, 0.1f, 100f))
{
GatherBuddy.Config.AutoGatherConfig.MountUpDistance = tmp;
GatherBuddy.Config.Save();
}
ImGuiUtil.HoverTooltip("The distance at which you will mount up to move to a node.");
GatherBuddy.Config.AutoGatherConfig.MountUpDistance = tmp;
}

public static void DrawAntiStuckCooldown()
{
var tmp = GatherBuddy.Config.AutoGatherConfig.NavResetCooldown;
ImGui.DragFloat("Anti-Stuck Cooldown", ref tmp, 0.1f, 0.1f, 10f);
if (ImGui.DragFloat("Anti-Stuck Cooldown", ref tmp, 0.1f, 0.1f, 10f))
{
GatherBuddy.Config.AutoGatherConfig.NavResetCooldown = tmp;
GatherBuddy.Config.Save();
}
ImGuiUtil.HoverTooltip("The time in seconds before the navigation system will reset if you are stuck.");
GatherBuddy.Config.AutoGatherConfig.NavResetCooldown = tmp;
}

public static void DrawForceWalkingBox()
=> DrawCheckbox("Force Walking", "Force walking to nodes instead of using mounts.", GatherBuddy.Config.AutoGatherConfig.ForceWalking, b => GatherBuddy.Config.AutoGatherConfig.ForceWalking = b);
=> DrawCheckbox("Force Walking", "Force walking to nodes instead of using mounts.",
GatherBuddy.Config.AutoGatherConfig.ForceWalking, b => GatherBuddy.Config.AutoGatherConfig.ForceWalking = b);

public static void DrawStuckThreshold()
{
var tmp = GatherBuddy.Config.AutoGatherConfig.NavResetThreshold;
ImGui.DragFloat("Stuck Threshold", ref tmp, 0.1f, 0.1f, 10f);
if (ImGui.DragFloat("Stuck Threshold", ref tmp, 0.1f, 0.1f, 10f))
{
GatherBuddy.Config.AutoGatherConfig.NavResetThreshold = tmp;
GatherBuddy.Config.Save();
}

ImGuiUtil.HoverTooltip("The time in seconds before the navigation system will consider you stuck.");
GatherBuddy.Config.AutoGatherConfig.NavResetThreshold = tmp;
}

// General Config
public static void DrawOpenOnStartBox()
=> DrawCheckbox("Open Config UI On Start",
Expand Down Expand Up @@ -247,7 +289,7 @@ public static void DrawContextMenuBox()

public static void DrawPreferredJobSelect()
{
var v = GatherBuddy.Config.PreferredGatheringType;
var v = GatherBuddy.Config.PreferredGatheringType;
var current = v == GatheringType.Multiple ? "No Preference" : v.ToString();
ImGui.SetNextItemWidth(SetInputWidth);
using var combo = ImRaii.Combo("Preferred Job", current);
Expand Down Expand Up @@ -300,12 +342,13 @@ public static void DrawAlarmToggle()
});

private static bool _gatherDebug = false;

public static void DrawAlarmsInDutyToggle()
=> DrawCheckbox("Enable Alarms in Duty", "Set whether alarms should trigger while you are bound by a duty.",
GatherBuddy.Config.AlarmsInDuty, b => GatherBuddy.Config.AlarmsInDuty = b);
GatherBuddy.Config.AlarmsInDuty, b => GatherBuddy.Config.AlarmsInDuty = b);

public static void DrawAlarmsOnlyWhenLoggedInToggle()
=> DrawCheckbox("Enable Alarms Only In-Game", "Set whether alarms should trigger while you are not logged into any character.",
=> DrawCheckbox("Enable Alarms Only In-Game", "Set whether alarms should trigger while you are not logged into any character.",
GatherBuddy.Config.AlarmsOnlyWhenLoggedIn, b => GatherBuddy.Config.AlarmsOnlyWhenLoggedIn = b);

private static void DrawAlarmPicker(string label, string description, Sounds current, Action<Sounds> setter)
Expand All @@ -319,11 +362,11 @@ private static void DrawAlarmPicker(string label, string description, Sounds cur

public static void DrawWeatherAlarmPicker()
=> DrawAlarmPicker("Weather Change Alarm", "Choose a sound that is played every 8 Eorzea hours on regular weather changes.",
GatherBuddy.Config.WeatherAlarm, _plugin.AlarmManager.SetWeatherAlarm);
GatherBuddy.Config.WeatherAlarm, _plugin.AlarmManager.SetWeatherAlarm);

public static void DrawHourAlarmPicker()
=> DrawAlarmPicker("Eorzea Hour Change Alarm", "Choose a sound that is played every time the current Eorzea hour changes.",
GatherBuddy.Config.HourAlarm, _plugin.AlarmManager.SetHourAlarm);
GatherBuddy.Config.HourAlarm, _plugin.AlarmManager.SetHourAlarm);

// Fish Timer
public static void DrawFishTimerBox()
Expand Down Expand Up @@ -551,7 +594,7 @@ public static void DrawGatherWindowDeleteModifierInput()

public static void DrawAetherytePreference()
{
var tmp = GatherBuddy.Config.AetherytePreference == AetherytePreference.Cost;
var tmp = GatherBuddy.Config.AetherytePreference == AetherytePreference.Cost;
var oldPref = GatherBuddy.Config.AetherytePreference;
if (ImGui.RadioButton("Prefer Cheaper Aetherytes", tmp))
GatherBuddy.Config.AetherytePreference = AetherytePreference.Cost;
Expand Down Expand Up @@ -587,7 +630,7 @@ public static void DrawIdentifiedGatherableFormatInput()

private void DrawConfigTab()
{
using var id = ImRaii.PushId("Config");
using var id = ImRaii.PushId("Config");
using var tab = ImRaii.TabItem("Config");
ImGuiUtil.HoverTooltip("Set up your very own GatherBuddy to your meticulous specifications.\n"
+ "If you treat him well, he might even become a real boy.");
Expand All @@ -608,6 +651,7 @@ private void DrawConfigTab()
ConfigFunctions.DrawMinimumGPGathering();
ImGui.TreePop();
}

if (ImGui.TreeNodeEx("Actions"))
{
if (ImGui.TreeNodeEx("Bountiful Yield"))
Expand All @@ -617,15 +661,18 @@ private void DrawConfigTab()
ConfigFunctions.DrawBYIIMaxGP();
ImGui.TreePop();
}

if (ImGui.TreeNodeEx("Luck"))
{
ConfigFunctions.DrawLuckBox();
ConfigFunctions.DrawLuckMinGP();
ConfigFunctions.DrawLuckMaxGP();
ImGui.TreePop();
}

ImGui.TreePop();
}

if (ImGui.TreeNodeEx("Advanced"))
{
ConfigFunctions.DrawAutoGatherBox();
Expand Down Expand Up @@ -656,9 +703,9 @@ private void DrawConfigTab()

if (ImGui.TreeNodeEx("Set Names"))
{
ConfigFunctions.DrawSetInput("Miner", GatherBuddy.Config.MinerSetName, s => GatherBuddy.Config.MinerSetName = s);
ConfigFunctions.DrawSetInput("Miner", GatherBuddy.Config.MinerSetName, s => GatherBuddy.Config.MinerSetName = s);
ConfigFunctions.DrawSetInput("Botanist", GatherBuddy.Config.BotanistSetName, s => GatherBuddy.Config.BotanistSetName = s);
ConfigFunctions.DrawSetInput("Fisher", GatherBuddy.Config.FisherSetName, s => GatherBuddy.Config.FisherSetName = s);
ConfigFunctions.DrawSetInput("Fisher", GatherBuddy.Config.FisherSetName, s => GatherBuddy.Config.FisherSetName = s);
ImGui.TreePop();
}

Expand Down
45 changes: 45 additions & 0 deletions GatherBuddy/Gui/Interface.GatherWindowTab.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text.RegularExpressions;
using Dalamud.Interface;
using Dalamud.Interface.Components;
using FFXIVClientStructs.FFXIV.Client.Game;
Expand Down Expand Up @@ -138,6 +141,48 @@ private void DrawGatherWindowPresetHeaderLine()
_plugin.AlarmManager.AddGroup(preset);
}

if (ImGuiUtil.DrawDisabledButton("Import from TeamCraft", Vector2.Zero, "Populate list from clipboard contents (TeamCraft format)",
_gatherWindowCache.Selector.Current == null))
{
var clipboardText = ImGuiUtil.GetClipboardText();
if (!string.IsNullOrEmpty(clipboardText))
{
try
{
Dictionary<string, int> items = new Dictionary<string, int>();

// Regex pattern
var pattern = @"\b(\d+)x\s(.+)\b";
var matches = Regex.Matches(clipboardText, pattern);

// Loop through matches and add them to dictionary
foreach (Match match in matches)
{
var quantity = int.Parse(match.Groups[1].Value);
var itemName = match.Groups[2].Value;
items[itemName] = quantity;
}

var preset = _gatherWindowCache.Selector.Current;

foreach (var item in items)
{
var gatherable =
GatherBuddy.GameData.Gatherables.Values.FirstOrDefault(g => g.Name[Dalamud.ClientState.ClientLanguage] == item.Key);
if (gatherable == null)
continue;

gatherable.Quantity = (uint)item.Value;
preset.Add(gatherable);
}
}
catch (Exception e)
{
Communicator.PrintClipboardMessage("Error importing gather window preset", e.ToString());
}
}
}

ImGuiComponents.HelpMarker(
"If not sorting the Gather Window by uptimes, items are uniquely added in order of enabled preset, then order of item in preset.\n"
+ "You can drag and draw presets in the list to move them.\n"
Expand Down

0 comments on commit 3600f6a

Please sign in to comment.