Profile.GetCurrentlyActiveProfileOnCharacter -> Profile.GetActiveProfileIdOnCharacter (now returns profile id instead of profile contents), Profile.GetProfileById -> Profile.GetProfileByUniqueId

This commit is contained in:
RisaDev
2024-03-18 04:46:08 +03:00
parent fb4b71dfe2
commit 849b5c19de
3 changed files with 35 additions and 33 deletions

View File

@@ -49,8 +49,8 @@ public partial class CustomizePlusIpc
/// <summary>
/// Get JSON copy of profile with specified unique id
/// </summary>
[EzIPC("Profile.GetProfileById")]
private (int, string?) GetProfileById(Guid uniqueId)
[EzIPC("Profile.GetProfileByUniqueId")]
private (int, string?) GetProfileByUniqueId(Guid uniqueId)
{
if (uniqueId == Guid.Empty)
return ((int)ErrorCode.ProfileNotFound, null);
@@ -120,10 +120,10 @@ public partial class CustomizePlusIpc
}
/// <summary>
/// Get JSON copy of active profile for character.
/// Get unique id of currently active profile for character.
/// </summary>
[EzIPC("Profile.GetCurrentlyActiveProfileOnCharacter")]
private (int, string?) GetCurrentlyActiveProfileOnCharacter(Character character)
[EzIPC("Profile.GetActiveProfileIdOnCharacter")]
private (int, Guid?) GetActiveProfileIdOnCharacter(Character character)
{
if (character == null)
return ((int)ErrorCode.InvalidCharacter, null);
@@ -133,23 +133,7 @@ public partial class CustomizePlusIpc
if (profile == null)
return ((int)ErrorCode.ProfileNotFound, null);
var convertedProfile = IPCCharacterProfile.FromFullProfile(profile);
if (convertedProfile == null)
{
_logger.Error($"IPCCharacterProfile.FromFullProfile returned empty converted profile for character {character?.Name.ToString().Incognify()}, profile: {profile.UniqueId}");
return ((int)ErrorCode.UnknownError, null);
}
try
{
return ((int)ErrorCode.Success, JsonConvert.SerializeObject(convertedProfile));
}
catch(Exception ex)
{
_logger.Error($"Exception in IPCCharacterProfile.FromFullProfile for character {character?.Name.ToString().Incognify()}, profile: {profile.UniqueId}: {ex}");
return ((int)ErrorCode.UnknownError, null);
}
return ((int)ErrorCode.Success, profile.UniqueId);
}
/// <summary>

View File

@@ -47,8 +47,8 @@ public class IPCTestTab //: IDisposable
[EzIPC("Profile.DisableByUniqueId")]
private readonly Action<Guid> _disableProfileByUniqueIdIpcFunc;
[EzIPC("Profile.GetCurrentlyActiveProfileOnCharacter")]
private readonly Func<Character, (int, string?)> _getCurrentlyActiveProfileOnCharacterIpcFunc;
[EzIPC("Profile.GetActiveProfileIdOnCharacter")]
private readonly Func<Character, (int, Guid?)> _getActiveProfileIdOnCharacterIpcFunc;
[EzIPC("Profile.SetTemporaryProfileOnCharacter")]
private readonly Func<Character, string, (int, Guid?)> _setTemporaryProfileOnCharacterIpcFunc;
@@ -59,7 +59,7 @@ public class IPCTestTab //: IDisposable
[EzIPC("Profile.DeleteTemporaryProfileByUniqueId")]
private readonly Func<Guid, int> _deleteTemporaryProfileByUniqueIdIpcFunc;
[EzIPC("Profile.GetProfileById")]
[EzIPC("Profile.GetProfileByUniqueId")]
private readonly Func<Guid, (int, string?)> _getProfileByIdIpcFunc;
//private readonly ICallGateSubscriber<string, Character?, object>? _setCharacterProfile;
@@ -161,16 +161,19 @@ public class IPCTestTab //: IDisposable
_popupSystem.ShowPopup(PopupSystem.Messages.IPCV4ProfileRemembered);
}
if (ImGui.Button("GetCurrentlyActiveProfileOnCharacter into memory"))
if (ImGui.Button("GetActiveProfileIdOnCharacter into clipboard"))
{
var actors = _gameObjectService.FindActorsByName(_targetCharacterName).ToList();
if (actors.Count == 0)
return;
(int result, _rememberedProfileJson) = _getCurrentlyActiveProfileOnCharacterIpcFunc(FindCharacterByAddress(actors[0].Item2.Address));
(int result, Guid? uniqueId) = _getActiveProfileIdOnCharacterIpcFunc(FindCharacterByAddress(actors[0].Item2.Address));
if(result == 0)
_popupSystem.ShowPopup(PopupSystem.Messages.IPCGetProfileFromChrRemembered);
{
ImGui.SetClipboardText(uniqueId.ToString());
_popupSystem.ShowPopup(PopupSystem.Messages.IPCCopiedToClipboard);
}
else
{
_logger.Error($"Error code {result} while calling GetCurrentlyActiveProfileOnCharacter");
@@ -228,7 +231,7 @@ public class IPCTestTab //: IDisposable
ImGui.SameLine();
ImGui.InputText("##profileguid", ref _targetProfileId, 128);
if (ImGui.Button("Get profile by Unique ID"))
if (ImGui.Button("Get profile by Unique ID into clipboard"))
{
(int result, string? profileJson) = _getProfileByIdIpcFunc(Guid.Parse(_targetProfileId));
if (result == 0)
@@ -243,6 +246,21 @@ public class IPCTestTab //: IDisposable
}
}
if (ImGui.Button("Get profile by Unique ID into memory"))
{
(int result, string? profileJson) = _getProfileByIdIpcFunc(Guid.Parse(_targetProfileId));
if (result == 0)
{
_rememberedProfileJson = profileJson;
_popupSystem.ShowPopup(PopupSystem.Messages.IPCV4ProfileRemembered);
}
else
{
_logger.Error($"Error code {result} while calling GetProfileById");
_popupSystem.ShowPopup(PopupSystem.Messages.ActionError);
}
}
if (ImGui.Button("Enable profile by Unique ID"))
{
_enableProfileByUniqueIdIpcFunc(Guid.Parse(_targetProfileId));

View File

@@ -11,7 +11,7 @@ public partial class PopupSystem
public const string FantasiaPlusDetected = "fantasia_detected_warn";
public const string IPCV4ProfileRemembered = "ipc_v4_profile_remembered";
public const string IPCGetProfileFromChrRemembered = "ipc_get_profile_from_character_remembered";
public const string IPCGetProfileByIdRemembered = "ipc_get_profile_by_id_remembered";
public const string IPCSetProfileToChrDone = "ipc_set_profile_to_character_done";
public const string IPCRevertDone = "ipc_revert_done";
public const string IPCCopiedToClipboard = "ipc_copied_to clipboard";
@@ -31,9 +31,9 @@ public partial class PopupSystem
RegisterPopup(Messages.FantasiaPlusDetected, "Customize+ detected that you have Fantasia+ installed.\nPlease delete or turn it off and restart your game to use Customize+.");
RegisterPopup(Messages.IPCV4ProfileRemembered, "Current profile has been copied into memory");
RegisterPopup(Messages.IPCGetProfileFromChrRemembered, "GetProfileFromCharacter result has been copied into memory");
RegisterPopup(Messages.IPCGetProfileByIdRemembered, "GetProfileByUniqueId result has been copied into memory");
RegisterPopup(Messages.IPCSetProfileToChrDone, "SetProfileToCharacter has been called with data from memory, profile id printed to log");
RegisterPopup(Messages.IPCRevertDone, "Revert has been called");
RegisterPopup(Messages.IPCRevertDone, "DeleteTemporaryProfileByUniqueId has been called");
RegisterPopup(Messages.IPCCopiedToClipboard, "Copied into clipboard");
RegisterPopup(Messages.IPCEnableProfileByIdDone, "Enable profile by id has been called");
RegisterPopup(Messages.IPCDisableProfileByIdDone, "Disable profile by id has been called");