mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-07 08:24:37 +01:00
Add Self Test
This commit is contained in:
parent
282fa87571
commit
b2397efb25
1 changed files with 72 additions and 6 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Game.Chat;
|
||||
using Dalamud.Game.Gui;
|
||||
using Dalamud.Game.Text;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
|
|
@ -12,8 +13,12 @@ namespace Dalamud.Interface.Internal.Windows.SelfTest.Steps;
|
|||
internal class ChatSelfTestStep : ISelfTestStep
|
||||
{
|
||||
private int step = 0;
|
||||
private bool subscribed = false;
|
||||
private bool subscribedChatMessage = false;
|
||||
private bool subscribedLogMessage = false;
|
||||
private bool hasPassed = false;
|
||||
private bool hasTeleportGil = false;
|
||||
private bool hasTeleportTicket = false;
|
||||
private int teleportCount = 0;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string Name => "Test Chat";
|
||||
|
|
@ -34,20 +39,63 @@ internal class ChatSelfTestStep : ISelfTestStep
|
|||
case 1:
|
||||
ImGui.Text("Type \"/e DALAMUD\" in chat...");
|
||||
|
||||
if (!this.subscribed)
|
||||
if (!this.subscribedChatMessage)
|
||||
{
|
||||
this.subscribed = true;
|
||||
this.subscribedChatMessage = true;
|
||||
chatGui.ChatMessage += this.ChatOnOnChatMessage;
|
||||
}
|
||||
|
||||
if (this.hasPassed)
|
||||
{
|
||||
chatGui.ChatMessage -= this.ChatOnOnChatMessage;
|
||||
this.subscribed = false;
|
||||
return SelfTestStepResult.Pass;
|
||||
this.subscribedChatMessage = false;
|
||||
this.step++;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 2:
|
||||
ImGui.Text("Teleport somewhere...");
|
||||
|
||||
if (!this.subscribedLogMessage)
|
||||
{
|
||||
this.subscribedLogMessage = true;
|
||||
chatGui.LogMessage += this.ChatOnLogMessage;
|
||||
}
|
||||
|
||||
if (this.hasTeleportGil)
|
||||
{
|
||||
ImGui.Text($"You spent {this.teleportCount} gil to teleport.");
|
||||
}
|
||||
if (this.hasTeleportTicket)
|
||||
{
|
||||
ImGui.Text($"You used a ticket to teleport and have {this.teleportCount} remaining.");
|
||||
}
|
||||
|
||||
if (this.hasTeleportGil || this.hasTeleportTicket)
|
||||
{
|
||||
ImGui.Text("Is this correct?");
|
||||
|
||||
if (ImGui.Button("Yes"))
|
||||
{
|
||||
chatGui.LogMessage -= this.ChatOnLogMessage;
|
||||
this.subscribedLogMessage = false;
|
||||
this.step++;
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button("No"))
|
||||
{
|
||||
chatGui.LogMessage -= this.ChatOnLogMessage;
|
||||
this.subscribedLogMessage = false;
|
||||
return SelfTestStepResult.Fail;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
return SelfTestStepResult.Pass;
|
||||
}
|
||||
|
||||
return SelfTestStepResult.Waiting;
|
||||
|
|
@ -59,7 +107,9 @@ internal class ChatSelfTestStep : ISelfTestStep
|
|||
var chatGui = Service<ChatGui>.Get();
|
||||
|
||||
chatGui.ChatMessage -= this.ChatOnOnChatMessage;
|
||||
this.subscribed = false;
|
||||
chatGui.LogMessage -= this.ChatOnLogMessage;
|
||||
this.subscribedChatMessage = false;
|
||||
this.subscribedLogMessage = false;
|
||||
}
|
||||
|
||||
private void ChatOnOnChatMessage(
|
||||
|
|
@ -70,4 +120,20 @@ internal class ChatSelfTestStep : ISelfTestStep
|
|||
this.hasPassed = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void ChatOnLogMessage(ILogMessage message)
|
||||
{
|
||||
if (message.LogMessageId == 4590 && message.TryGetIntParameter(0, out var value))
|
||||
{
|
||||
this.hasTeleportGil = true;
|
||||
this.hasTeleportTicket = false;
|
||||
this.teleportCount = value;
|
||||
}
|
||||
if (message.LogMessageId == 4591 && message.TryGetIntParameter(0, out var item) && item == 7569 && message.TryGetIntParameter(1, out var remaining))
|
||||
{
|
||||
this.hasTeleportGil = false;
|
||||
this.hasTeleportTicket = true;
|
||||
this.teleportCount = remaining;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue