Skip to content

Commit

Permalink
more 7.1 updates
Browse files Browse the repository at this point in the history
updated memory sigs
fixed world fetching for hunt relays
changed plugin name
  • Loading branch information
Jaksuhn committed Nov 20, 2024
1 parent f62cd29 commit 699069c
Show file tree
Hide file tree
Showing 18 changed files with 255 additions and 228 deletions.
18 changes: 0 additions & 18 deletions Automaton.sln
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
TODO.txt = TODO.txt
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KamiToolKit", "KamiToolKit\KamiToolKit.csproj", "{AFDBE099-01B0-4CB6-96F1-8834A818C910}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoRetainerAPI", "AutoRetainerAPI\AutoRetainerAPI\AutoRetainerAPI.csproj", "{61FEA914-4DA7-4BB9-B665-D05D0E74377F}"
EndProject
Global
Expand Down Expand Up @@ -62,22 +60,6 @@ Global
{4A68DEED-4539-477E-87A2-32E30043FF0B}.Release|Any CPU.Build.0 = Release|x64
{4A68DEED-4539-477E-87A2-32E30043FF0B}.Release|x64.ActiveCfg = Release|x64
{4A68DEED-4539-477E-87A2-32E30043FF0B}.Release|x64.Build.0 = Release|x64
{AFDBE099-01B0-4CB6-96F1-8834A818C910}.Debug|Any CPU.ActiveCfg = Debug|x64
{AFDBE099-01B0-4CB6-96F1-8834A818C910}.Debug|Any CPU.Build.0 = Debug|x64
{AFDBE099-01B0-4CB6-96F1-8834A818C910}.Debug|x64.ActiveCfg = Debug|x64
{AFDBE099-01B0-4CB6-96F1-8834A818C910}.Debug|x64.Build.0 = Debug|x64
{AFDBE099-01B0-4CB6-96F1-8834A818C910}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|x64
{AFDBE099-01B0-4CB6-96F1-8834A818C910}.ExportDebug|Any CPU.Build.0 = ExportDebug|x64
{AFDBE099-01B0-4CB6-96F1-8834A818C910}.ExportDebug|x64.ActiveCfg = ExportDebug|x64
{AFDBE099-01B0-4CB6-96F1-8834A818C910}.ExportDebug|x64.Build.0 = ExportDebug|x64
{AFDBE099-01B0-4CB6-96F1-8834A818C910}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|x64
{AFDBE099-01B0-4CB6-96F1-8834A818C910}.ExportRelease|Any CPU.Build.0 = ExportRelease|x64
{AFDBE099-01B0-4CB6-96F1-8834A818C910}.ExportRelease|x64.ActiveCfg = ExportRelease|x64
{AFDBE099-01B0-4CB6-96F1-8834A818C910}.ExportRelease|x64.Build.0 = ExportRelease|x64
{AFDBE099-01B0-4CB6-96F1-8834A818C910}.Release|Any CPU.ActiveCfg = ExportRelease|x64
{AFDBE099-01B0-4CB6-96F1-8834A818C910}.Release|Any CPU.Build.0 = ExportRelease|x64
{AFDBE099-01B0-4CB6-96F1-8834A818C910}.Release|x64.ActiveCfg = ExportRelease|x64
{AFDBE099-01B0-4CB6-96F1-8834A818C910}.Release|x64.Build.0 = ExportRelease|x64
{61FEA914-4DA7-4BB9-B665-D05D0E74377F}.Debug|Any CPU.ActiveCfg = Debug|x64
{61FEA914-4DA7-4BB9-B665-D05D0E74377F}.Debug|Any CPU.Build.0 = Debug|x64
{61FEA914-4DA7-4BB9-B665-D05D0E74377F}.Debug|x64.ActiveCfg = Debug|x64
Expand Down
1 change: 0 additions & 1 deletion Automaton/Automaton.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@
<ItemGroup>
<ProjectReference Include="..\AutoRetainerAPI\AutoRetainerAPI\AutoRetainerAPI.csproj" />
<ProjectReference Include="..\ECommons\ECommons\ECommons.csproj" />
<ProjectReference Include="..\KamiToolKit\KamiToolKit.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Automaton/Automaton.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"Author": "croizat",
"Name": "Automaton",
"Name": "CBT (the plugin formerly known as Automaton)",
"Punchline": "Yet another tweaks collection plugin.",
"Description": "",
"InternalName": "Automaton",
Expand Down
2 changes: 1 addition & 1 deletion Automaton/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class TweakConfigs

public class YamlFactory : ISerializationFactory
{
public string DefaultConfigFileName => $"ez{Name}.yaml";
public string DefaultConfigFileName => $"ezAutomaton.yaml";

public T Deserialize<T>(string inputData)
{
Expand Down
4 changes: 2 additions & 2 deletions Automaton/Features/AchievementTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ public override void Disable()
{
P.Memory.ReceiveAchievementProgressHook.Disable();
Events.AchievementProgressUpdate -= OnAchievementProgressUpdate;
Utils.RemoveWindow<AchievementTrackerUI>();
EzConfigGui.RemoveWindow<AchievementTrackerUI>();
}

[CommandHandler("/atracker", "Toggle the Achievement Tracker window")]
private void OnCommand(string command, string arguments) => Utils.GetWindow<AchievementTrackerUI>()!.IsOpen ^= true;
private void OnCommand(string command, string arguments) => EzConfigGui.GetWindow<AchievementTrackerUI>()!.IsOpen ^= true;

private void OnAchievementProgressUpdate(uint id, uint current, uint max)
{
Expand Down
2 changes: 1 addition & 1 deletion Automaton/Features/DateWithDestiny.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public override void Disable()
}

[CommandHandler("/vfate", "Opens the FATE tracker")]
private void OnCommand(string command, string arguments) => Utils.GetWindow<FateTrackerUI>()!.IsOpen ^= true;
private void OnCommand(string command, string arguments) => EzConfigGui.GetWindow<FateTrackerUI>()!.IsOpen ^= true;

private unsafe void OnUpdate(IFramework framework)
{
Expand Down
15 changes: 8 additions & 7 deletions Automaton/Features/HuntRelayHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ public class HuntRelayHelperConfiguration
];
}

[Tweak]
[Tweak(outdated: true)]
public class HuntRelayHelper : Tweak<HuntRelayHelperConfiguration>
{
public override string Name => "Hunt Relay Helper";
public override string Description => "Appends a clickable icon to messages with a MapLinkPayload to relay them to other channels.";
public override string Description => "Appends a clickable icon to messages with a MapLinkPayload to relay them to other channels. THIS IS CURRENTLY BROKEN, AWAITING A FIX.";

private DalamudLinkPayload RelayLinkPayload = null!;
private readonly string InstanceHeuristics = @"\b(?:instance\s*(?<instanceNumber>\d+)|i(?<iNumber>\d+))\b";
Expand Down Expand Up @@ -211,10 +211,11 @@ private void OnChatMessage(XivChatType type, int timestamp, ref SeString sender,
.FirstOrDefault(Player.Object.CurrentWorld.Value);
break;
}
//Svc.Log.Debug($"Failed to detect world initially, relying on fallback. World is now {world.Value.Name}");
}
if (world != null)
if (world.HasValue)
{
Svc.Log.Verbose($"Detected world {world.Value.Name} and instance {instance} in {nameof(MapLinkPayload)} message: {message}");
//Svc.Log.Verbose($"Detected world {world.Value.Name} and instance {instance} in {nameof(MapLinkPayload)} message: {message}");
message.Payloads.AddRange([RelayLinkPayload, new IconPayload(BitmapFontIcon.NotoriousMonster), new RelayPayload(mlp, world.Value.RowId, instance, relayType, (uint)type).ToRawPayload(), RawPayload.LinkTerminator]);
}
else
Expand All @@ -223,7 +224,7 @@ private void OnChatMessage(XivChatType type, int timestamp, ref SeString sender,
}
catch (Exception ex)
{
Svc.Log.Error(ex.Message, ex);
Svc.Log.Error($"{nameof(HuntRelayHelper)}.{nameof(OnChatMessage)} {ex}", ex);
}
}

Expand Down Expand Up @@ -343,9 +344,9 @@ private Lumina.Text.SeStringBuilder BuildRelayMessage(MapLinkPayload MapLink, Wo
World? partial = null;
if (Config.AllowPartialWorldMatches)
foreach (var word in RemoveConflicts(text).Split(' ').Where(t => !ECommons.GenericHelpers.IsNullOrEmpty(t) && t.Length > 2))
partial ??= FindRow<World>(x => x!.IsPublic && x.DataCenter.Value!.Name == Player.CurrentDataCenter && x.Name.ToString().Contains(RemoveNonAlphaNumeric(word), StringComparison.OrdinalIgnoreCase));
partial ??= FindRow<World>(x => x.IsPublic && x.DataCenter.Value.Name == Player.CurrentDataCenter && x.Name.ExtractText().Contains(RemoveNonAlphaNumeric(word), StringComparison.OrdinalIgnoreCase));

return (partial ?? FindRow<World>(x => x!.IsPublic && RemoveConflicts(text).Contains(x.Name.ToString(), StringComparison.OrdinalIgnoreCase)) ?? null, heuristicInstance != 0 ? (uint)heuristicInstance : (uint)mapInstance, (uint)relayType);
return (partial ?? FindRow<World>(x => x.IsPublic && RemoveConflicts(text).Contains(x.Name.ExtractText(), StringComparison.OrdinalIgnoreCase)) ?? null, heuristicInstance != 0 ? (uint)heuristicInstance : (uint)mapInstance, (uint)relayType);
}

// I think this is the only case where an S rank has the name of a world contained within it
Expand Down
2 changes: 1 addition & 1 deletion Automaton/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
global using System.Collections.Generic;
global using System.Linq;
global using System.Numerics;
global using static Automaton.Automaton;
global using static Automaton.Plugin;
global using static Automaton.Utilities.Extensions;
global using ECommons.GameHelpers;
global using static ECommons.GenericHelpers;
Expand Down
16 changes: 7 additions & 9 deletions Automaton/Automaton.cs → Automaton/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,24 @@
using ECommons.Automation.LegacyTaskManager;
using ECommons.Configuration;
using ECommons.SimpleGui;
using FFXIVClientStructs.FFXIV.Client.Game;
using KamiToolKit;
using System.Collections.Specialized;
using System.Reflection;

namespace Automaton;

public class Automaton : IDalamudPlugin
public class Plugin : IDalamudPlugin
{
public static string Name => "Automaton";
private const string Command = "/automaton";
public static string Name => "CBT";
private const string Command = "/cbt";
private const string LegacyCommand = "/automaton";

internal static Automaton P = null!;
internal static Plugin P = null!;
private readonly Config Config;
public static Config C => P.Config;

public static readonly HashSet<Tweak> Tweaks = [];
internal TaskManager TaskManager;
internal NavmeshIPC Navmesh;
internal NativeController NativeController;
internal AddonObserver AddonObserver;
internal AutoRetainerApi AutoRetainerAPI;
internal LifestreamIPC Lifestream;
Expand All @@ -36,7 +34,7 @@ public class Automaton : IDalamudPlugin
internal bool UsingARPostProcess;
internal bool MemoryError;

public Automaton(IDalamudPluginInterface pluginInterface)
public Plugin(IDalamudPluginInterface pluginInterface)
{
P = this;
ECommonsMain.Init(pluginInterface, P, ECommons.Module.DalamudReflector, ECommons.Module.ObjectFunctions);
Expand All @@ -58,10 +56,10 @@ public Automaton(IDalamudPluginInterface pluginInterface)
Svc.Framework.Update += EventWatcher;

EzCmd.Add(Command, OnCommand, $"Opens the {Name} menu");
EzCmd.Add(LegacyCommand, OnCommand);
EzConfigGui.Init(new HaselWindow().Draw);
HaselWindow.SetWindowProperties();
EzConfigGui.WindowSystem.AddWindow(new DebugWindow());
NativeController = new NativeController(Svc.PluginInterface);
try
{
MemoryError = false;
Expand Down
47 changes: 0 additions & 47 deletions Automaton/UI/AchievementTrackerNative.cs

This file was deleted.

2 changes: 1 addition & 1 deletion Automaton/UI/AchievementTrackerUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using SheetAchievement = Lumina.Excel.Sheets.Achievement;

namespace Automaton.UI;
public unsafe class AchievementTrackerUI(AchievementTracker tweak) : Window($"Achievement Tracker##{Name}")
public unsafe class AchievementTrackerUI(AchievementTracker tweak) : Window($"Achievement Tracker##{nameof(AchievementTrackerUI)}")
{
private readonly AchievementTracker _tweak = tweak;
private SheetAchievement? selectedAchievement;
Expand Down
31 changes: 30 additions & 1 deletion Automaton/UI/DebugWindow.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
using Dalamud.Interface.Utility.Raii;
using Dalamud.Interface.Windowing;
using FFXIVClientStructs.FFXIV.Client.Game;
using ImGuiNET;

namespace Automaton.UI;

internal class DebugWindow : Window
{
public DebugWindow() : base($"{Name} - Debug {P.GetType().Assembly.GetName().Version}###{Name}{nameof(DebugWindow)}")
public DebugWindow() : base($"{Name} - Debug {P.GetType().Assembly.GetName().Version}###{nameof(DebugWindow)}")
{
SizeConstraints = new WindowSizeConstraints
{
Expand All @@ -17,7 +20,33 @@ public static void Dispose() { }

public override bool DrawConditions() => Player.Available;

private Utils.ExecuteCommandFlag flag;
private Utils.ExecuteCommandComplexFlag flag2;
private int ec1 = 0;
private int ec2 = 0;
private int ec3 = 0;
private int ec4 = 0;
private int ecc1 = 0;
private int ecc2 = 0;
private int ecc3 = 0;
private int ecc4 = 0;
public override unsafe void Draw()
{
ImGuiX.Enum("ExecuteCommand", ref flag);
ImGui.InputInt("p1", ref ec1);
ImGui.InputInt("p2", ref ec2);
ImGui.InputInt("p3", ref ec3);
ImGui.InputInt("p4", ref ec4);
if (ImGui.Button("exeucte"))
P.Memory.ExecuteCommand(flag, ec1, ec2, ec3, ec4);

using var id = ImRaii.PushId("complex");
ImGuiX.Enum("ExecuteCommandComplex", ref flag2);
ImGui.InputInt("p1", ref ecc1);
ImGui.InputInt("p2", ref ecc2);
ImGui.InputInt("p3", ref ecc3);
ImGui.InputInt("p4", ref ecc4);
if (ImGui.Button("exeucte"))
P.Memory.ExecuteCommandComplexLocation(flag2, Player.Position, ecc1, ecc2, ecc3, ecc4);
}
}
2 changes: 1 addition & 1 deletion Automaton/UI/FateTrackerUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using ImGuiNET;

namespace Automaton.UI;
internal class FateTrackerUI(DateWithDestiny tweak) : Window($"Fate Tracker##{Name}")
internal class FateTrackerUI(DateWithDestiny tweak) : Window($"Fate Tracker##{nameof(FateTrackerUI)}")
{
private readonly DateWithDestiny _tweak = tweak;
internal uint SelectedTerritory = 0;
Expand Down
25 changes: 25 additions & 0 deletions Automaton/Utilities/ImGuiX.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using ECommons.ImGuiMethods;
using FFXIVClientStructs.FFXIV.Client.Game;
using ImGuiNET;
using System.ComponentModel;
using System.Reflection;
using System.Threading.Tasks;

namespace Automaton.Utilities;
Expand Down Expand Up @@ -206,4 +208,27 @@ public static void FlashText(string text, Vector4 colour1, Vector4 colour2, floa
if (elapsedTime >= duration)
startTime = currentTime;
}

public static string EnumString(Enum v)
{
var name = v.ToString();
return v.GetType().GetField(name)?.GetCustomAttribute<DescriptionAttribute>()?.Description ?? name;
}

public static bool Enum<T>(string label, ref T v) where T : Enum
{
var res = false;
ImGui.SetNextItemWidth(200);
using var combo = ImRaii.Combo(label, EnumString(v));
if (!combo) return false;
foreach (var opt in System.Enum.GetValues(v.GetType()))
{
if (ImGui.Selectable(EnumString((Enum)opt), opt.Equals(v)))
{
v = (T)opt;
res = true;
}
}
return res;
}
}
Loading

0 comments on commit 699069c

Please sign in to comment.