Add compatible IPC for now.

This commit is contained in:
Ottermandias 2023-06-22 14:02:36 +02:00
parent 1aba34f34a
commit 63e82d19dc
9 changed files with 392 additions and 305 deletions

View file

@ -3,10 +3,12 @@ using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Interface;
using Dalamud.Plugin;
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
using Glamourer.Api;
using Glamourer.Customization;
using Glamourer.Designs;
using Glamourer.Events;
@ -27,6 +29,7 @@ namespace Glamourer.Gui.Tabs;
public unsafe class DebugTab : ITab
{
private readonly DalamudPluginInterface _pluginInterface;
private readonly Configuration _config;
private readonly VisorService _visorService;
private readonly ChangeCustomizeService _changeCustomizeService;
@ -36,6 +39,7 @@ public unsafe class DebugTab : ITab
private readonly PenumbraService _penumbra;
private readonly ObjectTable _objects;
private readonly ObjectManager _objectManager;
private readonly GlamourerIpc _ipc;
private readonly ItemManager _items;
private readonly ActorService _actors;
@ -57,7 +61,7 @@ public unsafe class DebugTab : ITab
UpdateSlotService updateSlotService, WeaponService weaponService, PenumbraService penumbra,
ActorService actors, ItemManager items, CustomizationService customization, ObjectManager objectManager,
DesignFileSystem designFileSystem, DesignManager designManager, StateManager state, Configuration config,
PenumbraChangedItemTooltip penumbraTooltip, MetaService metaService)
PenumbraChangedItemTooltip penumbraTooltip, MetaService metaService, GlamourerIpc ipc, DalamudPluginInterface pluginInterface)
{
_changeCustomizeService = changeCustomizeService;
_visorService = visorService;
@ -74,7 +78,9 @@ public unsafe class DebugTab : ITab
_state = state;
_config = config;
_penumbraTooltip = penumbraTooltip;
_metaService = metaService;
_metaService = metaService;
_ipc = ipc;
_pluginInterface = pluginInterface;
}
public ReadOnlySpan<byte> Label
@ -91,6 +97,7 @@ public unsafe class DebugTab : ITab
DrawPenumbraHeader();
DrawDesigns();
DrawState();
DrawIpc();
}
#region Interop
@ -778,7 +785,7 @@ public unsafe class DebugTab : ITab
return;
ImGui.SetNextItemWidth(-1);
ImGui.InputTextWithHint("##base64", "Base 64 input...", ref _base64, 2048);
ImGui.InputTextWithHint("##base64", "Base 64 input...", ref _base64, 2047);
if (ImGui.IsItemDeactivatedAfterEdit())
{
try
@ -1108,4 +1115,86 @@ public unsafe class DebugTab : ITab
}
#endregion
#region IPC
private string _gameObjectName = string.Empty;
private string _base64Apply = string.Empty;
private void DrawIpc()
{
if (!ImGui.CollapsingHeader("IPC Tester"))
return;
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);
using var table = ImRaii.Table("##ipc", 2, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg);
if (!table)
return;
ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelApiVersions);
var (major, minor) = GlamourerIpc.ApiVersionsSubscriber(_pluginInterface).Invoke();
ImGuiUtil.DrawTableColumn($"({major}, {minor})");
ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelGetAllCustomization);
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(_objects[_gameObjectIndex] as Character);
if (base64 != null)
ImGuiUtil.CopyOnClickSelectable(base64);
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(_objects[_gameObjectIndex] as Character);
ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelApplyAll);
ImGui.TableNextColumn();
if (ImGui.Button("Apply##AllName"))
GlamourerIpc.ApplyAllSubscriber(_pluginInterface).Invoke(_base64Apply, _gameObjectName);
ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelApplyAllToCharacter);
ImGui.TableNextColumn();
if (ImGui.Button("Apply##AllCharacter"))
GlamourerIpc.ApplyAllToCharacterSubscriber(_pluginInterface).Invoke(_base64Apply, _objects[_gameObjectIndex] as Character);
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, _objects[_gameObjectIndex] as Character);
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, _objects[_gameObjectIndex] as Character);
}
#endregion
}