Dalamud/Dalamud/Interface/Internal/Windows/SelfTest/AgingSteps/LuminaAgingStep.cs
Asriel Camora 0b9af0e3f4
Update to Lumina 5 (new Excel parsing) (#2022)
* Refactor and upgrade to new excel design

* Obsolete ExcelResolver<T> and use only RowRef<T>

* Better benchmarking for Lumina

* Add custom game-supported RSV provider

* Refactor and move Lazy<T> and nullable/cached row objects to RowRefs

* Convert IRSVProvider to delegate, resolve strings by default

* Split IExcelRow into IExcelSubrow

* Extra lumina documentation

* Minor RSV CS fixes

* Fix UIGlowPayload warning

* Fix rebase

* Update to Lumina 5
2024-10-20 19:59:03 -07:00

53 lines
1.4 KiB
C#

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>
/// <param name="isLargeSheet">Whether or not the sheet is large. If it is large, the self test will iterate through the full sheet in one frame and benchmark the time taken.</param>
internal class LuminaAgingStep<T>(bool isLargeSheet) : IAgingStep
where T : struct, IExcelRow<T>
{
private int step = 0;
private ExcelSheet<T> rows;
/// <inheritdoc/>
public string Name => $"Test Lumina ({typeof(T).Name})";
/// <inheritdoc/>
public SelfTestStepResult RunStep()
{
this.rows ??= Service<DataManager>.Get().GetExcelSheet<T>();
if (isLargeSheet)
{
var i = 0;
T currentRow = default;
foreach (var row in this.rows)
{
i++;
currentRow = row;
}
Util.ShowObject(currentRow);
return SelfTestStepResult.Pass;
}
else
{
Util.ShowObject(this.rows.GetRowAt(this.step));
this.step++;
return this.step >= this.rows.Count ? SelfTestStepResult.Pass : SelfTestStepResult.Waiting;
}
}
/// <inheritdoc/>
public void CleanUp()
{
this.step = 0;
}
}