diff --git a/Glamourer.Api b/Glamourer.Api index 1529863..ca919c3 160000 --- a/Glamourer.Api +++ b/Glamourer.Api @@ -1 +1 @@ -Subproject commit 1529863ecb33d85ea88dc2cf3c749a245b11cf55 +Subproject commit ca919c3f8982ca9990b909a225488ea20a119625 diff --git a/Glamourer/Api/IpcProviders.cs b/Glamourer/Api/IpcProviders.cs index c2a674c..68ce562 100644 --- a/Glamourer/Api/IpcProviders.cs +++ b/Glamourer/Api/IpcProviders.cs @@ -29,6 +29,8 @@ public sealed class IpcProviders : IDisposable, IApiService IpcSubscribers.GetState.Provider(pi, api.State), IpcSubscribers.GetStateName.Provider(pi, api.State), + IpcSubscribers.GetStateBase64.Provider(pi, api.State), + IpcSubscribers.GetStateBase64Name.Provider(pi, api.State), IpcSubscribers.ApplyState.Provider(pi, api.State), IpcSubscribers.ApplyStateName.Provider(pi, api.State), IpcSubscribers.RevertState.Provider(pi, api.State), diff --git a/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterPanel.cs b/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterPanel.cs index 62203ac..5e6f4a2 100644 --- a/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/IpcTester/IpcTesterPanel.cs @@ -1,16 +1,8 @@ using Dalamud.Plugin; using Dalamud.Plugin.Services; -using FFXIVClientStructs.FFXIV.Client.System.Framework; -using Glamourer.Api; -using Glamourer.Api.Enums; using Glamourer.Api.IpcSubscribers; -using Glamourer.Interop; using ImGuiNET; -using OtterGui; -using Penumbra.GameData.Enums; -using Penumbra.GameData.Gui; using Penumbra.GameData.Gui.Debug; -using Penumbra.GameData.Structs; namespace Glamourer.Gui.Tabs.DebugTab.IpcTester; @@ -49,192 +41,6 @@ public class IpcTesterPanel( { Glamourer.Log.Error($"Error during IPC Tests:\n{e}"); } - //ImGui.InputInt("Game Object Index", ref _gameObjectIndex, 0, 0); - //ImGui.InputTextWithHint("##gameObject", "Character Name...", ref _gameObjectName, 64); - //ImGui.InputTextWithHint("##base64", "Design Base64...", ref _base64Apply, 2047); - //ImGui.InputTextWithHint("##identifier", "Design identifier...", ref _designIdentifier, 36); - //DrawItemInput(); - //using var table = ImRaii.Table("##ipc", 2, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg); - //if (!table) - // return; - // - //ImGuiUtil.DrawTableColumn(); - //ImGui.TableNextColumn(); - //var base64 = GlamourerIpc.GetAllCustomizationSubscriber(_pluginInterface).Invoke(_gameObjectName); - //if (base64 != null) - // ImGuiUtil.CopyOnClickSelectable(base64); - //else - // ImGui.TextUnformatted("Error"); - // - //ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelGetAllCustomizationFromCharacter); - //ImGui.TableNextColumn(); - //base64 = GlamourerIpc.GetAllCustomizationFromCharacterSubscriber(_pluginInterface) - // .Invoke(_objectManager.GetDalamudCharacter(_gameObjectIndex)); - //if (base64 != null) - // ImGuiUtil.CopyOnClickSelectable(base64); - //else - // ImGui.TextUnformatted("Error"); - // - //ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelGetAllCustomizationFromLockedCharacter); - //ImGui.TableNextColumn(); - //var base64Locked = GlamourerIpc.GetAllCustomizationFromLockedCharacterSubscriber(_pluginInterface) - // .Invoke(_objectManager.GetDalamudCharacter(_gameObjectIndex), 1337); - //if (base64Locked != null) - // ImGuiUtil.CopyOnClickSelectable(base64Locked); - //else - // ImGui.TextUnformatted("Error"); - // - //ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelRevert); - //ImGui.TableNextColumn(); - //if (ImGui.Button("Revert##Name")) - // GlamourerIpc.RevertSubscriber(_pluginInterface).Invoke(_gameObjectName); - // - //ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelRevertCharacter); - //ImGui.TableNextColumn(); - //if (ImGui.Button("Revert##Character")) - // GlamourerIpc.RevertCharacterSubscriber(_pluginInterface).Invoke(_objectManager.GetDalamudCharacter(_gameObjectIndex)); - // - //ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelApplyAll); - //ImGui.TableNextColumn(); - //if (ImGui.Button("Apply##AllName")) - // GlamourerIpc.ApplyAllSubscriber(_pluginInterface).Invoke(_base64Apply, _gameObjectName); - // - //ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelApplyAllOnce); - //ImGui.TableNextColumn(); - //if (ImGui.Button("Apply Once##AllName")) - // GlamourerIpc.ApplyAllOnceSubscriber(_pluginInterface).Invoke(_base64Apply, _gameObjectName); - // - //ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelApplyAllToCharacter); - //ImGui.TableNextColumn(); - //if (ImGui.Button("Apply##AllCharacter")) - // GlamourerIpc.ApplyAllToCharacterSubscriber(_pluginInterface) - // .Invoke(_base64Apply, _objectManager.GetDalamudCharacter(_gameObjectIndex)); - // - //ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelApplyAllOnceToCharacter); - //ImGui.TableNextColumn(); - //if (ImGui.Button("Apply Once##AllCharacter")) - // GlamourerIpc.ApplyAllOnceToCharacterSubscriber(_pluginInterface) - // .Invoke(_base64Apply, _objectManager.GetDalamudCharacter(_gameObjectIndex)); - // - //ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelApplyOnlyEquipment); - //ImGui.TableNextColumn(); - //if (ImGui.Button("Apply##EquipName")) - // GlamourerIpc.ApplyOnlyEquipmentSubscriber(_pluginInterface).Invoke(_base64Apply, _gameObjectName); - // - //ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelApplyOnlyEquipmentToCharacter); - //ImGui.TableNextColumn(); - //if (ImGui.Button("Apply##EquipCharacter")) - // GlamourerIpc.ApplyOnlyEquipmentToCharacterSubscriber(_pluginInterface) - // .Invoke(_base64Apply, _objectManager.GetDalamudCharacter(_gameObjectIndex)); - // - //ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelApplyOnlyCustomization); - //ImGui.TableNextColumn(); - //if (ImGui.Button("Apply##CustomizeName")) - // GlamourerIpc.ApplyOnlyCustomizationSubscriber(_pluginInterface).Invoke(_base64Apply, _gameObjectName); - // - //ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelApplyOnlyCustomizationToCharacter); - //ImGui.TableNextColumn(); - //if (ImGui.Button("Apply##CustomizeCharacter")) - // GlamourerIpc.ApplyOnlyCustomizationToCharacterSubscriber(_pluginInterface) - // .Invoke(_base64Apply, _objectManager.GetDalamudCharacter(_gameObjectIndex)); - // - //ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelApplyByGuid); - //ImGui.TableNextColumn(); - //if (ImGui.Button("Apply##ByGuidName") && Guid.TryParse(_designIdentifier, out var guid1)) - // GlamourerIpc.ApplyByGuidSubscriber(_pluginInterface).Invoke(guid1, _gameObjectName); - // - //ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelApplyByGuidOnce); - //ImGui.TableNextColumn(); - //if (ImGui.Button("Apply Once##ByGuidName") && Guid.TryParse(_designIdentifier, out var guid1Once)) - // GlamourerIpc.ApplyByGuidOnceSubscriber(_pluginInterface).Invoke(guid1Once, _gameObjectName); - // - //ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelApplyByGuidToCharacter); - //ImGui.TableNextColumn(); - //if (ImGui.Button("Apply##ByGuidCharacter") && Guid.TryParse(_designIdentifier, out var guid2)) - // GlamourerIpc.ApplyByGuidToCharacterSubscriber(_pluginInterface) - // .Invoke(guid2, _objectManager.GetDalamudCharacter(_gameObjectIndex)); - // - //ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelApplyByGuidOnceToCharacter); - //ImGui.TableNextColumn(); - //if (ImGui.Button("Apply Once##ByGuidCharacter") && Guid.TryParse(_designIdentifier, out var guid2Once)) - // GlamourerIpc.ApplyByGuidOnceToCharacterSubscriber(_pluginInterface) - // .Invoke(guid2Once, _objectManager.GetDalamudCharacter(_gameObjectIndex)); - // - //ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelApplyAllLock); - //ImGui.TableNextColumn(); - //if (ImGui.Button("Apply With Lock##CustomizeCharacter")) - // GlamourerIpc.ApplyAllToCharacterLockSubscriber(_pluginInterface) - // .Invoke(_base64Apply, _objectManager.GetDalamudCharacter(_gameObjectIndex), 1337); - // - //ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelUnlock); - //ImGui.TableNextColumn(); - //if (ImGui.Button("Unlock##CustomizeCharacter")) - // GlamourerIpc.UnlockSubscriber(_pluginInterface) - // .Invoke(_objectManager.GetDalamudCharacter(_gameObjectIndex), 1337); - // - //ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelUnlockAll); - //ImGui.TableNextColumn(); - //if (ImGui.Button("Unlock All##CustomizeCharacter")) - // GlamourerIpc.UnlockAllSubscriber(_pluginInterface) - // .Invoke(1337); - // - //ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelRevertToAutomation); - //ImGui.TableNextColumn(); - //if (ImGui.Button("Revert##CustomizeCharacter")) - // GlamourerIpc.RevertToAutomationCharacterSubscriber(_pluginInterface) - // .Invoke(_objectManager.GetDalamudCharacter(_gameObjectIndex), 1337); - // - // - //ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelGetDesignList); - //ImGui.TableNextColumn(); - //var designList = GlamourerIpc.GetDesignListSubscriber(_pluginInterface) - // .Invoke(); - //if (ImGui.Button($"Copy {designList.Length} Designs to Clipboard###CopyDesignList")) - // ImGui.SetClipboardText(string.Join("\n", designList)); - // - //ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelSetItem); - //ImGui.TableNextColumn(); - //if (ImGui.Button("Set##SetItem")) - // _setItemEc = (GlamourerApiEc)GlamourerIpc.SetItemSubscriber(_pluginInterface) - // .Invoke(_objectManager.GetDalamudCharacter(_gameObjectIndex), (byte)_slot, _customItemId.Id, _stainId.Id, 1337); - //if (_setItemEc != GlamourerApiEc.Success) - //{ - // ImGui.SameLine(); - // ImGui.TextUnformatted(_setItemEc.ToString()); - //} - // - //ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelSetItemOnce); - //ImGui.TableNextColumn(); - //if (ImGui.Button("Set Once##SetItem")) - // _setItemOnceEc = (GlamourerApiEc)GlamourerIpc.SetItemOnceSubscriber(_pluginInterface) - // .Invoke(_objectManager.GetDalamudCharacter(_gameObjectIndex), (byte)_slot, _customItemId.Id, _stainId.Id, 1337); - //if (_setItemOnceEc != GlamourerApiEc.Success) - //{ - // ImGui.SameLine(); - // ImGui.TextUnformatted(_setItemOnceEc.ToString()); - //} - // - //ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelSetItemByActorName); - //ImGui.TableNextColumn(); - //if (ImGui.Button("Set##SetItemByActorName")) - // _setItemByActorNameEc = (GlamourerApiEc)GlamourerIpc.SetItemByActorNameSubscriber(_pluginInterface) - // .Invoke(_gameObjectName, (byte)_slot, _customItemId.Id, _stainId.Id, 1337); - //if (_setItemByActorNameEc != GlamourerApiEc.Success) - //{ - // ImGui.SameLine(); - // ImGui.TextUnformatted(_setItemByActorNameEc.ToString()); - //} - // - //ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelSetItemOnceByActorName); - //ImGui.TableNextColumn(); - //if (ImGui.Button("Set Once##SetItemByActorName")) - // _setItemOnceByActorNameEc = (GlamourerApiEc)GlamourerIpc.SetItemOnceByActorNameSubscriber(_pluginInterface) - // .Invoke(_gameObjectName, (byte)_slot, _customItemId.Id, _stainId.Id, 1337); - //if (_setItemOnceByActorNameEc != GlamourerApiEc.Success) - //{ - // ImGui.SameLine(); - // ImGui.TextUnformatted(_setItemOnceByActorNameEc.ToString()); - //} } private void Subscribe() diff --git a/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs b/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs index bcf7454..28b9506 100644 --- a/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs +++ b/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs @@ -28,6 +28,7 @@ public class StateIpcTester : IUiService, IDisposable private JObject? _state; private string? _stateString; private string _base64State = string.Empty; + private string? _getStateString; public readonly EventSubscriber StateChanged; private nint _lastStateChangeActor; @@ -92,6 +93,22 @@ public class StateIpcTester : IUiService, IDisposable ImGui.OpenPopup("State"); } + IpcTesterHelpers.DrawIntro(GetStateBase64.Label); + if (ImGui.Button("Get##Base64Idx")) + { + (_lastError, _getStateString) = new GetStateBase64(_pluginInterface).Invoke(_gameObjectIndex, _key); + _stateString = _getStateString ?? "No State Available"; + ImGui.OpenPopup("State"); + } + + IpcTesterHelpers.DrawIntro(GetStateBase64Name.Label); + if (ImGui.Button("Get##Base64Idx")) + { + (_lastError, _getStateString) = new GetStateBase64Name(_pluginInterface).Invoke(_gameObjectName, _key); + _stateString = _getStateString ?? "No State Available"; + ImGui.OpenPopup("State"); + } + IpcTesterHelpers.DrawIntro(ApplyState.Label); if (ImGuiUtil.DrawDisabledButton("Apply Last##Idx", Vector2.Zero, string.Empty, _state == null)) _lastError = new ApplyState(_pluginInterface).Invoke(_state!, _gameObjectIndex, _key, _flags); @@ -140,17 +157,24 @@ public class StateIpcTester : IUiService, IDisposable private void DrawStatePopup() { ImGui.SetNextWindowSize(ImGuiHelpers.ScaledVector2(500, 500)); + if (_stateString == null) + return; + using var p = ImRaii.Popup("State"); if (!p) return; if (ImGui.Button("Copy to Clipboard")) ImGui.SetClipboardText(_stateString); - ImGui.SameLine(); - if (ImGui.Button("Copy as Base64") && _state != null) - ImGui.SetClipboardText(DesignConverter.ToBase64(_state)); + if (_stateString[0] is '{') + { + ImGui.SameLine(); + if (ImGui.Button("Copy as Base64") && _state != null) + ImGui.SetClipboardText(DesignConverter.ToBase64(_state)); + } + using var font = ImRaii.PushFont(UiBuilder.MonoFont); - ImGui.TextUnformatted(_stateString); + ImGuiUtil.TextWrapped(_stateString ?? string.Empty); if (ImGui.Button("Close", -Vector2.UnitX) || !ImGui.IsWindowFocused()) ImGui.CloseCurrentPopup();