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

@@ -64,6 +64,12 @@ public class IPCTestTab //: IDisposable
[EzIPC("Profile.GetByUniqueId")]
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 (int, int) _apiVersion;
@@ -74,6 +80,10 @@ public class IPCTestTab //: IDisposable
private string _targetProfileId = "";
private int _cutsceneActorIdx;
private int _cutsceneActorParentIdx;
public IPCTestTab(
IDalamudPluginInterface pluginInterface,
IObjectTable objectTable,
@@ -286,6 +296,44 @@ public class IPCTestTab //: IDisposable
_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")]

View File

@@ -15,6 +15,7 @@ public partial class PopupSystem
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";
public const string IPCSuccessfullyExecuted = "ipc_successfully_executed";
public const string IPCEnableProfileByIdDone = "ipc_enable_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.IPCRevertDone, "DeleteTemporaryProfileByUniqueId has been called");
RegisterPopup(Messages.IPCCopiedToClipboard, "Copied into clipboard");
RegisterPopup(Messages.IPCSuccessfullyExecuted, "Successfully executed");
RegisterPopup(Messages.IPCEnableProfileByIdDone, "Enable profile by id has been called");
RegisterPopup(Messages.IPCDisableProfileByIdDone, "Disable profile by id has been called");