Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

necessary changes for EXDSchema generation #71

Merged
merged 6 commits into from
Oct 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/Lumina/Excel/LazyRow.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using System;
using System.Linq;
using Lumina.Data;
using Lumina.Data.Files.Excel;
using Lumina.Data.Structs.Excel;

namespace Lumina.Excel
{
Expand All @@ -22,6 +26,40 @@ public interface ILazyRow
public ExcelRow? RawRow { get; }
}

public class EmptyLazyRow : ILazyRow
{
private static readonly ExcelDataPagination _blankPagination = new();

public uint Row { get; set; }
public bool IsValueCreated => false;
public Language Language => Language.None;
public ExcelRow? RawRow => null;

public EmptyLazyRow( uint rowId )
{
Row = rowId;
}

public static ILazyRow GetFirstLazyRowOrEmpty( GameData gameData, uint row, params string[] sheetNames )
{
return GetFirstLazyRowOrEmpty( gameData, row, Language.None, sheetNames );
}

public static ILazyRow GetFirstLazyRowOrEmpty( GameData gameData, uint row, Language language, params string[] sheetNames )
{
foreach( var sheetName in sheetNames )
{
var exh = gameData.GetFile<ExcelHeaderFile>( $"exd/{sheetName}.exh" );
if( exh == null ) continue;
var page = exh.DataPages.FirstOrDefault( s => row >= s.StartId && row <= s.StartId + s.RowCount, _blankPagination );
if( page.Equals( _blankPagination ) ) continue;

return new LazyRow<ExcelRow>(gameData, row, language);
}
return new EmptyLazyRow( row );
}
}

/// <summary>
/// Allows for sheet definitions to contain entries which will lazily load the referenced sheet row
/// </summary>
Expand Down
Loading