Revert "refactor(Dalamud): switch to file-scoped namespaces"

This reverts commit b5f34c3199.
This commit is contained in:
goat 2021-11-18 15:23:40 +01:00
parent d473826247
commit 1561fbac00
No known key found for this signature in database
GPG key ID: 7773BB5B43BA52E5
325 changed files with 45549 additions and 45209 deletions

View file

@ -2,46 +2,47 @@ using Dalamud.Game.ClientState.Objects;
using Dalamud.Utility;
using ImGuiNET;
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps;
/// <summary>
/// Test setup for the Actor Table.
/// </summary>
internal class ActorTableAgingStep : IAgingStep
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps
{
private int index = 0;
/// <inheritdoc/>
public string Name => "Test ActorTable";
/// <inheritdoc/>
public SelfTestStepResult RunStep()
/// <summary>
/// Test setup for the Actor Table.
/// </summary>
internal class ActorTableAgingStep : IAgingStep
{
var objectTable = Service<ObjectTable>.Get();
private int index = 0;
ImGui.Text("Checking actor table...");
/// <inheritdoc/>
public string Name => "Test ActorTable";
if (this.index == objectTable.Length - 1)
/// <inheritdoc/>
public SelfTestStepResult RunStep()
{
return SelfTestStepResult.Pass;
}
var objectTable = Service<ObjectTable>.Get();
var actor = objectTable[this.index];
this.index++;
ImGui.Text("Checking actor table...");
if (this.index == objectTable.Length - 1)
{
return SelfTestStepResult.Pass;
}
var actor = objectTable[this.index];
this.index++;
if (actor == null)
{
return SelfTestStepResult.Waiting;
}
Util.ShowObject(actor);
if (actor == null)
{
return SelfTestStepResult.Waiting;
}
Util.ShowObject(actor);
return SelfTestStepResult.Waiting;
}
/// <inheritdoc/>
public void CleanUp()
{
// ignored
/// <inheritdoc/>
public void CleanUp()
{
// ignored
}
}
}

View file

@ -3,70 +3,71 @@ using Dalamud.Game.Text;
using Dalamud.Game.Text.SeStringHandling;
using ImGuiNET;
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps;
/// <summary>
/// Test setup for Chat.
/// </summary>
internal class ChatAgingStep : IAgingStep
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps
{
private int step = 0;
private bool subscribed = false;
private bool hasPassed = false;
/// <inheritdoc/>
public string Name => "Test Chat";
/// <inheritdoc/>
public SelfTestStepResult RunStep()
/// <summary>
/// Test setup for Chat.
/// </summary>
internal class ChatAgingStep : IAgingStep
{
var chatGui = Service<ChatGui>.Get();
private int step = 0;
private bool subscribed = false;
private bool hasPassed = false;
switch (this.step)
/// <inheritdoc/>
public string Name => "Test Chat";
/// <inheritdoc/>
public SelfTestStepResult RunStep()
{
case 0:
chatGui.Print("Testing!");
this.step++;
var chatGui = Service<ChatGui>.Get();
break;
switch (this.step)
{
case 0:
chatGui.Print("Testing!");
this.step++;
case 1:
ImGui.Text("Type \"/e DALAMUD\" in chat...");
break;
if (!this.subscribed)
{
this.subscribed = true;
chatGui.ChatMessage += this.ChatOnOnChatMessage;
}
case 1:
ImGui.Text("Type \"/e DALAMUD\" in chat...");
if (this.hasPassed)
{
chatGui.ChatMessage -= this.ChatOnOnChatMessage;
this.subscribed = false;
return SelfTestStepResult.Pass;
}
if (!this.subscribed)
{
this.subscribed = true;
chatGui.ChatMessage += this.ChatOnOnChatMessage;
}
break;
if (this.hasPassed)
{
chatGui.ChatMessage -= this.ChatOnOnChatMessage;
this.subscribed = false;
return SelfTestStepResult.Pass;
}
break;
}
return SelfTestStepResult.Waiting;
}
return SelfTestStepResult.Waiting;
}
/// <inheritdoc/>
public void CleanUp()
{
var chatGui = Service<ChatGui>.Get();
chatGui.ChatMessage -= this.ChatOnOnChatMessage;
this.subscribed = false;
}
private void ChatOnOnChatMessage(
XivChatType type, uint senderid, ref SeString sender, ref SeString message, ref bool ishandled)
{
if (type == XivChatType.Echo && message.TextValue == "DALAMUD")
/// <inheritdoc/>
public void CleanUp()
{
this.hasPassed = true;
var chatGui = Service<ChatGui>.Get();
chatGui.ChatMessage -= this.ChatOnOnChatMessage;
this.subscribed = false;
}
private void ChatOnOnChatMessage(
XivChatType type, uint senderid, ref SeString sender, ref SeString message, ref bool ishandled)
{
if (type == XivChatType.Echo && message.TextValue == "DALAMUD")
{
this.hasPassed = true;
}
}
}
}

View file

@ -2,35 +2,36 @@ using Dalamud.Game.ClientState.Conditions;
using ImGuiNET;
using Serilog;
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps;
/// <summary>
/// Test setup for Condition.
/// </summary>
internal class ConditionAgingStep : IAgingStep
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps
{
/// <inheritdoc/>
public string Name => "Test Condition";
/// <inheritdoc/>
public SelfTestStepResult RunStep()
/// <summary>
/// Test setup for Condition.
/// </summary>
internal class ConditionAgingStep : IAgingStep
{
var condition = Service<Condition>.Get();
/// <inheritdoc/>
public string Name => "Test Condition";
if (!condition.Any())
/// <inheritdoc/>
public SelfTestStepResult RunStep()
{
Log.Error("No condition flags present.");
return SelfTestStepResult.Fail;
var condition = Service<Condition>.Get();
if (!condition.Any())
{
Log.Error("No condition flags present.");
return SelfTestStepResult.Fail;
}
ImGui.Text("Please jump...");
return condition[ConditionFlag.Jumping] ? SelfTestStepResult.Pass : SelfTestStepResult.Waiting;
}
ImGui.Text("Please jump...");
return condition[ConditionFlag.Jumping] ? SelfTestStepResult.Pass : SelfTestStepResult.Waiting;
}
/// <inheritdoc/>
public void CleanUp()
{
// ignored
/// <inheritdoc/>
public void CleanUp()
{
// ignored
}
}
}

View file

@ -1,69 +1,70 @@
using Dalamud.Game.ClientState;
using ImGuiNET;
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps;
/// <summary>
/// Test setup for Territory Change.
/// </summary>
internal class EnterTerritoryAgingStep : IAgingStep
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps
{
private readonly ushort territory;
private readonly string terriName;
private bool subscribed = false;
private bool hasPassed = false;
/// <summary>
/// Initializes a new instance of the <see cref="EnterTerritoryAgingStep"/> class.
/// Test setup for Territory Change.
/// </summary>
/// <param name="terri">The territory to check for.</param>
/// <param name="name">Name to show.</param>
public EnterTerritoryAgingStep(ushort terri, string name)
internal class EnterTerritoryAgingStep : IAgingStep
{
this.terriName = name;
this.territory = terri;
}
private readonly ushort territory;
private readonly string terriName;
private bool subscribed = false;
private bool hasPassed = false;
/// <inheritdoc/>
public string Name => $"Enter Terri: {this.terriName}";
/// <inheritdoc/>
public SelfTestStepResult RunStep()
{
var clientState = Service<ClientState>.Get();
ImGui.TextUnformatted(this.Name);
if (!this.subscribed)
/// <summary>
/// Initializes a new instance of the <see cref="EnterTerritoryAgingStep"/> class.
/// </summary>
/// <param name="terri">The territory to check for.</param>
/// <param name="name">Name to show.</param>
public EnterTerritoryAgingStep(ushort terri, string name)
{
clientState.TerritoryChanged += this.ClientStateOnTerritoryChanged;
this.subscribed = true;
this.terriName = name;
this.territory = terri;
}
if (this.hasPassed)
/// <inheritdoc/>
public string Name => $"Enter Terri: {this.terriName}";
/// <inheritdoc/>
public SelfTestStepResult RunStep()
{
var clientState = Service<ClientState>.Get();
ImGui.TextUnformatted(this.Name);
if (!this.subscribed)
{
clientState.TerritoryChanged += this.ClientStateOnTerritoryChanged;
this.subscribed = true;
}
if (this.hasPassed)
{
clientState.TerritoryChanged -= this.ClientStateOnTerritoryChanged;
this.subscribed = false;
return SelfTestStepResult.Pass;
}
return SelfTestStepResult.Waiting;
}
/// <inheritdoc/>
public void CleanUp()
{
var clientState = Service<ClientState>.Get();
clientState.TerritoryChanged -= this.ClientStateOnTerritoryChanged;
this.subscribed = false;
return SelfTestStepResult.Pass;
}
return SelfTestStepResult.Waiting;
}
/// <inheritdoc/>
public void CleanUp()
{
var clientState = Service<ClientState>.Get();
clientState.TerritoryChanged -= this.ClientStateOnTerritoryChanged;
this.subscribed = false;
}
private void ClientStateOnTerritoryChanged(object sender, ushort e)
{
if (e == this.territory)
private void ClientStateOnTerritoryChanged(object sender, ushort e)
{
this.hasPassed = true;
if (e == this.territory)
{
this.hasPassed = true;
}
}
}
}

View file

@ -2,46 +2,47 @@ using Dalamud.Game.ClientState.Fates;
using Dalamud.Utility;
using ImGuiNET;
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps;
/// <summary>
/// Test setup for the Fate Table.
/// </summary>
internal class FateTableAgingStep : IAgingStep
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps
{
private int index = 0;
/// <inheritdoc/>
public string Name => "Test FateTable";
/// <inheritdoc/>
public SelfTestStepResult RunStep()
/// <summary>
/// Test setup for the Fate Table.
/// </summary>
internal class FateTableAgingStep : IAgingStep
{
var fateTable = Service<FateTable>.Get();
private int index = 0;
ImGui.Text("Checking fate table...");
/// <inheritdoc/>
public string Name => "Test FateTable";
if (this.index == fateTable.Length - 1)
/// <inheritdoc/>
public SelfTestStepResult RunStep()
{
return SelfTestStepResult.Pass;
}
var fateTable = Service<FateTable>.Get();
var actor = fateTable[this.index];
this.index++;
ImGui.Text("Checking fate table...");
if (this.index == fateTable.Length - 1)
{
return SelfTestStepResult.Pass;
}
var actor = fateTable[this.index];
this.index++;
if (actor == null)
{
return SelfTestStepResult.Waiting;
}
Util.ShowObject(actor);
if (actor == null)
{
return SelfTestStepResult.Waiting;
}
Util.ShowObject(actor);
return SelfTestStepResult.Waiting;
}
/// <inheritdoc/>
public void CleanUp()
{
// ignored
/// <inheritdoc/>
public void CleanUp()
{
// ignored
}
}
}

View file

@ -1,36 +1,37 @@
using Dalamud.Game.ClientState.GamePad;
using ImGuiNET;
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps;
/// <summary>
/// Test setup for the Gamepad State.
/// </summary>
internal class GamepadStateAgingStep : IAgingStep
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps
{
/// <inheritdoc/>
public string Name => "Test GamePadState";
/// <inheritdoc/>
public SelfTestStepResult RunStep()
/// <summary>
/// Test setup for the Gamepad State.
/// </summary>
internal class GamepadStateAgingStep : IAgingStep
{
var gamepadState = Service<GamepadState>.Get();
/// <inheritdoc/>
public string Name => "Test GamePadState";
ImGui.Text("Hold down North, East, L1");
if (gamepadState.Pressed(GamepadButtons.North) == 1
&& gamepadState.Pressed(GamepadButtons.East) == 1
&& gamepadState.Pressed(GamepadButtons.L1) == 1)
/// <inheritdoc/>
public SelfTestStepResult RunStep()
{
return SelfTestStepResult.Pass;
var gamepadState = Service<GamepadState>.Get();
ImGui.Text("Hold down North, East, L1");
if (gamepadState.Pressed(GamepadButtons.North) == 1
&& gamepadState.Pressed(GamepadButtons.East) == 1
&& gamepadState.Pressed(GamepadButtons.L1) == 1)
{
return SelfTestStepResult.Pass;
}
return SelfTestStepResult.Waiting;
}
return SelfTestStepResult.Waiting;
}
/// <inheritdoc/>
public void CleanUp()
{
// ignored
/// <inheritdoc/>
public void CleanUp()
{
// ignored
}
}
}

View file

@ -1,34 +1,35 @@
using System;
using System.Runtime.InteropServices;
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps;
/// <summary>
/// Test dedicated to handling of Access Violations.
/// </summary>
internal class HandledExceptionAgingStep : IAgingStep
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps
{
/// <inheritdoc/>
public string Name => "Test Handled Exception";
/// <inheritdoc/>
public SelfTestStepResult RunStep()
/// <summary>
/// Test dedicated to handling of Access Violations.
/// </summary>
internal class HandledExceptionAgingStep : IAgingStep
{
try
/// <inheritdoc/>
public string Name => "Test Handled Exception";
/// <inheritdoc/>
public SelfTestStepResult RunStep()
{
Marshal.ReadByte(IntPtr.Zero);
}
catch (AccessViolationException)
{
return SelfTestStepResult.Pass;
try
{
Marshal.ReadByte(IntPtr.Zero);
}
catch (AccessViolationException)
{
return SelfTestStepResult.Pass;
}
return SelfTestStepResult.Fail;
}
return SelfTestStepResult.Fail;
}
/// <inheritdoc/>
public void CleanUp()
{
// ignored
/// <inheritdoc/>
public void CleanUp()
{
// ignored
}
}
}

View file

@ -1,57 +1,58 @@
using Dalamud.Game.Gui;
using ImGuiNET;
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps;
/// <summary>
/// Test setup for the Hover events.
/// </summary>
internal class HoverAgingStep : IAgingStep
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps
{
private bool clearedItem = false;
private bool clearedAction = false;
/// <inheritdoc/>
public string Name => "Test Hover";
/// <inheritdoc/>
public SelfTestStepResult RunStep()
/// <summary>
/// Test setup for the Hover events.
/// </summary>
internal class HoverAgingStep : IAgingStep
{
var gameGui = Service<GameGui>.Get();
private bool clearedItem = false;
private bool clearedAction = false;
if (!this.clearedItem)
/// <inheritdoc/>
public string Name => "Test Hover";
/// <inheritdoc/>
public SelfTestStepResult RunStep()
{
ImGui.Text("Hover WHM soul crystal...");
var gameGui = Service<GameGui>.Get();
if (gameGui.HoveredItem == 4547)
if (!this.clearedItem)
{
this.clearedItem = true;
ImGui.Text("Hover WHM soul crystal...");
if (gameGui.HoveredItem == 4547)
{
this.clearedItem = true;
}
}
}
if (!this.clearedAction)
{
ImGui.Text("Hover \"Open Linkshells\" action...");
if (gameGui.HoveredAction != null &&
gameGui.HoveredAction.ActionKind == HoverActionKind.MainCommand &&
gameGui.HoveredAction.ActionID == 28)
if (!this.clearedAction)
{
this.clearedAction = true;
ImGui.Text("Hover \"Open Linkshells\" action...");
if (gameGui.HoveredAction != null &&
gameGui.HoveredAction.ActionKind == HoverActionKind.MainCommand &&
gameGui.HoveredAction.ActionID == 28)
{
this.clearedAction = true;
}
}
if (this.clearedItem && this.clearedAction)
{
return SelfTestStepResult.Pass;
}
return SelfTestStepResult.Waiting;
}
if (this.clearedItem && this.clearedAction)
/// <inheritdoc/>
public void CleanUp()
{
return SelfTestStepResult.Pass;
// ignored
}
return SelfTestStepResult.Waiting;
}
/// <inheritdoc/>
public void CleanUp()
{
// ignored
}
}

View file

@ -1,23 +1,24 @@
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps;
/// <summary>
/// Interface for test implementations.
/// </summary>
internal interface IAgingStep
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps
{
/// <summary>
/// Gets the name of the test.
/// Interface for test implementations.
/// </summary>
public string Name { get; }
internal interface IAgingStep
{
/// <summary>
/// Gets the name of the test.
/// </summary>
public string Name { get; }
/// <summary>
/// Run the test step, once per frame it is active.
/// </summary>
/// <returns>The result of this frame, test is discarded once a result other than <see cref="SelfTestStepResult.Waiting"/> is returned.</returns>
public SelfTestStepResult RunStep();
/// <summary>
/// Run the test step, once per frame it is active.
/// </summary>
/// <returns>The result of this frame, test is discarded once a result other than <see cref="SelfTestStepResult.Waiting"/> is returned.</returns>
public SelfTestStepResult RunStep();
/// <summary>
/// Clean up this test.
/// </summary>
public void CleanUp();
/// <summary>
/// Clean up this test.
/// </summary>
public void CleanUp();
}
}

View file

@ -1,38 +1,39 @@
using Dalamud.Game.ClientState.Keys;
using ImGuiNET;
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps;
/// <summary>
/// Test setup for the Key State.
/// </summary>
internal class KeyStateAgingStep : IAgingStep
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps
{
/// <inheritdoc/>
public string Name => "Test KeyState";
/// <inheritdoc/>
public SelfTestStepResult RunStep()
/// <summary>
/// Test setup for the Key State.
/// </summary>
internal class KeyStateAgingStep : IAgingStep
{
var keyState = Service<KeyState>.Get();
/// <inheritdoc/>
public string Name => "Test KeyState";
ImGui.Text("Hold down D,A,L,M,U");
if (keyState[VirtualKey.D]
&& keyState[VirtualKey.A]
&& keyState[VirtualKey.L]
&& keyState[VirtualKey.M]
&& keyState[VirtualKey.U])
/// <inheritdoc/>
public SelfTestStepResult RunStep()
{
return SelfTestStepResult.Pass;
var keyState = Service<KeyState>.Get();
ImGui.Text("Hold down D,A,L,M,U");
if (keyState[VirtualKey.D]
&& keyState[VirtualKey.A]
&& keyState[VirtualKey.L]
&& keyState[VirtualKey.M]
&& keyState[VirtualKey.U])
{
return SelfTestStepResult.Pass;
}
return SelfTestStepResult.Waiting;
}
return SelfTestStepResult.Waiting;
}
/// <inheritdoc/>
public void CleanUp()
{
// ignored
/// <inheritdoc/>
public void CleanUp()
{
// ignored
}
}
}

View file

@ -3,56 +3,57 @@ using System;
using Dalamud.Game.ClientState;
using ImGuiNET;
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps;
/// <summary>
/// Test setup for the login events.
/// </summary>
internal class LoginEventAgingStep : IAgingStep
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps
{
private bool subscribed = false;
private bool hasPassed = false;
/// <inheritdoc/>
public string Name => "Test Log-In";
/// <inheritdoc/>
public SelfTestStepResult RunStep()
/// <summary>
/// Test setup for the login events.
/// </summary>
internal class LoginEventAgingStep : IAgingStep
{
var clientState = Service<ClientState>.Get();
private bool subscribed = false;
private bool hasPassed = false;
ImGui.Text("Log in now...");
/// <inheritdoc/>
public string Name => "Test Log-In";
if (!this.subscribed)
/// <inheritdoc/>
public SelfTestStepResult RunStep()
{
clientState.Login += this.ClientStateOnOnLogin;
this.subscribed = true;
var clientState = Service<ClientState>.Get();
ImGui.Text("Log in now...");
if (!this.subscribed)
{
clientState.Login += this.ClientStateOnOnLogin;
this.subscribed = true;
}
if (this.hasPassed)
{
clientState.Login -= this.ClientStateOnOnLogin;
this.subscribed = false;
return SelfTestStepResult.Pass;
}
return SelfTestStepResult.Waiting;
}
if (this.hasPassed)
/// <inheritdoc/>
public void CleanUp()
{
clientState.Login -= this.ClientStateOnOnLogin;
this.subscribed = false;
return SelfTestStepResult.Pass;
var clientState = Service<ClientState>.Get();
if (this.subscribed)
{
clientState.Login -= this.ClientStateOnOnLogin;
this.subscribed = false;
}
}
return SelfTestStepResult.Waiting;
}
/// <inheritdoc/>
public void CleanUp()
{
var clientState = Service<ClientState>.Get();
if (this.subscribed)
private void ClientStateOnOnLogin(object sender, EventArgs e)
{
clientState.Login -= this.ClientStateOnOnLogin;
this.subscribed = false;
this.hasPassed = true;
}
}
private void ClientStateOnOnLogin(object sender, EventArgs e)
{
this.hasPassed = true;
}
}

View file

@ -3,56 +3,57 @@ using System;
using Dalamud.Game.ClientState;
using ImGuiNET;
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps;
/// <summary>
/// Test setup for the login events.
/// </summary>
internal class LogoutEventAgingStep : IAgingStep
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps
{
private bool subscribed = false;
private bool hasPassed = false;
/// <inheritdoc/>
public string Name => "Test Log-In";
/// <inheritdoc/>
public SelfTestStepResult RunStep()
/// <summary>
/// Test setup for the login events.
/// </summary>
internal class LogoutEventAgingStep : IAgingStep
{
var clientState = Service<ClientState>.Get();
private bool subscribed = false;
private bool hasPassed = false;
ImGui.Text("Log out now...");
/// <inheritdoc/>
public string Name => "Test Log-In";
if (!this.subscribed)
/// <inheritdoc/>
public SelfTestStepResult RunStep()
{
clientState.Logout += this.ClientStateOnOnLogout;
this.subscribed = true;
var clientState = Service<ClientState>.Get();
ImGui.Text("Log out now...");
if (!this.subscribed)
{
clientState.Logout += this.ClientStateOnOnLogout;
this.subscribed = true;
}
if (this.hasPassed)
{
clientState.Logout -= this.ClientStateOnOnLogout;
this.subscribed = false;
return SelfTestStepResult.Pass;
}
return SelfTestStepResult.Waiting;
}
if (this.hasPassed)
/// <inheritdoc/>
public void CleanUp()
{
clientState.Logout -= this.ClientStateOnOnLogout;
this.subscribed = false;
return SelfTestStepResult.Pass;
var clientState = Service<ClientState>.Get();
if (this.subscribed)
{
clientState.Logout -= this.ClientStateOnOnLogout;
this.subscribed = false;
}
}
return SelfTestStepResult.Waiting;
}
/// <inheritdoc/>
public void CleanUp()
{
var clientState = Service<ClientState>.Get();
if (this.subscribed)
private void ClientStateOnOnLogout(object sender, EventArgs e)
{
clientState.Logout -= this.ClientStateOnOnLogout;
this.subscribed = false;
this.hasPassed = true;
}
}
private void ClientStateOnOnLogout(object sender, EventArgs e)
{
this.hasPassed = true;
}
}

View file

@ -5,37 +5,38 @@ using Dalamud.Data;
using Dalamud.Utility;
using Lumina.Excel;
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps;
/// <summary>
/// Test setup for Lumina.
/// </summary>
/// <typeparam name="T">ExcelRow to run test on.</typeparam>
internal class LuminaAgingStep<T> : IAgingStep
where T : ExcelRow
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps
{
private int step = 0;
private List<T> rows;
/// <inheritdoc/>
public string Name => "Test Lumina";
/// <inheritdoc/>
public SelfTestStepResult RunStep()
/// <summary>
/// Test setup for Lumina.
/// </summary>
/// <typeparam name="T">ExcelRow to run test on.</typeparam>
internal class LuminaAgingStep<T> : IAgingStep
where T : ExcelRow
{
var dataManager = Service<DataManager>.Get();
private int step = 0;
private List<T> rows;
this.rows ??= dataManager.GetExcelSheet<T>().ToList();
/// <inheritdoc/>
public string Name => "Test Lumina";
Util.ShowObject(this.rows[this.step]);
/// <inheritdoc/>
public SelfTestStepResult RunStep()
{
var dataManager = Service<DataManager>.Get();
this.step++;
return this.step >= this.rows.Count ? SelfTestStepResult.Pass : SelfTestStepResult.Waiting;
}
this.rows ??= dataManager.GetExcelSheet<T>().ToList();
/// <inheritdoc/>
public void CleanUp()
{
// ignored
Util.ShowObject(this.rows[this.step]);
this.step++;
return this.step >= this.rows.Count ? SelfTestStepResult.Pass : SelfTestStepResult.Waiting;
}
/// <inheritdoc/>
public void CleanUp()
{
// ignored
}
}
}

View file

@ -2,56 +2,57 @@ using Dalamud.Game.Gui.PartyFinder;
using Dalamud.Game.Gui.PartyFinder.Types;
using ImGuiNET;
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps;
/// <summary>
/// Test setup for Party Finder events.
/// </summary>
internal class PartyFinderAgingStep : IAgingStep
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps
{
private bool subscribed = false;
private bool hasPassed = false;
/// <inheritdoc/>
public string Name => "Test Party Finder";
/// <inheritdoc/>
public SelfTestStepResult RunStep()
/// <summary>
/// Test setup for Party Finder events.
/// </summary>
internal class PartyFinderAgingStep : IAgingStep
{
var partyFinderGui = Service<PartyFinderGui>.Get();
private bool subscribed = false;
private bool hasPassed = false;
if (!this.subscribed)
/// <inheritdoc/>
public string Name => "Test Party Finder";
/// <inheritdoc/>
public SelfTestStepResult RunStep()
{
partyFinderGui.ReceiveListing += this.PartyFinderOnReceiveListing;
this.subscribed = true;
var partyFinderGui = Service<PartyFinderGui>.Get();
if (!this.subscribed)
{
partyFinderGui.ReceiveListing += this.PartyFinderOnReceiveListing;
this.subscribed = true;
}
if (this.hasPassed)
{
partyFinderGui.ReceiveListing -= this.PartyFinderOnReceiveListing;
this.subscribed = false;
return SelfTestStepResult.Pass;
}
ImGui.Text("Open Party Finder");
return SelfTestStepResult.Waiting;
}
if (this.hasPassed)
/// <inheritdoc/>
public void CleanUp()
{
partyFinderGui.ReceiveListing -= this.PartyFinderOnReceiveListing;
this.subscribed = false;
return SelfTestStepResult.Pass;
var partyFinderGui = Service<PartyFinderGui>.Get();
if (this.subscribed)
{
partyFinderGui.ReceiveListing -= this.PartyFinderOnReceiveListing;
this.subscribed = false;
}
}
ImGui.Text("Open Party Finder");
return SelfTestStepResult.Waiting;
}
/// <inheritdoc/>
public void CleanUp()
{
var partyFinderGui = Service<PartyFinderGui>.Get();
if (this.subscribed)
private void PartyFinderOnReceiveListing(PartyFinderListing listing, PartyFinderListingEventArgs args)
{
partyFinderGui.ReceiveListing -= this.PartyFinderOnReceiveListing;
this.subscribed = false;
this.hasPassed = true;
}
}
private void PartyFinderOnReceiveListing(PartyFinderListing listing, PartyFinderListingEventArgs args)
{
this.hasPassed = true;
}
}

View file

@ -3,73 +3,74 @@ using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Game.ClientState.Objects.Types;
using ImGuiNET;
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps;
/// <summary>
/// Test setup for targets.
/// </summary>
internal class TargetAgingStep : IAgingStep
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps
{
private int step = 0;
/// <inheritdoc/>
public string Name => "Test Target";
/// <inheritdoc/>
public SelfTestStepResult RunStep()
/// <summary>
/// Test setup for targets.
/// </summary>
internal class TargetAgingStep : IAgingStep
{
var targetManager = Service<TargetManager>.Get();
private int step = 0;
switch (this.step)
/// <inheritdoc/>
public string Name => "Test Target";
/// <inheritdoc/>
public SelfTestStepResult RunStep()
{
case 0:
targetManager.ClearTarget();
targetManager.ClearFocusTarget();
var targetManager = Service<TargetManager>.Get();
this.step++;
switch (this.step)
{
case 0:
targetManager.ClearTarget();
targetManager.ClearFocusTarget();
break;
case 1:
ImGui.Text("Target a player...");
var cTarget = targetManager.Target;
if (cTarget is PlayerCharacter)
{
this.step++;
}
break;
break;
case 2:
ImGui.Text("Focus-Target a Battle NPC...");
case 1:
ImGui.Text("Target a player...");
var fTarget = targetManager.FocusTarget;
if (fTarget is BattleNpc)
{
this.step++;
}
var cTarget = targetManager.Target;
if (cTarget is PlayerCharacter)
{
this.step++;
}
break;
break;
case 3:
ImGui.Text("Soft-Target an EventObj...");
case 2:
ImGui.Text("Focus-Target a Battle NPC...");
var sTarget = targetManager.FocusTarget;
if (sTarget is EventObj)
{
return SelfTestStepResult.Pass;
}
var fTarget = targetManager.FocusTarget;
if (fTarget is BattleNpc)
{
this.step++;
}
break;
break;
case 3:
ImGui.Text("Soft-Target an EventObj...");
var sTarget = targetManager.FocusTarget;
if (sTarget is EventObj)
{
return SelfTestStepResult.Pass;
}
break;
}
return SelfTestStepResult.Waiting;
}
return SelfTestStepResult.Waiting;
}
/// <inheritdoc/>
public void CleanUp()
{
// ignored
/// <inheritdoc/>
public void CleanUp()
{
// ignored
}
}
}

View file

@ -1,29 +1,30 @@
using Dalamud.Game.Gui.Toast;
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps;
/// <summary>
/// Test setup for toasts.
/// </summary>
internal class ToastAgingStep : IAgingStep
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps
{
/// <inheritdoc/>
public string Name => "Test Toasts";
/// <inheritdoc/>
public SelfTestStepResult RunStep()
/// <summary>
/// Test setup for toasts.
/// </summary>
internal class ToastAgingStep : IAgingStep
{
var toastGui = Service<ToastGui>.Get();
/// <inheritdoc/>
public string Name => "Test Toasts";
toastGui.ShowNormal("Normal Toast");
toastGui.ShowError("Error Toast");
/// <inheritdoc/>
public SelfTestStepResult RunStep()
{
var toastGui = Service<ToastGui>.Get();
return SelfTestStepResult.Pass;
}
toastGui.ShowNormal("Normal Toast");
toastGui.ShowError("Error Toast");
/// <inheritdoc/>
public void CleanUp()
{
// ignored
return SelfTestStepResult.Pass;
}
/// <inheritdoc/>
public void CleanUp()
{
// ignored
}
}
}

View file

@ -1,37 +1,38 @@
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps;
/// <summary>
/// Test that waits N frames.
/// </summary>
internal class WaitFramesAgingStep : IAgingStep
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps
{
private readonly int frames;
private int cFrames;
/// <summary>
/// Initializes a new instance of the <see cref="WaitFramesAgingStep"/> class.
/// Test that waits N frames.
/// </summary>
/// <param name="frames">Amount of frames to wait.</param>
public WaitFramesAgingStep(int frames)
internal class WaitFramesAgingStep : IAgingStep
{
this.frames = frames;
this.cFrames = frames;
}
private readonly int frames;
private int cFrames;
/// <inheritdoc/>
public string Name => $"Wait {this.cFrames} frames";
/// <summary>
/// Initializes a new instance of the <see cref="WaitFramesAgingStep"/> class.
/// </summary>
/// <param name="frames">Amount of frames to wait.</param>
public WaitFramesAgingStep(int frames)
{
this.frames = frames;
this.cFrames = frames;
}
/// <inheritdoc/>
public SelfTestStepResult RunStep()
{
this.cFrames--;
/// <inheritdoc/>
public string Name => $"Wait {this.cFrames} frames";
return this.cFrames <= 0 ? SelfTestStepResult.Pass : SelfTestStepResult.Waiting;
}
/// <inheritdoc/>
public SelfTestStepResult RunStep()
{
this.cFrames--;
/// <inheritdoc/>
public void CleanUp()
{
this.cFrames = this.frames;
return this.cFrames <= 0 ? SelfTestStepResult.Pass : SelfTestStepResult.Waiting;
}
/// <inheritdoc/>
public void CleanUp()
{
this.cFrames = this.frames;
}
}
}