From 3a74a50e399946600ade557f4208f54ca0ccb1af Mon Sep 17 00:00:00 2001 From: RisaDev <151885272+RisaDev@users.noreply.github.com> Date: Thu, 21 Mar 2024 23:34:43 +0300 Subject: [PATCH] Updated ECommons, Profile.GetProfileByUniqueId -> Profile.GetByUniqueId, OnProfileUpdate now returns Guid.Empty if no profile is set --- CustomizePlus/Api/CustomizePlusIpc.Profile.cs | 8 +++-- .../MainWindow/Tabs/Debug/IPCTestTab.cs | 32 ++++++++++++++----- submodules/ECommons | 2 +- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/CustomizePlus/Api/CustomizePlusIpc.Profile.cs b/CustomizePlus/Api/CustomizePlusIpc.Profile.cs index 6faccaa..3f0690f 100644 --- a/CustomizePlus/Api/CustomizePlusIpc.Profile.cs +++ b/CustomizePlus/Api/CustomizePlusIpc.Profile.cs @@ -18,6 +18,7 @@ using Dalamud.Game.ClientState.Objects.Types; using Penumbra.GameData.Actors; using IPCProfileDataTuple = (System.Guid UniqueId, string Name, string CharacterName, bool IsEnabled); +using Penumbra.GameData.Interop; //using OnUpdateTuple = (Dalamud.Game.ClientState.Objects.Types.Character Character, System.Guid? ProfileUniqueId, string? ProfileJson); namespace CustomizePlus.Api; @@ -29,9 +30,10 @@ public partial class CustomizePlusIpc /// Not triggered if any changes happen due to character no longer existing. /// Right now ignores every character but local player. It is not recommended to assume that this will always be the case and not perform any checks on your side. /// Ignores temporary profiles. + /// /!\ If no profile is set on specified character profile id will be equal to Guid.Empty /// [EzIPCEvent("Profile.OnUpdate")] - private Action OnProfileUpdate; + private Action OnProfileUpdate; /// /// Retrieve list of all user profiles @@ -49,7 +51,7 @@ public partial class CustomizePlusIpc /// /// Get JSON copy of profile with specified unique id /// - [EzIPC("Profile.GetProfileByUniqueId")] + [EzIPC("Profile.GetByUniqueId")] private (int, string?) GetProfileByUniqueId(Guid uniqueId) { if (uniqueId == Guid.Empty) @@ -327,6 +329,6 @@ public partial class CustomizePlusIpc _logger.Debug($"Sending player update message: Character: {character.Name.ToString().Incognify()}, Profile: {(profile != null ? profile.ToString() : "no profile")}"); - OnProfileUpdate(character, profile != null ? profile.UniqueId : null); + OnProfileUpdate(character, profile != null ? profile.UniqueId : Guid.Empty); } } diff --git a/CustomizePlus/UI/Windows/MainWindow/Tabs/Debug/IPCTestTab.cs b/CustomizePlus/UI/Windows/MainWindow/Tabs/Debug/IPCTestTab.cs index a7cd82d..9d45a80 100644 --- a/CustomizePlus/UI/Windows/MainWindow/Tabs/Debug/IPCTestTab.cs +++ b/CustomizePlus/UI/Windows/MainWindow/Tabs/Debug/IPCTestTab.cs @@ -42,10 +42,10 @@ public class IPCTestTab //: IDisposable private readonly Func> _getProfileListIpcFunc; [EzIPC("Profile.EnableByUniqueId")] - private readonly Action _enableProfileByUniqueIdIpcFunc; + private readonly Func _enableProfileByUniqueIdIpcFunc; [EzIPC("Profile.DisableByUniqueId")] - private readonly Action _disableProfileByUniqueIdIpcFunc; + private readonly Func _disableProfileByUniqueIdIpcFunc; [EzIPC("Profile.GetActiveProfileIdOnCharacter")] private readonly Func _getActiveProfileIdOnCharacterIpcFunc; @@ -59,7 +59,7 @@ public class IPCTestTab //: IDisposable [EzIPC("Profile.DeleteTemporaryProfileByUniqueId")] private readonly Func _deleteTemporaryProfileByUniqueIdIpcFunc; - [EzIPC("Profile.GetProfileByUniqueId")] + [EzIPC("Profile.GetByUniqueId")] private readonly Func _getProfileByIdIpcFunc; //private readonly ICallGateSubscriber? _setCharacterProfile; @@ -263,14 +263,30 @@ public class IPCTestTab //: IDisposable if (ImGui.Button("Enable profile by Unique ID")) { - _enableProfileByUniqueIdIpcFunc(Guid.Parse(_targetProfileId)); - _popupSystem.ShowPopup(PopupSystem.Messages.IPCEnableProfileByIdDone); + int result = _enableProfileByUniqueIdIpcFunc(Guid.Parse(_targetProfileId)); + if (result == 0) + { + _popupSystem.ShowPopup(PopupSystem.Messages.IPCEnableProfileByIdDone); + } + else + { + _logger.Error($"Error code {result} while calling EnableByUniqueId"); + _popupSystem.ShowPopup(PopupSystem.Messages.ActionError); + } } if (ImGui.Button("Disable profile by Unique ID")) { - _disableProfileByUniqueIdIpcFunc(Guid.Parse(_targetProfileId)); - _popupSystem.ShowPopup(PopupSystem.Messages.IPCDisableProfileByIdDone); + int result = _disableProfileByUniqueIdIpcFunc(Guid.Parse(_targetProfileId)); + if (result == 0) + { + _popupSystem.ShowPopup(PopupSystem.Messages.IPCDisableProfileByIdDone); + } + else + { + _logger.Error($"Error code {result} while calling DisableByUniqueId"); + _popupSystem.ShowPopup(PopupSystem.Messages.ActionError); + } } if (ImGui.Button("DeleteTemporaryProfileByUniqueId")) @@ -293,7 +309,7 @@ public class IPCTestTab //: IDisposable [EzIPCEvent("Profile.OnUpdate")] private void OnProfileUpdate(Character Character, Guid? ProfileUniqueId) { - _logger.Debug($"IPC Test Tab - OnProfileUpdate: Character: {Character.Name.ToString().Incognify()}, Profile ID: {(ProfileUniqueId != null ? ProfileUniqueId.ToString() : "no id")}"); + _logger.Debug($"IPC Test Tab - OnProfileUpdate: Character: {Character.Name.ToString().Incognify()}, Profile ID: {(ProfileUniqueId != Guid.Empty ? ProfileUniqueId.ToString() : "no id")}"); } private Character? FindCharacterByAddress(nint address) diff --git a/submodules/ECommons b/submodules/ECommons index a3521ec..d238d41 160000 --- a/submodules/ECommons +++ b/submodules/ECommons @@ -1 +1 @@ -Subproject commit a3521ec6188fec91dcb01090cacf27f2104e8a2e +Subproject commit d238d4188e8b47b11252d75cb5e4b678b8da2756