Skip to content

Commit 94a37f9

Browse files
committed
Add primitive IPC tester
1 parent 430bef4 commit 94a37f9

7 files changed

+347
-0
lines changed

BrioTester.sln

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Microsoft Visual Studio Solution File, Format Version 12.00
2+
# Visual Studio Version 17
3+
VisualStudioVersion = 17.13.35507.96
4+
MinimumVisualStudioVersion = 10.0.40219.1
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BrioTester", "BrioTester\BrioTester.csproj", "{E20A4046-E8C5-BDB1-282C-F2BC3231E687}"
6+
EndProject
7+
Global
8+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
9+
Debug|x64 = Debug|x64
10+
Release|x64 = Release|x64
11+
EndGlobalSection
12+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
13+
{E20A4046-E8C5-BDB1-282C-F2BC3231E687}.Debug|x64.ActiveCfg = Debug|x64
14+
{E20A4046-E8C5-BDB1-282C-F2BC3231E687}.Debug|x64.Build.0 = Debug|x64
15+
{E20A4046-E8C5-BDB1-282C-F2BC3231E687}.Release|x64.ActiveCfg = Release|x64
16+
{E20A4046-E8C5-BDB1-282C-F2BC3231E687}.Release|x64.Build.0 = Release|x64
17+
EndGlobalSection
18+
GlobalSection(SolutionProperties) = preSolution
19+
HideSolutionNode = FALSE
20+
EndGlobalSection
21+
GlobalSection(ExtensibilityGlobals) = postSolution
22+
SolutionGuid = {6A991217-5AC2-4125-AB33-D78DDED973AE}
23+
EndGlobalSection
24+
EndGlobal

BrioTester/BrioTester.cs

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
using BrioTester.Plugin.UI;
2+
using Dalamud.Game;
3+
using Dalamud.Game.ClientState.Objects;
4+
using Dalamud.Game.Command;
5+
using Dalamud.Interface.Windowing;
6+
using Dalamud.IoC;
7+
using Dalamud.Plugin;
8+
using Dalamud.Plugin.Services;
9+
10+
namespace BrioTester.Plugin;
11+
12+
public class BrioTester : IDalamudPlugin
13+
{
14+
public const string PluginName = "BrioTester";
15+
public string Name => PluginName;
16+
17+
private const string CommandName = "/btw";
18+
19+
[PluginService]
20+
public ICommandManager CommandManager { get; init; } = null!;
21+
22+
[PluginService]
23+
public IFramework Framework { get; init; } = null!;
24+
25+
[PluginService]
26+
public ISigScanner SigScanner { get; init; } = null!;
27+
28+
[PluginService]
29+
public IObjectTable ObjectTable { get; init; } = null!;
30+
31+
[PluginService]
32+
public IGameInteropProvider GameInteropProvider { get; init; } = null!;
33+
34+
[PluginService]
35+
public IClientState ClientState { get; init; } = null!;
36+
37+
public IDalamudPluginInterface PluginInterface { get; }
38+
39+
public BrioTesterWindow Window { get; }
40+
public WindowSystem WindowSystem { get; }
41+
42+
public bool IsInGPose { get; private set; }
43+
44+
public BrioTester(IDalamudPluginInterface pluginInterface)
45+
{
46+
this.PluginInterface = pluginInterface;
47+
this.PluginInterface.Inject(this);
48+
49+
this.PluginInterface.UiBuilder.DisableGposeUiHide = true;
50+
this.PluginInterface.UiBuilder.DisableCutsceneUiHide = true;
51+
this.PluginInterface.UiBuilder.Draw += DrawUI;
52+
this.Framework.Update += Update;
53+
54+
this.CommandManager.AddHandler(CommandName, new CommandInfo(OnCommand)
55+
{
56+
HelpMessage = "A very useful message!"
57+
});
58+
59+
this.Window = new(pluginInterface, this);
60+
this.WindowSystem = new(PluginName);
61+
this.WindowSystem.AddWindow(Window);
62+
63+
Window.IsOpen = true;
64+
}
65+
66+
private void OnCommand(string command, string args)
67+
{
68+
Window? window = this.Window;
69+
70+
if (window != null)
71+
{
72+
if (window.IsOpen)
73+
{
74+
window.IsOpen = false;
75+
}
76+
else
77+
{
78+
window.IsOpen = true;
79+
}
80+
}
81+
}
82+
83+
private void DrawUI()
84+
{
85+
this.WindowSystem.Draw();
86+
}
87+
88+
private void Update(IFramework framework)
89+
{
90+
if (ClientState.IsGPosing && IsInGPose == false)
91+
{
92+
IsInGPose = true;
93+
94+
Window.IsOpen = true;
95+
}
96+
else if (ClientState.IsGPosing == false && IsInGPose)
97+
{
98+
IsInGPose = false;
99+
}
100+
}
101+
102+
public void Dispose()
103+
{
104+
Framework.Update -= Update;
105+
106+
this.CommandManager.RemoveHandler(CommandName);
107+
108+
this.PluginInterface.UiBuilder.Draw -= DrawUI;
109+
110+
this.WindowSystem.RemoveAllWindows();
111+
}
112+
}

BrioTester/BrioTester.csproj

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0-windows</TargetFramework>
5+
<Platforms>x64</Platforms>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
9+
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
10+
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
11+
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
12+
<Version>0.0.0.1</Version>
13+
</PropertyGroup>
14+
15+
<PropertyGroup>
16+
<DalamudLibPath>$(appdata)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath>
17+
</PropertyGroup>
18+
19+
<ItemGroup>
20+
<PackageReference Include="DalamudPackager" Version="11.0.0" />
21+
<Reference Include="FFXIVClientStructs">
22+
<HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath>
23+
<Private>false</Private>
24+
</Reference>
25+
<Reference Include="Newtonsoft.Json">
26+
<HintPath>$(DalamudLibPath)Newtonsoft.Json.dll</HintPath>
27+
<Private>false</Private>
28+
</Reference>
29+
<Reference Include="Dalamud">
30+
<HintPath>$(DalamudLibPath)Dalamud.dll</HintPath>
31+
<Private>false</Private>
32+
</Reference>
33+
<Reference Include="ImGui.NET">
34+
<HintPath>$(DalamudLibPath)ImGui.NET.dll</HintPath>
35+
<Private>false</Private>
36+
</Reference>
37+
<Reference Include="ImGuiScene">
38+
<HintPath>$(DalamudLibPath)ImGuiScene.dll</HintPath>
39+
<Private>false</Private>
40+
</Reference>
41+
<Reference Include="Lumina">
42+
<HintPath>$(DalamudLibPath)Lumina.dll</HintPath>
43+
<Private>false</Private>
44+
</Reference>
45+
<Reference Include="Lumina.Excel">
46+
<HintPath>$(DalamudLibPath)Lumina.Excel.dll</HintPath>
47+
<Private>false</Private>
48+
</Reference>
49+
</ItemGroup>
50+
51+
<ItemGroup>
52+
<PackageReference Include="DalamudPackager" Version="11.0.0" />
53+
</ItemGroup>
54+
55+
<ItemGroup>
56+
<None Update="BrioTester.json">
57+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
58+
</None>
59+
</ItemGroup>
60+
61+
</Project>

BrioTester/BrioTester.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"Author": "Brio Contributors",
3+
"Name": "Brio Tester",
4+
"Punchline": "...",
5+
"Description": "...",
6+
"AssemblyVersion": "x.x.x.x",
7+
"InternalName": "BrioTester",
8+
"ApplicableVersion": "any",
9+
"Tags": ["brio"]
10+
}

BrioTester/DalamudPackager.targets

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project>
3+
<Target Name="PackagePlugin" AfterTargets="Build">
4+
<DalamudPackager
5+
ProjectDir="$(ProjectDir)"
6+
OutputPath="$(OutputPath)"
7+
AssemblyName="$(AssemblyName)"
8+
MakeZip="false"/>
9+
</Target>
10+
</Project>

BrioTester/UI/BrioTesterWindow.cs

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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+
}

BrioTester/packages.lock.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": 1,
3+
"dependencies": {
4+
"net8.0-windows7.0": {
5+
"DalamudPackager": {
6+
"type": "Direct",
7+
"requested": "[11.0.0, )",
8+
"resolved": "11.0.0",
9+
"contentHash": "bjT7XUlhIJSmsE/O76b7weUX+evvGQctbQB8aKXt94o+oPWxHpCepxAGMs7Thow3AzCyqWs7cOpp9/2wcgRRQA=="
10+
}
11+
}
12+
}
13+
}

0 commit comments

Comments
 (0)