|
| 1 | +using Dalamud.Game.ClientState.Objects.Types; |
| 2 | +using Dalamud.Interface.Utility.Raii; |
| 3 | +using Dalamud.Interface.Windowing; |
| 4 | +using Dalamud.Plugin; |
| 5 | +using Dalamud.Plugin.Ipc; |
| 6 | +using ImGuiNET; |
| 7 | +using System.Numerics; |
| 8 | + |
| 9 | +namespace BrioTester.Plugin.UI; |
| 10 | + |
| 11 | +public class BrioTesterWindow : Window |
| 12 | +{ |
| 13 | + private BrioTester _plugin { get; } |
| 14 | + |
| 15 | + // |
| 16 | + |
| 17 | + private (int, int) ver; |
| 18 | + private IGameObject? gameObject; |
| 19 | + |
| 20 | + // |
| 21 | + |
| 22 | + private ICallGateSubscriber<(int, int)> API_Version_IPC; |
| 23 | + |
| 24 | + private ICallGateSubscriber<IGameObject?> Actor_Spawn_IPC; |
| 25 | + private ICallGateSubscriber<Task<IGameObject?>> Actor_SpawnAsync_IPC; |
| 26 | + private ICallGateSubscriber<bool, bool, Task<IGameObject?>> Actor_SpawnExAsync_IPC; |
| 27 | + |
| 28 | + private ICallGateSubscriber<IGameObject, bool> Actor_DespawnActor_Ipc; |
| 29 | + private ICallGateSubscriber<IGameObject, Task<bool>> Actor_DespawnActorAsync_Ipc; |
| 30 | + |
| 31 | + private ICallGateSubscriber<IGameObject, Vector3, Quaternion, Vector3, bool> Actor_SetModelTransform_IPC; |
| 32 | + private ICallGateSubscriber<IGameObject, (Vector3?, Quaternion?, Vector3?)> Actor_GetModelTransform_IPC; |
| 33 | + |
| 34 | + // |
| 35 | + |
| 36 | + public BrioTesterWindow(IDalamudPluginInterface pluginInterface, BrioTester plugin) : base($" {BrioTester.PluginName}") |
| 37 | + { |
| 38 | + _plugin = plugin; |
| 39 | + |
| 40 | + API_Version_IPC = pluginInterface.GetIpcSubscriber<(int, int)>("Brio.ApiVersion"); |
| 41 | + |
| 42 | + Actor_Spawn_IPC = pluginInterface.GetIpcSubscriber<IGameObject?>("Brio.Actor.Spawn"); |
| 43 | + Actor_SpawnAsync_IPC = pluginInterface.GetIpcSubscriber<Task<IGameObject?>>("Brio.Actor.SpawnAsync"); |
| 44 | + Actor_SpawnExAsync_IPC = pluginInterface.GetIpcSubscriber<bool, bool, Task<IGameObject?>>("Brio.Actor.SpawnExAsync"); |
| 45 | + |
| 46 | + Actor_DespawnActor_Ipc = pluginInterface.GetIpcSubscriber<IGameObject, bool>("Brio.Actor.Despawn"); |
| 47 | + Actor_DespawnActorAsync_Ipc = pluginInterface.GetIpcSubscriber<IGameObject, Task<bool>>("Brio.Actor.DespawnAsync"); |
| 48 | + |
| 49 | + Actor_SetModelTransform_IPC = pluginInterface.GetIpcSubscriber<IGameObject, Vector3, Quaternion, Vector3, bool>("Brio.Actor.SetModelTransform"); |
| 50 | + Actor_GetModelTransform_IPC = pluginInterface.GetIpcSubscriber<IGameObject, (Vector3?, Quaternion?, Vector3?)>("Brio.Actor.GetModelTransform"); |
| 51 | + |
| 52 | + SizeConstraints = new WindowSizeConstraints |
| 53 | + { |
| 54 | + MinimumSize = new Vector2(520, 360), |
| 55 | + MaximumSize = new Vector2(1040, 720) |
| 56 | + }; |
| 57 | + } |
| 58 | + |
| 59 | + string logText; |
| 60 | + public override void Draw() |
| 61 | + { |
| 62 | + var segmentSize = ImGui.GetWindowSize().X / 4.5f; |
| 63 | + var buttonSize = new Vector2(segmentSize, ImGui.GetTextLineHeight() * 1.8f); |
| 64 | + |
| 65 | + using (var textGroup = ImRaii.Group()) |
| 66 | + { |
| 67 | + if (textGroup.Success) |
| 68 | + { |
| 69 | + ImGui.PushTextWrapPos(segmentSize * 4); |
| 70 | + ImGui.TextWrapped(logText); |
| 71 | + ImGui.PopTextWrapPos(); |
| 72 | + } |
| 73 | + } |
| 74 | + |
| 75 | + using var buttonGroup = ImRaii.Group(); |
| 76 | + if (buttonGroup.Success) |
| 77 | + { |
| 78 | + ImGui.PushStyleColor(ImGuiCol.Button, new Vector4(255, 0, 0, 255) / 255); |
| 79 | + if (ImGui.Button("brio v." + ver, buttonSize)) |
| 80 | + { |
| 81 | + ver = API_Version_IPC.InvokeFunc(); |
| 82 | + } |
| 83 | + ImGui.PopStyleColor(); |
| 84 | + ImGui.SameLine(); |
| 85 | + |
| 86 | + ImGui.PushStyleColor(ImGuiCol.Button, new Vector4(86, 98, 246, 255) / 255); |
| 87 | + if (ImGui.Button("spawn " + gameObject?.Name, buttonSize)) |
| 88 | + { |
| 89 | + gameObject = Actor_Spawn_IPC.InvokeFunc(); |
| 90 | + } |
| 91 | + ImGui.PopStyleColor(); |
| 92 | + ImGui.SameLine(); |
| 93 | + |
| 94 | + ImGui.PushStyleColor(ImGuiCol.Button, new Vector4(0, 100, 255, 255) / 255); |
| 95 | + if (ImGui.Button("despawn " + gameObject?.Name, buttonSize)) |
| 96 | + { |
| 97 | + if (gameObject is not null) |
| 98 | + Actor_DespawnActor_Ipc.InvokeFunc(gameObject); |
| 99 | + } |
| 100 | + ImGui.PopStyleColor(); |
| 101 | + ImGui.SameLine(); |
| 102 | + |
| 103 | + ImGui.PushStyleColor(ImGuiCol.Button, new Vector4(110, 84, 148, 255) / 255); |
| 104 | + if (ImGui.Button("move ", buttonSize)) |
| 105 | + { |
| 106 | + if (gameObject is not null) |
| 107 | + { |
| 108 | + var act = Actor_GetModelTransform_IPC.InvokeFunc(gameObject); |
| 109 | + logText += $"{act} \n"; |
| 110 | + Actor_SetModelTransform_IPC.InvokeFunc(gameObject, act.Item1.GetValueOrDefault() + new Vector3(10, 0, 10), act.Item2.GetValueOrDefault(), act.Item3.GetValueOrDefault()); |
| 111 | + } |
| 112 | + } |
| 113 | + ImGui.PopStyleColor(); |
| 114 | + ImGui.SameLine(); |
| 115 | + } |
| 116 | + } |
| 117 | +} |
0 commit comments