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

Improvements to Feather to the Metal #4

Merged
merged 1 commit into from
Oct 9, 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
2 changes: 2 additions & 0 deletions RebornToolbox/Features/ChocoboRacing/ChocoboRacing.UI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public override void Draw()
if (ImGui.Checkbox("Enable", ref enabled))
{
_chocoboRacing.IsRunning = enabled;
if (!enabled && _chocoboRacing.IsMoving)
_chocoboRacing.IsMoving = false;
}
var route = Plugin.Configuration.ChocoboRacingConfig.RaceRoute;
if (ImGuiUtil.GenericEnumCombo("Race Route", 150, route, out var newRoute, r => r.ToFriendlyString()))
Expand Down
16 changes: 14 additions & 2 deletions RebornToolbox/Features/ChocoboRacing/ChocoboRacing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,23 @@
using ECommons.Reflection;
using ECommons.Throttlers;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Game.UI;
using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using FFXIVClientStructs.FFXIV.Component.GUI;
using Lumina.Excel.GeneratedSheets;

namespace RebornToolbox.Features.ChocoboRacing;

public class ChocoboRacing
{
public bool IsRunning { get; set; } = false;

public IEnumerable<ContentRoulette> ContentRoulettes;

public ChocoboRacing()
{
ContentRoulettes = Svc.Data.GetExcelSheet<ContentRoulette>(Svc.ClientState.ClientLanguage)!;
Svc.Framework.Update += OnUpdate;
}

Expand Down Expand Up @@ -127,14 +132,21 @@ private unsafe void OnUpdate(IFramework framework)
}

var selectedDutyName = addon->AtkValues[18].GetValueAsString();
if (selectedDutyName.Contains(Plugin.Configuration.ChocoboRacingConfig.RaceRoute.ToFriendlyString(), StringComparison.OrdinalIgnoreCase))
if (selectedDutyName.Contains(GetSelectedDutyName(), StringComparison.InvariantCultureIgnoreCase))
{
Callback.Fire((AtkUnitBase*)addon, true, 12, 0);
}
}
}

// Credit: https://github.com/ffxivcode/AutoDuty/blob/26a61eefdba148bc5f46694f915f402315e9f128/AutoDuty/Helpers/QueueHelper.cs#L247
private string GetSelectedDutyName()
{
var routeId = (byte)Plugin.Configuration.ChocoboRacingConfig.RaceRoute;
var row = ContentRoulettes.First(c => c.RowId == routeId);
return row.Name.ToString();
}

// Credit: https://github.com/ffxivcode/AutoDuty/blob/26a61eefdba148bc5f46694f915f402315e9f128/AutoDuty/Helpers/QueueHelper.cs#L247
private uint HeadersCount(uint before, List<AtkComponentTreeListItem> list)
{
uint count = 0;
Expand Down