Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Commit

Permalink
API9 and 6.5 Compat
Browse files Browse the repository at this point in the history
  • Loading branch information
StoiaCode committed Oct 4, 2023
1 parent 1bbe296 commit ad34b07
Show file tree
Hide file tree
Showing 18 changed files with 64 additions and 39 deletions.
5 changes: 3 additions & 2 deletions CustomizePlus/Api/CustomizePlusIpc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Text;
using CustomizePlus.Data;
using CustomizePlus.Data.Profile;
using Dalamud.Plugin.Services;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Logging;
Expand All @@ -24,7 +25,7 @@ public class CustomizePlusIpc : IDisposable
public const string RevertCharacterLabel = $"CustomizePlus.{nameof(RevertCharacter)}";
public const string OnProfileUpdateLabel = $"CustomizePlus.{nameof(OnProfileUpdate)}";
public static readonly (int, int) ApiVersion = (3, 0);
private readonly ObjectTable _objectTable;
private readonly IObjectTable _objectTable;
private readonly DalamudPluginInterface _pluginInterface;


Expand All @@ -36,7 +37,7 @@ public class CustomizePlusIpc : IDisposable
internal ICallGateProvider<Character?, string?>? ProviderGetProfileFromCharacter;
internal ICallGateProvider<(int, int)>? ProviderGetApiVersion;

public CustomizePlusIpc(ObjectTable objectTable, DalamudPluginInterface pluginInterface)
public CustomizePlusIpc(IObjectTable objectTable, DalamudPluginInterface pluginInterface)
{
_objectTable = objectTable;
_pluginInterface = pluginInterface;
Expand Down
6 changes: 3 additions & 3 deletions CustomizePlus/CustomizePlus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PropertyGroup>
<Authors></Authors>
<Company></Company>
<Version>1.2.5.6</Version>
<Version>1.2.5.7</Version>
<Description>CustomizePlus</Description>
<Copyright></Copyright>
<PackageProjectUrl>https://github.com/XIV-Tools/CustomizePlus</PackageProjectUrl>
Expand Down Expand Up @@ -41,8 +41,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.10" />
<PackageReference Include="Penumbra.String" Version="1.0.3" />
<PackageReference Include="DalamudPackager" Version="2.1.12" />
<PackageReference Include="Penumbra.String" Version="1.0.4" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
1 change: 1 addition & 0 deletions CustomizePlus/Data/Armature/Armature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Dalamud.Game.ClientState.Objects.Types;
using FFXIVClientStructs.Havok;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.ToolTip;
using CustomizePlus.Services;

namespace CustomizePlus.Data.Armature
{
Expand Down
1 change: 1 addition & 0 deletions CustomizePlus/Data/Armature/ArmatureManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Linq;
using CustomizePlus.Data.Profile;
using CustomizePlus.Services;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Logging;

Expand Down
1 change: 1 addition & 0 deletions CustomizePlus/Data/Configuration/ConfigurationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using CustomizePlus.Data.Configuration.Version0;
using CustomizePlus.Data.Configuration.Version2;
using CustomizePlus.Helpers;
using CustomizePlus.Services;
using Dalamud.Logging;
using Newtonsoft.Json;

Expand Down
8 changes: 5 additions & 3 deletions CustomizePlus/Data/Files.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using CustomizePlus.Services;
using Dalamud.Interface.Internal;
using ImGuiScene;

namespace CustomizePlus.Data
{
public static class Files
{
private static readonly List<IDisposable> LoadedResources = new();
private static readonly Dictionary<string, TextureWrap> TextureCache = new();
private static readonly Dictionary<string, IDalamudTextureWrap> TextureCache = new();

public static TextureWrap Icon => LoadImage("icon.png");
public static IDalamudTextureWrap Icon => LoadImage("icon.png");

public static void Dispose()
{
Expand All @@ -26,7 +28,7 @@ public static void Dispose()
LoadedResources.Clear();
}

private static TextureWrap LoadImage(string file)
private static IDalamudTextureWrap LoadImage(string file)
{
if (TextureCache.TryGetValue(file, out var image))
return image;
Expand Down
1 change: 1 addition & 0 deletions CustomizePlus/Data/Profile/ProfileReaderWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using CustomizePlus.Helpers;
using Dalamud.Logging;
using Newtonsoft.Json;
using CustomizePlus.Services;

namespace CustomizePlus.Data.Profile
{
Expand Down
4 changes: 3 additions & 1 deletion CustomizePlus/Extensions/CommandManagerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
// Licensed under the MIT license.

using System.Collections.Generic;
using CustomizePlus.Services;
using Dalamud.Game.Command;
using Dalamud.Plugin.Services;

namespace CustomizePlus.Extensions
{
public static class CommandManagerExtensions
{
private static readonly List<string> BoundCommands = new();

public static void AddCommand(this CommandManager self, CommandInfo.HandlerDelegate handler, string command,
public static void AddCommand(this ICommandManager self, CommandInfo.HandlerDelegate handler, string command,
string help)
{
var info = new CommandInfo(handler)
Expand Down
6 changes: 4 additions & 2 deletions CustomizePlus/Extensions/ObjectTableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dalamud.Plugin.Services;
using CustomizePlus.Services;

namespace CustomizePlus.Extensions
{
Expand All @@ -19,7 +21,7 @@ public static class ObjectTableExtensions
/// <param name="objectTable"></param>
/// <param name="includeSelf">Whether or not to include the local player.</param>
/// <returns>An <see cref="IEnumerable{T}" /> of <see cref="PlayerCharacter" />s.</returns>
public static IEnumerable<PlayerCharacter> GetPlayerCharacters(this ObjectTable objectTable, bool includeSelf = true) => objectTable
public static IEnumerable<PlayerCharacter> GetPlayerCharacters(this IObjectTable objectTable, bool includeSelf = true) => objectTable
.Where(x => x is PlayerCharacter).Cast<PlayerCharacter>()
.Where(x => includeSelf || x.ObjectId != DalamudServices.ClientState.LocalPlayer?.ObjectId)
.Where(x => x.ObjectId > 240);
Expand All @@ -29,7 +31,7 @@ public static IEnumerable<PlayerCharacter> GetPlayerCharacters(this ObjectTable
/// </summary>
/// <param name="objectTable"></param>
/// <returns></returns>
public static IEnumerable<PlayerCharacter> GetPlayerOwnedCharacters(this ObjectTable objectTable) => objectTable
public static IEnumerable<PlayerCharacter> GetPlayerOwnedCharacters(this IObjectTable objectTable) => objectTable
.Where(x => x is PlayerCharacter).Cast<PlayerCharacter>()
.Where(x => x.ObjectId == DalamudServices.ClientState.LocalPlayer?.ObjectId || x.ObjectId == 200 || x.ObjectId == 201 || x.OwnerId == DalamudServices.ClientState.LocalPlayer?.ObjectId)
.Where(x => x.ObjectId > 240);
Expand Down
1 change: 1 addition & 0 deletions CustomizePlus/Helpers/ChatHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// © Customize+.
// Licensed under the MIT license.

using CustomizePlus.Services;
using Dalamud.Game.Text.SeStringHandling;

namespace CustomizePlus.Helpers
Expand Down
1 change: 1 addition & 0 deletions CustomizePlus/Helpers/GameDataHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Xml.Linq;

using CustomizePlus.Data.Profile;
using CustomizePlus.Services;
using Dalamud.Game.ClientState.Objects.Enums;
using Dalamud.Logging;
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
Expand Down
9 changes: 4 additions & 5 deletions CustomizePlus/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using Dalamud.Hooking;
using Dalamud.Logging;
using Dalamud.Plugin;
using Dalamud.Plugin.Services;
using Newtonsoft.Json;

namespace CustomizePlus
Expand All @@ -47,7 +48,6 @@ public sealed class Plugin : IDalamudPlugin
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate void GameObjectMovementDelegate(IntPtr gameObject);


public Plugin(DalamudPluginInterface pluginInterface)
{
try
Expand Down Expand Up @@ -127,15 +127,14 @@ public static void ReloadHooks()
if (_renderManagerHook == null)
{
var renderAddress = DalamudServices.SigScanner.ScanText(Constants.RenderHookAddress);
_renderManagerHook = Hook<RenderDelegate>.FromAddress(renderAddress, OnRender);
_renderManagerHook = DalamudServices.Hooker.HookFromAddress<RenderDelegate>(renderAddress, OnRender);
PluginLog.Debug("Render hook established");
}

if (_gameObjectMovementHook == null)
{
var movementAddress = DalamudServices.SigScanner.ScanText(Constants.MovementHookAddress);
_gameObjectMovementHook =
Hook<GameObjectMovementDelegate>.FromAddress(movementAddress, OnGameObjectMove);
_gameObjectMovementHook = DalamudServices.Hooker.HookFromAddress<GameObjectMovementDelegate>(movementAddress, OnGameObjectMove);
PluginLog.Debug("Movement hook established");
}

Expand Down Expand Up @@ -164,7 +163,7 @@ public static void ReloadHooks()
}
}

private static void Framework_Update(Framework framework)
private static void Framework_Update(IFramework framework)
{
ServiceManager.Tick();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,48 @@
using Dalamud.Game.Gui;
using Dalamud.IoC;
using Dalamud.Plugin;
using Dalamud.Plugin.Services;

namespace CustomizePlus
namespace CustomizePlus.Services
{
public class DalamudServices
{
[PluginService] public static Framework Framework { get; private set; } = null!;


[PluginService]
[RequiredVersion("1.0")]
public static ObjectTable ObjectTable { get; private set; } = null!;
public static DalamudPluginInterface PluginInterface { get; private set; } = null!;

[PluginService]
[RequiredVersion("1.0")]
public static DalamudPluginInterface PluginInterface { get; private set; } = null!;
public static ISigScanner SigScanner { get; private set; } = null!;

[PluginService]
public static IFramework Framework { get; private set; } = null!;

[PluginService]
[RequiredVersion("1.0")]
public static IObjectTable ObjectTable { get; private set; } = null!;

[PluginService]
[RequiredVersion("1.0")]
public static CommandManager CommandManager { get; private set; } = null!;
public static ICommandManager CommandManager { get; private set; } = null!;

[PluginService]
[RequiredVersion("1.0")]
public static ChatGui ChatGui { get; private set; } = null!;
public static IChatGui ChatGui { get; private set; } = null!;

[PluginService]
[RequiredVersion("1.0")]
public static ClientState ClientState { get; private set; } = null!;
public static IClientState ClientState { get; private set; } = null!;

[PluginService]
[RequiredVersion("1.0")]
public static SigScanner SigScanner { get; private set; } = null!;
public static IGameGui GameGui { get; private set; } = null!;

[PluginService]
[RequiredVersion("1.0")]
public static GameGui GameGui { get; private set; } = null!;
internal static IGameInteropProvider Hooker { get; private set; } = null!;

public static void Initialize(DalamudPluginInterface pluginInterface)
{
Expand Down
7 changes: 4 additions & 3 deletions CustomizePlus/Services/GPoseService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using CustomizePlus.Core;
using CustomizePlus.Helpers;
using Dalamud.Hooking;
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.System.Framework;

namespace CustomizePlus.Services
Expand Down Expand Up @@ -48,16 +49,16 @@ public bool FakeGPose

public override unsafe void Start()
{
GPoseState = DalamudServices.PluginInterface.UiBuilder.GposeActive ? GPoseState.Inside : GPoseState.Outside;
GPoseState = DalamudServices.ClientState.IsGPosing ? GPoseState.Inside : GPoseState.Outside;

var uiModule = Framework.Instance()->GetUiModule();
var enterGPoseAddress = (nint)uiModule->VTable->EnterGPose;
var exitGPoseAddress = (nint)uiModule->VTable->ExitGPose;

_enterGPoseHook = Hook<EnterGPoseDelegate>.FromAddress(enterGPoseAddress, EnteringGPoseDetour);
_enterGPoseHook = DalamudServices.Hooker.HookFromAddress<EnterGPoseDelegate>(enterGPoseAddress, EnteringGPoseDetour);
_enterGPoseHook.Enable();

_exitGPoseHook = Hook<ExitGPoseDelegate>.FromAddress(exitGPoseAddress, ExitingGPoseDetour);
_exitGPoseHook = DalamudServices.Hooker.HookFromAddress<ExitGPoseDelegate>(exitGPoseAddress, ExitingGPoseDetour);
_exitGPoseHook.Enable();

base.Start();
Expand Down
1 change: 1 addition & 0 deletions CustomizePlus/Services/PosingModeDetectService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT license.

using CustomizePlus.Core;
using Dalamud.Plugin.Services;

namespace CustomizePlus.Services
{
Expand Down
1 change: 1 addition & 0 deletions CustomizePlus/UI/Windows/Debug/IPCTestWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Numerics;
using CustomizePlus.Data;
using CustomizePlus.Data.Profile;
using CustomizePlus.Services;
using Dalamud.Interface;
using Dalamud.Interface.Components;
using Dalamud.Logging;
Expand Down
1 change: 1 addition & 0 deletions CustomizePlus/UI/Windows/SettingsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT license.

using CustomizePlus.Helpers;
using CustomizePlus.Services;
using CustomizePlus.UI.Windows.Debug;
using Dalamud.Interface;
using Dalamud.Logging;
Expand Down
23 changes: 12 additions & 11 deletions CustomizePlus/customizePlus.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"Author": "XIV Tools",
"Name": "Customize+",
"Punchline": "Customize your character beyond FFXIV's limitations.",
"Description": "A plugin that allows you to create and apply Anamnesis-style body scaling full time.",
"InternalName": "CustomizePlus",
"ApplicableVersion": "any",
"Tags": [
"anamnesis",
"customize",
"XIV Tools"
]
"Author": "XIV Tools",
"Name": "Customize+",
"Punchline": "Customize your character beyond FFXIV's limitations.",
"Description": "A plugin that allows you to create and apply Anamnesis-style body scaling full time.",
"InternalName": "CustomizePlus",
"ApplicableVersion": "any",
"DalamudApiLevel": 9,
"Tags": [
"anamnesis",
"customize",
"XIV Tools"
]
}

0 comments on commit ad34b07

Please sign in to comment.