EzIPC experiments
This commit is contained in:
4
.gitmodules
vendored
4
.gitmodules
vendored
@@ -14,3 +14,7 @@
|
|||||||
path = submodules/Penumbra.String
|
path = submodules/Penumbra.String
|
||||||
url = https://github.com/Ottermandias/Penumbra.String.git
|
url = https://github.com/Ottermandias/Penumbra.String.git
|
||||||
branch = main
|
branch = main
|
||||||
|
[submodule "submodules/ECommons"]
|
||||||
|
path = submodules/ECommons
|
||||||
|
url = https://github.com/NightmareXIV/ECommons.git
|
||||||
|
branch = master
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Penumbra.Api", "submodules\
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Penumbra.String", "submodules\Penumbra.String\Penumbra.String.csproj", "{CB1DFB63-22D9-4E90-A8C1-A4F7CFEF7823}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Penumbra.String", "submodules\Penumbra.String\Penumbra.String.csproj", "{CB1DFB63-22D9-4E90-A8C1-A4F7CFEF7823}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ECommons", "submodules\ECommons\ECommons\ECommons.csproj", "{0234819A-193E-4B75-A528-23E71C9FB1C8}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -78,6 +80,14 @@ Global
|
|||||||
{CB1DFB63-22D9-4E90-A8C1-A4F7CFEF7823}.Release|Any CPU.Build.0 = Release|Any CPU
|
{CB1DFB63-22D9-4E90-A8C1-A4F7CFEF7823}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{CB1DFB63-22D9-4E90-A8C1-A4F7CFEF7823}.Release|x64.ActiveCfg = Release|Any CPU
|
{CB1DFB63-22D9-4E90-A8C1-A4F7CFEF7823}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
{CB1DFB63-22D9-4E90-A8C1-A4F7CFEF7823}.Release|x64.Build.0 = Release|Any CPU
|
{CB1DFB63-22D9-4E90-A8C1-A4F7CFEF7823}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{0234819A-193E-4B75-A528-23E71C9FB1C8}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||||
|
{0234819A-193E-4B75-A528-23E71C9FB1C8}.Debug|Any CPU.Build.0 = Debug|x64
|
||||||
|
{0234819A-193E-4B75-A528-23E71C9FB1C8}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{0234819A-193E-4B75-A528-23E71C9FB1C8}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{0234819A-193E-4B75-A528-23E71C9FB1C8}.Release|Any CPU.ActiveCfg = Release|x64
|
||||||
|
{0234819A-193E-4B75-A528-23E71C9FB1C8}.Release|Any CPU.Build.0 = Release|x64
|
||||||
|
{0234819A-193E-4B75-A528-23E71C9FB1C8}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{0234819A-193E-4B75-A528-23E71C9FB1C8}.Release|x64.Build.0 = Release|x64
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -87,6 +97,7 @@ Global
|
|||||||
{D79C8833-D241-4867-BF6F-8097E0ED8067} = {121C2200-A844-44FD-85C4-22D6C7E35553}
|
{D79C8833-D241-4867-BF6F-8097E0ED8067} = {121C2200-A844-44FD-85C4-22D6C7E35553}
|
||||||
{CC460943-1E07-4FA0-8B8C-67F0EF385290} = {121C2200-A844-44FD-85C4-22D6C7E35553}
|
{CC460943-1E07-4FA0-8B8C-67F0EF385290} = {121C2200-A844-44FD-85C4-22D6C7E35553}
|
||||||
{CB1DFB63-22D9-4E90-A8C1-A4F7CFEF7823} = {121C2200-A844-44FD-85C4-22D6C7E35553}
|
{CB1DFB63-22D9-4E90-A8C1-A4F7CFEF7823} = {121C2200-A844-44FD-85C4-22D6C7E35553}
|
||||||
|
{0234819A-193E-4B75-A528-23E71C9FB1C8} = {121C2200-A844-44FD-85C4-22D6C7E35553}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {B17E85B1-5F60-4440-9F9A-3DDE877E8CDF}
|
SolutionGuid = {B17E85B1-5F60-4440-9F9A-3DDE877E8CDF}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Dalamud.Plugin.Ipc;
|
using Dalamud.Plugin.Ipc;
|
||||||
|
using ECommons.EzIpcManager;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -8,20 +9,16 @@ using static Penumbra.Api.Ipc;
|
|||||||
|
|
||||||
namespace CustomizePlus.Api;
|
namespace CustomizePlus.Api;
|
||||||
|
|
||||||
//I'm not a big fan of having functions and variables/properties
|
public partial class CustomizePlusIpc
|
||||||
//grouped up like that but it makes sense here
|
|
||||||
|
|
||||||
public partial class CustomizePlusIpc : IDisposable
|
|
||||||
{
|
{
|
||||||
|
private readonly (int Breaking, int Feature) _apiVersion = (4, 0);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// When there are breaking changes the first number is bumped up and second one is reset.
|
/// When there are breaking changes the first number is bumped up and second one is reset.
|
||||||
/// When there are non-breaking changes only second number is bumped up.
|
/// When there are non-breaking changes only second number is bumped up.
|
||||||
/// In general clients should not try to use IPC if they encounter unexpected Breaking version.
|
/// In general clients should not try to use IPC if they encounter unexpected Breaking version.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly (int Breaking, int Feature) _apiVersion = (4, 0);
|
[EzIPC($"General.{nameof(GetApiVersion)}")]
|
||||||
private const string _providerGetApiVersionLabel = $"CustomizePlus.General.{nameof(GetApiVersion)}";
|
|
||||||
private ICallGateProvider<(int, int)>? _providerGetApiVersion;
|
|
||||||
|
|
||||||
private (int, int) GetApiVersion()
|
private (int, int) GetApiVersion()
|
||||||
{
|
{
|
||||||
return _apiVersion;
|
return _apiVersion;
|
||||||
@@ -32,30 +29,11 @@ public partial class CustomizePlusIpc : IDisposable
|
|||||||
/// This only indicates that no fatal errors occured in Customize+.
|
/// This only indicates that no fatal errors occured in Customize+.
|
||||||
/// This will still be true if, for example, user turns off Customize+ in its settings.
|
/// This will still be true if, for example, user turns off Customize+ in its settings.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private const string _providerIsValidLabel = $"CustomizePlus.General.{nameof(IsValid)}";
|
[EzIPC($"General.{nameof(IsValid)}")]
|
||||||
private ICallGateProvider<bool>? _providerIsValid;
|
|
||||||
|
|
||||||
private bool IsValid()
|
private bool IsValid()
|
||||||
{
|
{
|
||||||
return !IPCFailed &&
|
return !IPCFailed &&
|
||||||
!_hookingService.RenderHookFailed &&
|
!_hookingService.RenderHookFailed &&
|
||||||
!_hookingService.MovementHookFailed;
|
!_hookingService.MovementHookFailed;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeGeneralProviders()
|
|
||||||
{
|
|
||||||
_logger.Debug("Initializing General Customize+ IPC providers.");
|
|
||||||
|
|
||||||
_providerGetApiVersion = _pluginInterface.GetIpcProvider<(int, int)>(_providerGetApiVersionLabel);
|
|
||||||
_providerGetApiVersion.RegisterFunc(GetApiVersion);
|
|
||||||
|
|
||||||
_providerIsValid = _pluginInterface.GetIpcProvider<bool>(_providerIsValidLabel);
|
|
||||||
_providerIsValid.RegisterFunc(IsValid);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DisposeGeneralProviders()
|
|
||||||
{
|
|
||||||
_logger.Debug("Disposing General Customize+ IPC providers.");
|
|
||||||
_providerGetApiVersion?.UnregisterFunc();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace CustomizePlus.Api;
|
namespace CustomizePlus.Api;
|
||||||
|
|
||||||
public partial class CustomizePlusIpc : IDisposable
|
public partial class CustomizePlusIpc
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
using CustomizePlus.Core.Services;
|
using CustomizePlus.Core.Services;
|
||||||
using Dalamud.Plugin;
|
using Dalamud.Plugin;
|
||||||
|
using ECommons.EzIpcManager;
|
||||||
using OtterGui.Log;
|
using OtterGui.Log;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace CustomizePlus.Api;
|
namespace CustomizePlus.Api;
|
||||||
|
|
||||||
public partial class CustomizePlusIpc : IDisposable
|
public partial class CustomizePlusIpc
|
||||||
{
|
{
|
||||||
private readonly DalamudPluginInterface _pluginInterface;
|
private readonly DalamudPluginInterface _pluginInterface;
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
@@ -25,32 +26,6 @@ public partial class CustomizePlusIpc : IDisposable
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
_hookingService = hookingService;
|
_hookingService = hookingService;
|
||||||
|
|
||||||
InitializeProviders();
|
EzIPC.Init(this, "CustomizePlus");
|
||||||
}
|
|
||||||
|
|
||||||
private void InitializeProviders()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
InitializeGeneralProviders();
|
|
||||||
}
|
|
||||||
catch(Exception ex)
|
|
||||||
{
|
|
||||||
_logger.Fatal($"Fatal error while initializing Customize+ IPC: {ex}");
|
|
||||||
|
|
||||||
IPCFailed = true;
|
|
||||||
|
|
||||||
DisposeProviders();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DisposeProviders()
|
|
||||||
{
|
|
||||||
DisposeGeneralProviders();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
DisposeProviders();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,7 @@
|
|||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<ProjectReference Include="..\CustomizePlus.GameData\CustomizePlus.GameData.csproj" />
|
<ProjectReference Include="..\CustomizePlus.GameData\CustomizePlus.GameData.csproj" />
|
||||||
|
<ProjectReference Include="..\submodules\ECommons\ECommons\ECommons.csproj" />
|
||||||
<ProjectReference Include="..\submodules\OtterGui\OtterGui.csproj" />
|
<ProjectReference Include="..\submodules\OtterGui\OtterGui.csproj" />
|
||||||
<Reference Include="Newtonsoft.Json">
|
<Reference Include="Newtonsoft.Json">
|
||||||
<HintPath>$(DalamudLibPath)Newtonsoft.Json.dll</HintPath>
|
<HintPath>$(DalamudLibPath)Newtonsoft.Json.dll</HintPath>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ using CustomizePlus.Api.Compatibility;
|
|||||||
using CustomizePlus.Configuration.Services.Temporary;
|
using CustomizePlus.Configuration.Services.Temporary;
|
||||||
using OtterGui.Services;
|
using OtterGui.Services;
|
||||||
using CustomizePlus.Api;
|
using CustomizePlus.Api;
|
||||||
|
using ECommons;
|
||||||
|
|
||||||
namespace CustomizePlus;
|
namespace CustomizePlus;
|
||||||
|
|
||||||
@@ -29,6 +30,8 @@ public sealed class Plugin : IDalamudPlugin
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
ECommonsMain.Init(pluginInterface, this);
|
||||||
|
|
||||||
_services = ServiceManagerBuilder.CreateProvider(pluginInterface, Logger);
|
_services = ServiceManagerBuilder.CreateProvider(pluginInterface, Logger);
|
||||||
|
|
||||||
//temporary
|
//temporary
|
||||||
@@ -57,5 +60,7 @@ public sealed class Plugin : IDalamudPlugin
|
|||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_services?.Dispose();
|
_services?.Dispose();
|
||||||
|
|
||||||
|
ECommonsMain.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,8 @@ using CustomizePlus.Configuration.Helpers;
|
|||||||
using CustomizePlus.Game.Services;
|
using CustomizePlus.Game.Services;
|
||||||
using CustomizePlus.GameData.Services;
|
using CustomizePlus.GameData.Services;
|
||||||
using Penumbra.GameData.Actors;
|
using Penumbra.GameData.Actors;
|
||||||
|
using ECommons.EzIpcManager;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace CustomizePlus.UI.Windows.MainWindow.Tabs.Debug;
|
namespace CustomizePlus.UI.Windows.MainWindow.Tabs.Debug;
|
||||||
|
|
||||||
@@ -23,8 +25,12 @@ public class IPCTestTab //: IDisposable
|
|||||||
private readonly ObjectManager _objectManager;
|
private readonly ObjectManager _objectManager;
|
||||||
private readonly ActorManager _actorManager;
|
private readonly ActorManager _actorManager;
|
||||||
|
|
||||||
private readonly ICallGateSubscriber<(int, int)>? _getApiVersion;
|
[EzIPC("General.GetApiVersion")]
|
||||||
private readonly ICallGateSubscriber<bool>? _isValid;
|
private readonly Func<(int, int)> _getApiVersionIpcFunc;
|
||||||
|
|
||||||
|
[EzIPC("General.IsValid")]
|
||||||
|
private readonly Func<bool> _isValidIpcFunc;
|
||||||
|
|
||||||
private readonly ICallGateSubscriber<string, Character?, object>? _setCharacterProfile;
|
private readonly ICallGateSubscriber<string, Character?, object>? _setCharacterProfile;
|
||||||
private readonly ICallGateSubscriber<Character?, string>? _getProfileFromCharacter;
|
private readonly ICallGateSubscriber<Character?, string>? _getProfileFromCharacter;
|
||||||
private readonly ICallGateSubscriber<Character?, object>? _revertCharacter;
|
private readonly ICallGateSubscriber<Character?, object>? _revertCharacter;
|
||||||
@@ -33,6 +39,8 @@ public class IPCTestTab //: IDisposable
|
|||||||
private string? _rememberedProfileJson;
|
private string? _rememberedProfileJson;
|
||||||
|
|
||||||
private (int, int) _apiVersion;
|
private (int, int) _apiVersion;
|
||||||
|
private DateTime _lastValidCheckAt;
|
||||||
|
private bool _validResult;
|
||||||
|
|
||||||
private string? _targetCharacterName;
|
private string? _targetCharacterName;
|
||||||
|
|
||||||
@@ -52,10 +60,10 @@ public class IPCTestTab //: IDisposable
|
|||||||
_gameObjectService = gameObjectService;
|
_gameObjectService = gameObjectService;
|
||||||
_actorManager = actorManager;
|
_actorManager = actorManager;
|
||||||
|
|
||||||
_getApiVersion = pluginInterface.GetIpcSubscriber<(int, int)>("CustomizePlus.General.GetApiVersion");
|
EzIPC.Init(this, "CustomizePlus");
|
||||||
_apiVersion = _getApiVersion.InvokeFunc();
|
|
||||||
|
|
||||||
_isValid = pluginInterface.GetIpcSubscriber<bool>("CustomizePlus.General.IsValid");
|
if (_getApiVersionIpcFunc != null)
|
||||||
|
_apiVersion = _getApiVersionIpcFunc();
|
||||||
|
|
||||||
_setCharacterProfile = pluginInterface.GetIpcSubscriber<string, Character?, object>("CustomizePlus.SetProfileToCharacter");
|
_setCharacterProfile = pluginInterface.GetIpcSubscriber<string, Character?, object>("CustomizePlus.SetProfileToCharacter");
|
||||||
_getProfileFromCharacter = pluginInterface.GetIpcSubscriber<Character?, string>("CustomizePlus.GetProfileFromCharacter");
|
_getProfileFromCharacter = pluginInterface.GetIpcSubscriber<Character?, string>("CustomizePlus.GetProfileFromCharacter");
|
||||||
@@ -82,8 +90,15 @@ public class IPCTestTab //: IDisposable
|
|||||||
_targetCharacterName = _gameObjectService.GetCurrentPlayerName();
|
_targetCharacterName = _gameObjectService.GetCurrentPlayerName();
|
||||||
|
|
||||||
ImGui.Text($"Version: {_apiVersion.Item1}.{_apiVersion.Item2}");
|
ImGui.Text($"Version: {_apiVersion.Item1}.{_apiVersion.Item2}");
|
||||||
//
|
|
||||||
//ImGui.Text($"IsValid: {_isValid?.InvokeFunc()}");
|
ImGui.Text($"IsValid: {_validResult} ({_lastValidCheckAt} UTC)");
|
||||||
|
|
||||||
|
ImGui.SameLine();
|
||||||
|
if(ImGui.Button("Check IPC validity") || _lastValidCheckAt == DateTime.MinValue)
|
||||||
|
{
|
||||||
|
_validResult = _isValidIpcFunc();
|
||||||
|
_lastValidCheckAt = DateTime.UtcNow;
|
||||||
|
}
|
||||||
|
|
||||||
//ImGui.Text($"Last profile update: {_lastProfileUpdate}, Character: {_lastProfileUpdateName}");
|
//ImGui.Text($"Last profile update: {_lastProfileUpdate}, Character: {_lastProfileUpdateName}");
|
||||||
ImGui.Text($"Memory: {(string.IsNullOrWhiteSpace(_rememberedProfileJson) ? "empty" : "has data")}");
|
ImGui.Text($"Memory: {(string.IsNullOrWhiteSpace(_rememberedProfileJson) ? "empty" : "has data")}");
|
||||||
|
|||||||
1
submodules/ECommons
Submodule
1
submodules/ECommons
Submodule
Submodule submodules/ECommons added at a3521ec618
Reference in New Issue
Block a user