Expose GameState.GetCutsceneParentIndex and GameState.SetCutsceneParentIndex via IPC

This commit is contained in:
RisaDev
2024-09-30 22:44:19 +03:00
parent 0a6b5e51ca
commit 80d0ed4f07
5 changed files with 93 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
using CustomizePlus.Api.Enums;
using ECommons.EzIpcManager;
namespace CustomizePlus.Api;
public partial class CustomizePlusIpc
{
/// <summary>
/// Retrieve parent for actor. If actor has no parent will return -1.
/// This IPC method is identical to same method in Penumbra.
/// /!\ Generally speaking use cases for this are quite limited and you should not use this unless you know what you are doing.
/// Improper use of this method can lead to incorrect Customize+ behavior.
/// </summary>
[EzIPC("GameState.GetCutsceneParentIndex")]
private int GetCutsceneParentIndex(int actorIndex)
{
return _cutsceneService.GetParentIndex(actorIndex);
}
/// <summary>
/// Set parent for actor.
/// This IPC method is identical to same method in Penumbra.
/// /!\ Generally speaking use cases for this are quite limited and you should not use this unless you know what you are doing.
/// Improper use of this method can lead to incorrect Customize+ behavior.
/// </summary>
[EzIPC("GameState.SetCutsceneParentIndex")]
private int SetCutsceneParentIndex(int copyIndex, int newParentIndex)
{
return _cutsceneService.SetParentIndex(copyIndex, newParentIndex) ? (int)ErrorCode.Success : (int)ErrorCode.InvalidArgument;
}
}

View File

@@ -1,6 +1,7 @@
using CustomizePlus.Armatures.Events; using CustomizePlus.Armatures.Events;
using CustomizePlus.Core.Services; using CustomizePlus.Core.Services;
using CustomizePlus.Game.Services; using CustomizePlus.Game.Services;
using CustomizePlus.GameData.Services;
using CustomizePlus.Profiles; using CustomizePlus.Profiles;
using CustomizePlus.Profiles.Events; using CustomizePlus.Profiles.Events;
using Dalamud.Plugin; using Dalamud.Plugin;
@@ -25,6 +26,7 @@ public partial class CustomizePlusIpc : IDisposable
private readonly ProfileManager _profileManager; private readonly ProfileManager _profileManager;
private readonly GameObjectService _gameObjectService; private readonly GameObjectService _gameObjectService;
private readonly ProfileFileSystem _profileFileSystem; private readonly ProfileFileSystem _profileFileSystem;
private readonly CutsceneService _cutsceneService;
private readonly ArmatureChanged _armatureChangedEvent; private readonly ArmatureChanged _armatureChangedEvent;
@@ -40,6 +42,7 @@ public partial class CustomizePlusIpc : IDisposable
ProfileManager profileManager, ProfileManager profileManager,
GameObjectService gameObjectService, GameObjectService gameObjectService,
ProfileFileSystem profileFileSystem, ProfileFileSystem profileFileSystem,
CutsceneService cutsceneService,
ArmatureChanged armatureChangedEvent) ArmatureChanged armatureChangedEvent)
{ {
_pluginInterface = pluginInterface; _pluginInterface = pluginInterface;
@@ -48,6 +51,7 @@ public partial class CustomizePlusIpc : IDisposable
_profileManager = profileManager; _profileManager = profileManager;
_gameObjectService = gameObjectService; _gameObjectService = gameObjectService;
_profileFileSystem = profileFileSystem; _profileFileSystem = profileFileSystem;
_cutsceneService = cutsceneService;
_armatureChangedEvent = armatureChangedEvent; _armatureChangedEvent = armatureChangedEvent;

View File

@@ -12,18 +12,26 @@ namespace CustomizePlus.Api.Enums;
public enum ErrorCode public enum ErrorCode
{ {
Success = 0, Success = 0,
/// <summary> /// <summary>
/// Returned when invalid character address was provided /// Returned when invalid character address was provided
/// </summary> /// </summary>
InvalidCharacter = 1, InvalidCharacter = 1,
/// <summary> /// <summary>
/// Returned if IPCCharacterProfile could not be deserialized or deserialized into an empty object /// Returned if IPCCharacterProfile could not be deserialized or deserialized into an empty object
/// </summary> /// </summary>
CorruptedProfile = 2, CorruptedProfile = 2,
/// <summary> /// <summary>
/// Provided character does not have active profiles, provided profile id is invalid or provided profile id is not valid for use in current function /// Provided character does not have active profiles, provided profile id is invalid or provided profile id is not valid for use in current function
/// </summary> /// </summary>
ProfileNotFound = 3, ProfileNotFound = 3,
/// <summary>
/// General error telling that one of the provided arguments were invalid.
/// </summary>
InvalidArgument = 4,
UnknownError = 255 UnknownError = 255
} }

View File

@@ -64,6 +64,12 @@ public class IPCTestTab //: IDisposable
[EzIPC("Profile.GetByUniqueId")] [EzIPC("Profile.GetByUniqueId")]
private readonly Func<Guid, (int, string?)> _getProfileByIdIpcFunc; private readonly Func<Guid, (int, string?)> _getProfileByIdIpcFunc;
[EzIPC("GameState.GetCutsceneParentIndex")]
private readonly Func<int, int> _getCutsceneParentIdxIpcFunc;
[EzIPC("GameState.SetCutsceneParentIndex")]
private readonly Func<int, int, int> _setCutsceneParentIdxIpcFunc;
private string? _rememberedProfileJson; private string? _rememberedProfileJson;
private (int, int) _apiVersion; private (int, int) _apiVersion;
@@ -74,6 +80,10 @@ public class IPCTestTab //: IDisposable
private string _targetProfileId = ""; private string _targetProfileId = "";
private int _cutsceneActorIdx;
private int _cutsceneActorParentIdx;
public IPCTestTab( public IPCTestTab(
IDalamudPluginInterface pluginInterface, IDalamudPluginInterface pluginInterface,
IObjectTable objectTable, IObjectTable objectTable,
@@ -286,6 +296,44 @@ public class IPCTestTab //: IDisposable
_popupSystem.ShowPopup(PopupSystem.Messages.ActionError); _popupSystem.ShowPopup(PopupSystem.Messages.ActionError);
} }
} }
ImGui.Text("Cutscene actor index:");
ImGui.SameLine();
ImGui.InputInt("##cutsceneactoridx", ref _cutsceneActorIdx);
ImGui.Text("Cutscene actor parent index:");
ImGui.SameLine();
ImGui.InputInt("##cutsceneactorparentidx", ref _cutsceneActorParentIdx);
if (ImGui.Button("GameState.GetCutsceneParentIndex"))
{
int result = _getCutsceneParentIdxIpcFunc(_cutsceneActorIdx);
if (result > -1)
{
_cutsceneActorParentIdx = result;
_popupSystem.ShowPopup(PopupSystem.Messages.IPCSuccessfullyExecuted);
}
else
{
_logger.Error($"No parent for actor or actor not found while caling GetCutsceneParentIndex");
_popupSystem.ShowPopup(PopupSystem.Messages.ActionError);
}
}
if (ImGui.Button("GameState.SetCutsceneParentIndex"))
{
int result = _setCutsceneParentIdxIpcFunc(_cutsceneActorIdx, _cutsceneActorParentIdx);
if (result == 0)
{
_cutsceneActorParentIdx = result;
_popupSystem.ShowPopup(PopupSystem.Messages.IPCSuccessfullyExecuted);
}
else
{
_logger.Error($"Error code {result} while calling GameState.SetCutsceneParentIndex");
_popupSystem.ShowPopup(PopupSystem.Messages.ActionError);
}
}
} }
[EzIPCEvent("Profile.OnUpdate")] [EzIPCEvent("Profile.OnUpdate")]

View File

@@ -15,6 +15,7 @@ public partial class PopupSystem
public const string IPCSetProfileToChrDone = "ipc_set_profile_to_character_done"; public const string IPCSetProfileToChrDone = "ipc_set_profile_to_character_done";
public const string IPCRevertDone = "ipc_revert_done"; public const string IPCRevertDone = "ipc_revert_done";
public const string IPCCopiedToClipboard = "ipc_copied_to clipboard"; public const string IPCCopiedToClipboard = "ipc_copied_to clipboard";
public const string IPCSuccessfullyExecuted = "ipc_successfully_executed";
public const string IPCEnableProfileByIdDone = "ipc_enable_profile_by_id_done"; public const string IPCEnableProfileByIdDone = "ipc_enable_profile_by_id_done";
public const string IPCDisableProfileByIdDone = "ipc_disable_profile_by_id_done"; public const string IPCDisableProfileByIdDone = "ipc_disable_profile_by_id_done";
@@ -35,6 +36,7 @@ public partial class PopupSystem
RegisterPopup(Messages.IPCSetProfileToChrDone, "SetProfileToCharacter has been called with data from memory, profile id printed to log"); RegisterPopup(Messages.IPCSetProfileToChrDone, "SetProfileToCharacter has been called with data from memory, profile id printed to log");
RegisterPopup(Messages.IPCRevertDone, "DeleteTemporaryProfileByUniqueId has been called"); RegisterPopup(Messages.IPCRevertDone, "DeleteTemporaryProfileByUniqueId has been called");
RegisterPopup(Messages.IPCCopiedToClipboard, "Copied into clipboard"); RegisterPopup(Messages.IPCCopiedToClipboard, "Copied into clipboard");
RegisterPopup(Messages.IPCSuccessfullyExecuted, "Successfully executed");
RegisterPopup(Messages.IPCEnableProfileByIdDone, "Enable profile by id has been called"); RegisterPopup(Messages.IPCEnableProfileByIdDone, "Enable profile by id has been called");
RegisterPopup(Messages.IPCDisableProfileByIdDone, "Disable profile by id has been called"); RegisterPopup(Messages.IPCDisableProfileByIdDone, "Disable profile by id has been called");