Add Completion module (#2274)

* Add Completion module

Dalamud and plugin commands will now be tab-completable in the ChatLog

* PR feedback

---------

Co-authored-by: goat <16760685+goaaats@users.noreply.github.com>
This commit is contained in:
salanth357 2025-05-29 14:24:21 -04:00 committed by GitHub
parent 944c3700db
commit 84d121c7bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 438 additions and 4 deletions

View file

@ -57,7 +57,8 @@ internal class SelfTestWindow : Window
new SheetRedirectResolverSelfTestStep(),
new NounProcessorSelfTestStep(),
new SeStringEvaluatorSelfTestStep(),
new LogoutEventSelfTestStep()
new LogoutEventSelfTestStep(),
new CompletionSelfTestStep()
];
private readonly Dictionary<int, (SelfTestStepResult Result, TimeSpan? Duration)> testIndexToResult = new();

View file

@ -0,0 +1,94 @@
using Dalamud.Game.Command;
using Dalamud.Game.Gui;
using Dalamud.Game.Text;
using Dalamud.Game.Text.SeStringHandling;
using ImGuiNET;
namespace Dalamud.Interface.Internal.Windows.SelfTest.Steps;
/// <summary>
/// Test setup for Chat.
/// </summary>
internal class CompletionSelfTestStep : ISelfTestStep
{
private int step = 0;
private bool registered;
private bool commandRun;
/// <inheritdoc/>
public string Name => "Test Completion";
/// <inheritdoc/>
public SelfTestStepResult RunStep()
{
var cmdManager = Service<CommandManager>.Get();
switch (this.step)
{
case 0:
this.step++;
break;
case 1:
ImGui.Text("[Chat Log]");
ImGui.Text("Use the category menus to navigate to [Dalamud], then complete a command from the list. Did it work?");
if (ImGui.Button("Yes"))
this.step++;
ImGui.SameLine();
if (ImGui.Button("No"))
return SelfTestStepResult.Fail;
break;
case 2:
ImGui.Text("[Chat Log]");
ImGui.Text("Type /xl into the chat log and tab-complete a dalamud command. Did it work?");
if (ImGui.Button("Yes"))
this.step++;
ImGui.SameLine();
if (ImGui.Button("No"))
return SelfTestStepResult.Fail;
break;
case 3:
ImGui.Text("[Chat Log]");
if (!this.registered)
{
cmdManager.AddHandler("/xlselftestcompletion", new CommandInfo((_, _) => this.commandRun = true));
this.registered = true;
}
ImGui.Text("Tab-complete /xlselftestcompletion in the chat log and send the command");
if (this.commandRun)
this.step++;
break;
case 4:
ImGui.Text("[Other text inputs]");
ImGui.Text("Open the party finder recruitment criteria dialog and try to tab-complete /xldev in the text box.");
ImGui.Text("Did the command appear in the text box? (It should not have)");
if (ImGui.Button("Yes"))
return SelfTestStepResult.Fail;
ImGui.SameLine();
if (ImGui.Button("No"))
this.step++;
break;
case 5:
return SelfTestStepResult.Pass;
}
return SelfTestStepResult.Waiting;
}
/// <inheritdoc/>
public void CleanUp()
{
Service<CommandManager>.Get().RemoveHandler("/completionselftest");
}
}