Added Profile.GetProfileList, Profile.EnableByUniqueId, Profile.DisableByUniqueId IPC endpoints
Co-authored-by: Limiana <5073202+Limiana@users.noreply.github.com>
This commit is contained in:
@@ -18,7 +18,7 @@ public partial class CustomizePlusIpc
|
||||
/// 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.
|
||||
/// </summary>
|
||||
[EzIPC($"General.{nameof(GetApiVersion)}")]
|
||||
[EzIPC($"General.GetApiVersion")]
|
||||
private (int, int) GetApiVersion()
|
||||
{
|
||||
return _apiVersion;
|
||||
@@ -29,7 +29,7 @@ public partial class CustomizePlusIpc
|
||||
/// 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.
|
||||
/// </summary>
|
||||
[EzIPC($"General.{nameof(IsValid)}")]
|
||||
[EzIPC($"General.IsValid")]
|
||||
private bool IsValid()
|
||||
{
|
||||
return !IPCFailed &&
|
||||
|
||||
@@ -1,12 +1,44 @@
|
||||
using System;
|
||||
using CustomizePlus.Profiles.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ECommons.EzIpcManager;
|
||||
|
||||
using IPCProfileDataTuple = (System.Guid UniqueId, string Name, string CharacterName, bool IsEnabled);
|
||||
|
||||
namespace CustomizePlus.Api;
|
||||
|
||||
public partial class CustomizePlusIpc
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieve list of all user profiles
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[EzIPC($"Profile.GetProfileList")]
|
||||
private IList<IPCProfileDataTuple> GetProfileList()
|
||||
{
|
||||
return _profileManager.Profiles
|
||||
.Where(x => x.ProfileType == ProfileType.Normal)
|
||||
.Select(x => (x.UniqueId, x.Name.Text, x.CharacterName.Text, x.Enabled))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable profile using its Unique ID
|
||||
/// </summary>
|
||||
/// <param name="uniqueId"></param>
|
||||
[EzIPC($"Profile.EnableByUniqueId")]
|
||||
private void EnableProfileByUniqueId(Guid uniqueId)
|
||||
{
|
||||
_profileManager.SetEnabled(uniqueId, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disable profile using its Unique ID
|
||||
/// </summary>
|
||||
[EzIPC($"Profile.DisableByUniqueId")]
|
||||
private void DisableProfileByUniqueId(Guid uniqueId)
|
||||
{
|
||||
_profileManager.SetEnabled(uniqueId, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using CustomizePlus.Core.Services;
|
||||
using CustomizePlus.Profiles;
|
||||
using Dalamud.Plugin;
|
||||
using ECommons.EzIpcManager;
|
||||
using OtterGui.Log;
|
||||
@@ -11,6 +12,7 @@ public partial class CustomizePlusIpc
|
||||
private readonly DalamudPluginInterface _pluginInterface;
|
||||
private readonly Logger _logger;
|
||||
private readonly HookingService _hookingService;
|
||||
private readonly ProfileManager _profileManager;
|
||||
|
||||
/// <summary>
|
||||
/// Shows if IPC failed to initialize or any other unrecoverable fatal error occured.
|
||||
@@ -20,11 +22,13 @@ public partial class CustomizePlusIpc
|
||||
public CustomizePlusIpc(
|
||||
DalamudPluginInterface pluginInterface,
|
||||
Logger logger,
|
||||
HookingService hookingService)
|
||||
HookingService hookingService,
|
||||
ProfileManager profileManager)
|
||||
{
|
||||
_pluginInterface = pluginInterface;
|
||||
_logger = logger;
|
||||
_hookingService = hookingService;
|
||||
_profileManager = profileManager;
|
||||
|
||||
EzIPC.Init(this, "CustomizePlus");
|
||||
}
|
||||
|
||||
@@ -292,6 +292,15 @@ public class ProfileManager : IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
public void SetEnabled(Guid guid, bool value)
|
||||
{
|
||||
var profile = Profiles.FirstOrDefault(x => x.UniqueId == guid && x.ProfileType == ProfileType.Normal);
|
||||
if (profile != null)
|
||||
{
|
||||
SetEnabled(profile, value);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetLimitLookupToOwned(Profile profile, bool value)
|
||||
{
|
||||
if (profile.LimitLookupToOwnedObjects != value)
|
||||
|
||||
@@ -13,6 +13,10 @@ using CustomizePlus.GameData.Services;
|
||||
using Penumbra.GameData.Actors;
|
||||
using ECommons.EzIpcManager;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using IPCProfileDataTuple = (System.Guid UniqueId, string Name, string CharacterName, bool IsEnabled);
|
||||
|
||||
namespace CustomizePlus.UI.Windows.MainWindow.Tabs.Debug;
|
||||
|
||||
@@ -31,6 +35,15 @@ public class IPCTestTab //: IDisposable
|
||||
[EzIPC("General.IsValid")]
|
||||
private readonly Func<bool> _isValidIpcFunc;
|
||||
|
||||
[EzIPC("Profile.GetProfileList")]
|
||||
private readonly Func<IList<IPCProfileDataTuple>> _getProfileListIpcFunc;
|
||||
|
||||
[EzIPC("Profile.EnableByUniqueId")]
|
||||
private readonly Action<Guid> _enableProfileByUniqueIdIpcFunc;
|
||||
|
||||
[EzIPC("Profile.DisableByUniqueId")]
|
||||
private readonly Action<Guid> _disableProfileByUniqueIdIpcFunc;
|
||||
|
||||
private readonly ICallGateSubscriber<string, Character?, object>? _setCharacterProfile;
|
||||
private readonly ICallGateSubscriber<Character?, string>? _getProfileFromCharacter;
|
||||
private readonly ICallGateSubscriber<Character?, object>? _revertCharacter;
|
||||
@@ -44,6 +57,8 @@ public class IPCTestTab //: IDisposable
|
||||
|
||||
private string? _targetCharacterName;
|
||||
|
||||
private string _targetProfileId = "";
|
||||
|
||||
public IPCTestTab(
|
||||
DalamudPluginInterface pluginInterface,
|
||||
IObjectTable objectTable,
|
||||
@@ -100,6 +115,8 @@ public class IPCTestTab //: IDisposable
|
||||
_lastValidCheckAt = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
//ImGui.Text($"Last profile update: {_lastProfileUpdate}, Character: {_lastProfileUpdateName}");
|
||||
ImGui.Text($"Memory: {(string.IsNullOrWhiteSpace(_rememberedProfileJson) ? "empty" : "has data")}");
|
||||
|
||||
@@ -156,6 +173,30 @@ public class IPCTestTab //: IDisposable
|
||||
_revertCharacter!.InvokeAction(FindCharacterByAddress(actors[0].Item2.Address));
|
||||
_popupSystem.ShowPopup(PopupSystem.Messages.IPCRevertDone);
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
if (ImGui.Button("Copy user profile list to clipboard"))
|
||||
{
|
||||
ImGui.SetClipboardText(string.Join("\n", _getProfileListIpcFunc().Select(x => $"{x.UniqueId}, {x.Name}, {x.CharacterName}, {x.IsEnabled}")));
|
||||
_popupSystem.ShowPopup(PopupSystem.Messages.IPCProfileListCopied);
|
||||
}
|
||||
|
||||
ImGui.Text("Profile Unique ID to set:");
|
||||
ImGui.SameLine();
|
||||
ImGui.InputText("##profileguid", ref _targetProfileId, 128);
|
||||
|
||||
if (ImGui.Button("Enable profile by Unique ID"))
|
||||
{
|
||||
_enableProfileByUniqueIdIpcFunc(Guid.Parse(_targetProfileId));
|
||||
_popupSystem.ShowPopup(PopupSystem.Messages.IPCEnableProfileByIdDone);
|
||||
}
|
||||
|
||||
if (ImGui.Button("Disable profile by Unique ID"))
|
||||
{
|
||||
_disableProfileByUniqueIdIpcFunc(Guid.Parse(_targetProfileId));
|
||||
_popupSystem.ShowPopup(PopupSystem.Messages.IPCDisableProfileByIdDone);
|
||||
}
|
||||
}
|
||||
|
||||
private Character? FindCharacterByAddress(nint address)
|
||||
|
||||
@@ -14,6 +14,9 @@ public partial class PopupSystem
|
||||
public const string IPCGetProfileFromChrRemembered = "ipc_get_profile_from_character_remembered";
|
||||
public const string IPCSetProfileToChrDone = "ipc_set_profile_to_character_done";
|
||||
public const string IPCRevertDone = "ipc_revert_done";
|
||||
public const string IPCProfileListCopied = "ipc_profile_list_copied";
|
||||
public const string IPCEnableProfileByIdDone = "ipc_enable_profile_by_id_done";
|
||||
public const string IPCDisableProfileByIdDone = "ipc_disable_profile_by_id_done";
|
||||
|
||||
public const string TemplateEditorActiveWarning = "template_editor_active_warn";
|
||||
public const string ClipboardDataUnsupported = "clipboard_data_unsupported_version";
|
||||
@@ -31,6 +34,9 @@ public partial class PopupSystem
|
||||
RegisterPopup(Messages.IPCGetProfileFromChrRemembered, "GetProfileFromCharacter result has been copied into memory");
|
||||
RegisterPopup(Messages.IPCSetProfileToChrDone, "SetProfileToCharacter has been called with data from memory");
|
||||
RegisterPopup(Messages.IPCRevertDone, "Revert has been called");
|
||||
RegisterPopup(Messages.IPCProfileListCopied, "Profile list copied into clipboard");
|
||||
RegisterPopup(Messages.IPCEnableProfileByIdDone, "Enable profile by id has been called");
|
||||
RegisterPopup(Messages.IPCDisableProfileByIdDone, "Disable profile by id has been called");
|
||||
|
||||
RegisterPopup(Messages.TemplateEditorActiveWarning, "You need to stop bone editing before doing this action");
|
||||
RegisterPopup(Messages.ClipboardDataUnsupported, "Clipboard data you are trying to use cannot be used in this version of Customize+.");
|
||||
|
||||
Reference in New Issue
Block a user