Skip to content

Commit

Permalink
API9 Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Taurenkey committed Sep 29, 2023
1 parent f69c839 commit d596165
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 35 deletions.
3 changes: 2 additions & 1 deletion XIVSlothCombo/Combos/JobHelpers/AST.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Dalamud.Game;
using Dalamud.Game.ClientState.JobGauge.Enums;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Plugin.Services;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -20,7 +21,7 @@ internal static void Init()
Service.Framework.Update += CheckCards;
}

private static void CheckCards(Framework framework)
private static void CheckCards(IFramework framework)
{
if (Service.ClientState.LocalPlayer is null || Service.ClientState.LocalPlayer.ClassJob.Id != 33)
return;
Expand Down
4 changes: 2 additions & 2 deletions XIVSlothCombo/Core/IconReplacer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public IconReplacer()
.OrderByDescending(x => x.Preset)
.ToList();

getIconHook = Hook<GetIconDelegate>.FromAddress(Service.Address.GetAdjustedActionId, GetIconDetour);
isIconReplaceableHook = Hook<IsIconReplaceableDelegate>.FromAddress(Service.Address.IsActionIdReplaceable, IsIconReplaceableDetour);
getIconHook = Service.GameInteropProvider.HookFromAddress<GetIconDelegate>(Service.Address.GetAdjustedActionId, GetIconDetour);
isIconReplaceableHook = Service.GameInteropProvider.HookFromAddress<IsIconReplaceableDelegate>(Service.Address.IsActionIdReplaceable, IsIconReplaceableDetour);

getIconHook.Enable();
isIconReplaceableHook.Enable();
Expand Down
4 changes: 2 additions & 2 deletions XIVSlothCombo/Core/PluginAddressResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace XIVSlothCombo.Core
{
/// <summary> Plugin address resolver. </summary>
internal class PluginAddressResolver : BaseAddressResolver
internal class PluginAddressResolver
{
/// <summary> Gets the address of the member ComboTimer. </summary>
public IntPtr ComboTimer { get; private set; }
Expand All @@ -21,7 +21,7 @@ internal class PluginAddressResolver : BaseAddressResolver
public IntPtr IsActionIdReplaceable { get; private set; }

/// <inheritdoc/>
protected unsafe override void Setup64Bit(SigScanner scanner)
public unsafe void Setup(ISigScanner scanner)
{
ComboTimer = new IntPtr(&ActionManager.Instance()->Combo.Timer);

Expand Down
3 changes: 2 additions & 1 deletion XIVSlothCombo/CustomCombo/Functions/Party.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Linq;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Game.ClientState.Party;
using Dalamud.Plugin.Services;
using XIVSlothCombo.Services;

namespace XIVSlothCombo.CustomComboNS.Functions
Expand All @@ -12,7 +13,7 @@ internal abstract partial class CustomComboFunctions

/// <summary> Gets the party list </summary>
/// <returns> Current party list. </returns>
public static PartyList GetPartyMembers() => Service.PartyList;
public static IPartyList GetPartyMembers() => Service.PartyList;

public unsafe static GameObject? GetPartySlot(int slot)
{
Expand Down
4 changes: 2 additions & 2 deletions XIVSlothCombo/CustomCombo/Functions/PlayerCharacter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ internal abstract partial class CustomComboFunctions

/// <summary> Find if the player has a pet present. </summary>
/// <returns> A value indicating whether the player has a pet (fairy/carbuncle) present. </returns>
public static bool HasPetPresent() => Service.BuddyList.PetBuddyPresent;
public static bool HasPetPresent() => Service.BuddyList.PetBuddy != null;

/// <summary> Find if the player has a companion (chocobo) present. </summary>
/// <returns> A value indicating whether the player has a companion (chocobo). </returns>
public static bool HasCompanionPresent() => Service.BuddyList.CompanionBuddyPresent;
public static bool HasCompanionPresent() => Service.BuddyList.CompanionBuddy != null;

/// <summary> Checks if the player is in a PVP enabled zone. </summary>
/// <returns> A value indicating whether the player is in a PVP enabled zone. </returns>
Expand Down
2 changes: 1 addition & 1 deletion XIVSlothCombo/CustomCombo/Functions/Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public static bool HasFriendlyTarget(GameObject? OurTarget = null)
public static unsafe GameObject? GetHealTarget(bool checkMOPartyUI = false, bool restrictToMouseover = false)
{
GameObject? healTarget = null;
TargetManager tm = Service.TargetManager;
ITargetManager tm = Service.TargetManager;

if (HasFriendlyTarget(tm.SoftTarget)) healTarget = tm.SoftTarget;
if (healTarget is null && HasFriendlyTarget(CurrentTarget) && !restrictToMouseover) healTarget = CurrentTarget;
Expand Down
4 changes: 2 additions & 2 deletions XIVSlothCombo/Data/ActionWatching.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ public static void Dispose()

static unsafe ActionWatching()
{
ReceiveActionEffectHook ??= Hook<ReceiveActionEffectDelegate>.FromAddress(Service.SigScanner.ScanText("E8 ?? ?? ?? ?? 48 8B 8D F0 03 00 00"), ReceiveActionEffectDetour);
SendActionHook ??= Hook<SendActionDelegate>.FromAddress(Service.SigScanner.ScanText("E8 ?? ?? ?? ?? E9 ?? ?? ?? ?? F3 0F 10 3D ?? ?? ?? ?? 48 8D 4D BF"), SendActionDetour);
ReceiveActionEffectHook ??= Service.GameInteropProvider.HookFromSignature<ReceiveActionEffectDelegate>("E8 ?? ?? ?? ?? 48 8B 8D F0 03 00 00", ReceiveActionEffectDetour);
SendActionHook ??= Service.GameInteropProvider.HookFromSignature<SendActionDelegate>("E8 ?? ?? ?? ?? E9 ?? ?? ?? ?? F3 0F 10 3D ?? ?? ?? ?? 48 8D 4D BF", SendActionDetour);
}


Expand Down
3 changes: 2 additions & 1 deletion XIVSlothCombo/Data/CustomComboCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using DalamudStatus = Dalamud.Game.ClientState.Statuses; // conflicts with structs if not defined
using FFXIVClientStructs.FFXIV.Client.Game;
using XIVSlothCombo.Services;
using Dalamud.Plugin.Services;

namespace XIVSlothCombo.Data
{
Expand Down Expand Up @@ -148,7 +149,7 @@ private byte GetCooldownGroup(uint actionID)
}

/// <summary> Triggers when the game framework updates. Clears cooldown and status caches. </summary>
private unsafe void Framework_Update(Framework framework)
private unsafe void Framework_Update(IFramework framework)
{
statusCache.Clear();
cooldownCache.Clear();
Expand Down
30 changes: 17 additions & 13 deletions XIVSlothCombo/Services/Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Dalamud.Game.Gui;
using Dalamud.IoC;
using Dalamud.Plugin;
using Dalamud.Plugin.Services;
using XIVSlothCombo.Core;
using XIVSlothCombo.Data;

Expand All @@ -26,44 +27,44 @@ internal class Service

/// <summary> Gets the Dalamud buddy list. </summary>
[PluginService]
internal static BuddyList BuddyList { get; private set; } = null!;
internal static IBuddyList BuddyList { get; private set; } = null!;

/// <summary> Gets the Dalamud chat gui. </summary>
[PluginService]
internal static ChatGui ChatGui { get; private set; } = null!;
internal static IChatGui ChatGui { get; private set; } = null!;

/// <summary> Facilitates class-based locking. </summary>
internal static bool ClassLocked { get; set; } = true;

/// <summary> Gets the Dalamud client state. </summary>
[PluginService]
internal static ClientState ClientState { get; private set; } = null!;
internal static IClientState ClientState { get; private set; } = null!;

/// <summary> Gets or sets the plugin caching mechanism. </summary>
internal static CustomComboCache ComboCache { get; set; } = null!;

/// <summary> Gets the Dalamud command manager. </summary>
[PluginService]
internal static CommandManager CommandManager { get; private set; } = null!;
internal static ICommandManager CommandManager { get; private set; } = null!;

/// <summary> Gets the Dalamud condition. </summary>
[PluginService]
internal static Condition Condition { get; private set; } = null!;
internal static ICondition Condition { get; private set; } = null!;

/// <summary> Gets or sets the plugin configuration. </summary>
internal static PluginConfiguration Configuration { get; set; } = null!;

/// <summary> Gets the Dalamud data manager. </summary>
[PluginService]
internal static DataManager DataManager { get; private set; } = null!;
internal static IDataManager DataManager { get; private set; } = null!;

/// <summary> Gets the Dalamud framework manager. </summary>
[PluginService]
internal static Framework Framework { get; private set; } = null!;
internal static IFramework Framework { get; private set; } = null!;

/// <summary> Handles the in-game UI. </summary>
[PluginService]
internal static GameGui GameGui { get; private set; } = null!;
internal static IGameGui GameGui { get; private set; } = null!;

/// <summary> Gets or sets the plugin icon replacer. </summary>
internal static IconReplacer IconReplacer { get; set; } = null!;
Expand All @@ -74,11 +75,11 @@ internal class Service

/// <summary> Gets the Dalamud job gauges. </summary>
[PluginService]
internal static JobGauges JobGauges { get; private set; } = null!;
internal static IJobGauges JobGauges { get; private set; } = null!;

/// <summary> Gets the Dalamud object table. </summary>
[PluginService]
internal static ObjectTable ObjectTable { get; private set; } = null!;
internal static IObjectTable ObjectTable { get; private set; } = null!;

/// <summary> Returns the Plugin Folder location </summary>
public static string PluginFolder
Expand All @@ -94,14 +95,17 @@ public static string PluginFolder

/// <summary> Gets the Dalamud party list. </summary>
[PluginService]
internal static PartyList PartyList { get; private set; } = null!;
internal static IPartyList PartyList { get; private set; } = null!;

/// <summary> Facilitates searching for memory signatures. </summary>
[PluginService]
internal static SigScanner SigScanner { get; private set; } = null!;
internal static ISigScanner SigScanner { get; private set; } = null!;

/// <summary> Gets the Dalamud target manager. </summary>
[PluginService]
internal static TargetManager TargetManager { get; private set; } = null!;
internal static ITargetManager TargetManager { get; private set; } = null!;

[PluginService]
internal static IGameInteropProvider GameInteropProvider { get; private set; } = null!;
}
}
3 changes: 2 additions & 1 deletion XIVSlothCombo/Window/ConfigWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Numerics;
using System.Runtime.InteropServices;
using Dalamud.Interface;
using Dalamud.Interface.Utility;
using Dalamud.Plugin;
using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Client.UI;
Expand Down Expand Up @@ -124,7 +125,7 @@ public void DrawConfig()

if (ImGui.BeginTabItem("About XIVSlothCombo / Report an Issue"))
{
AboutUs.Draw(Plugin);
AboutUs.Draw();
ImGui.EndTabItem();
}

Expand Down
1 change: 1 addition & 0 deletions XIVSlothCombo/Window/InfoBox.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Numerics;
using Dalamud.Interface;
using Dalamud.Interface.Utility;
using ImGuiNET;

namespace XIVSlothCombo.Window
Expand Down
9 changes: 6 additions & 3 deletions XIVSlothCombo/Window/Tabs/AboutUs.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Dalamud.Interface;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Utility;
using Dalamud.Plugin;
using Dalamud.Utility;
using ECommons.ImGuiMethods;
Expand All @@ -8,6 +9,8 @@
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Reflection;
using XIVSlothCombo.Services;

namespace XIVSlothCombo.Window.Tabs
{
Expand All @@ -16,17 +19,17 @@ internal class AboutUs : ConfigWindow
public static Version version = null!;

private static Dictionary<string, TextureWrap> Images = new();
internal static void Draw(IDalamudPlugin P)
internal static void Draw()
{
version ??= P.GetType().Assembly.GetName().Version!;
version ??= Assembly.GetExecutingAssembly().GetName().Version!;

PvEFeatures.HasToOpenJob = true;

ImGui.BeginChild("About", new Vector2(0, 0), true);

ImGuiEx.ImGuiLineCentered("Header", delegate
{
ImGuiEx.TextUnderlined($"{P.Name} - v{version}");
ImGuiEx.TextUnderlined($"XIVSlothCombo - v{version}");
});

ImGuiEx.ImGuiLineCentered("AboutHeader", delegate
Expand Down
1 change: 1 addition & 0 deletions XIVSlothCombo/Window/Tabs/PvEFeatures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using XIVSlothCombo.Services;
using XIVSlothCombo.Window.Functions;
using XIVSlothCombo.Window.MessagesNS;
using Dalamud.Interface.Utility;

namespace XIVSlothCombo.Window.Tabs
{
Expand Down
1 change: 1 addition & 0 deletions XIVSlothCombo/Window/Tabs/PvPFeatures.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Linq;
using System.Numerics;
using Dalamud.Interface;
using Dalamud.Interface.Utility;
using ImGuiNET;
using XIVSlothCombo.Core;
using XIVSlothCombo.Services;
Expand Down
12 changes: 7 additions & 5 deletions XIVSlothCombo/XIVSlothCombo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using XIVSlothCombo.Window;
using XIVSlothCombo.Window.Tabs;
using ECommons;
using Dalamud.Plugin.Services;

namespace XIVSlothCombo
{
Expand All @@ -29,6 +30,7 @@ public sealed partial class XIVSlothCombo : IDalamudPlugin
private const string Command = "/scombo";

private readonly ConfigWindow configWindow;
private HttpClient httpClient = new();

private readonly TextPayload starterMotd = new("[Sloth Message of the Day] ");
private static uint? jobID;
Expand All @@ -55,7 +57,7 @@ public XIVSlothCombo(DalamudPluginInterface pluginInterface)

Service.Configuration = pluginInterface.GetPluginConfig() as PluginConfiguration ?? new PluginConfiguration();
Service.Address = new PluginAddressResolver();
Service.Address.Setup();
Service.Address.Setup(Service.SigScanner);

if (Service.Configuration.Version == 4)
UpgradeConfig4();
Expand Down Expand Up @@ -85,7 +87,7 @@ public XIVSlothCombo(DalamudPluginInterface pluginInterface)
KillRedundantIDs();
}

private static void CheckCurrentJob(Framework framework)
private static void CheckCurrentJob(IFramework framework)
{
JobID = Service.ClientState.LocalPlayer?.ClassJob?.Id;
}
Expand Down Expand Up @@ -114,7 +116,7 @@ private static void ResetFeatures()

private void DrawUI() => configWindow.Draw();

private void PrintLoginMessage(object? sender, EventArgs e)
private void PrintLoginMessage()
{
Task.Delay(TimeSpan.FromSeconds(5)).ContinueWith(task => ResetFeatures());

Expand All @@ -126,7 +128,7 @@ private void PrintMotD()
{
try
{
using HttpResponseMessage? motd = Dalamud.Utility.Util.HttpClient.GetAsync("https://raw.githubusercontent.com/Nik-Potokar/XIVSlothCombo/main/res/motd.txt").Result;
using HttpResponseMessage? motd = httpClient.GetAsync("https://raw.githubusercontent.com/Nik-Potokar/XIVSlothCombo/main/res/motd.txt").Result;
motd.EnsureSuccessStatusCode();
string? data = motd.Content.ReadAsStringAsync().Result;
List<Payload>? payloads = new()
Expand All @@ -137,7 +139,7 @@ private void PrintMotD()
EmphasisItalicPayload.ItalicsOff
};

Service.ChatGui.PrintChat(new XivChatEntry
Service.ChatGui.Print(new XivChatEntry
{
Message = new SeString(payloads),
Type = XivChatType.Echo
Expand Down
2 changes: 1 addition & 1 deletion XIVSlothCombo/XIVSlothCombo.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"Author": "Team Sloth",
"Name": "XIVSlothCombo",
"InternalName": "XIVSlothCombo",
"DalamudApiLevel": 8,
"DalamudApiLevel": 9,
"Punchline": "Condenses combos and mutually exclusive abilities onto a single button - and then some.",
"Description": "Condenses combos and mutually exclusive abilities onto a single button - and then some.",
"RepoUrl": "https://github.com/Nik-Potokar/XIVSlothCombo",
Expand Down

0 comments on commit d596165

Please sign in to comment.