mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-04-28 09:21:57 +00:00
SGA model cleanup
This commit is contained in:
@@ -9,11 +9,11 @@ namespace SabreTools.Data.Models.SGA
|
||||
/// <summary>
|
||||
///Header data
|
||||
/// </summary>
|
||||
public Header? Header { get; set; }
|
||||
public Header Header { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Directory data
|
||||
/// </summary>
|
||||
public Directory? Directory { get; set; }
|
||||
public Directory Directory { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,4 +13,4 @@ namespace SabreTools.Data.Models.SGA
|
||||
/// </summary>
|
||||
public const int HL_SGA_CHECKSUM_LENGTH = 0x00008000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace SabreTools.Data.Models.SGA
|
||||
/// <summary>
|
||||
/// Source SGA file
|
||||
/// </summary>
|
||||
public Archive? File { get; set; }
|
||||
public Archive File { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -25,26 +25,26 @@ namespace SabreTools.Data.Models.SGA
|
||||
/// <summary>
|
||||
/// Directory header data
|
||||
/// </summary>
|
||||
public TDirectoryHeader? DirectoryHeader { get; set; }
|
||||
public TDirectoryHeader DirectoryHeader { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Sections data
|
||||
/// </summary>
|
||||
public TSection[]? Sections { get; set; }
|
||||
public TSection[] Sections { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Folders data
|
||||
/// </summary>
|
||||
public TFolder[]? Folders { get; set; }
|
||||
public TFolder[] Folders { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Files data
|
||||
/// </summary>
|
||||
public TFile[]? Files { get; set; }
|
||||
public TFile[] Files { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// String table data
|
||||
/// </summary>
|
||||
public Dictionary<long, string?>? StringTable { get; set; }
|
||||
public Dictionary<long, string?> StringTable { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,22 +7,22 @@ namespace SabreTools.Data.Models.SGA
|
||||
}
|
||||
|
||||
/// <see href="https://github.com/RavuAlHemio/hllib/blob/master/HLLib/SGAFile.h"/>
|
||||
public abstract class DirectoryHeader<T>
|
||||
public abstract class DirectoryHeader<T> where T : notnull
|
||||
{
|
||||
public uint SectionOffset { get; set; }
|
||||
|
||||
public T? SectionCount { get; set; }
|
||||
public T SectionCount { get; set; }
|
||||
|
||||
public uint FolderOffset { get; set; }
|
||||
|
||||
public T? FolderCount { get; set; }
|
||||
public T FolderCount { get; set; }
|
||||
|
||||
public uint FileOffset { get; set; }
|
||||
|
||||
public T? FileCount { get; set; }
|
||||
public T FileCount { get; set; }
|
||||
|
||||
public uint StringTableOffset { get; set; }
|
||||
|
||||
public T? StringTableCount { get; set; }
|
||||
public T StringTableCount { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace SabreTools.Data.Models.SGA
|
||||
{
|
||||
public uint NameOffset { get; set; }
|
||||
|
||||
public string? Name { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
public uint Offset { get; set; }
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ namespace SabreTools.Data.Models.SGA
|
||||
/// <see href="https://github.com/RavuAlHemio/hllib/blob/master/HLLib/SGAFile.h"/>
|
||||
public sealed class FileHeader
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
public uint CRC32 { get; set; }
|
||||
}
|
||||
|
||||
@@ -9,14 +9,14 @@ namespace SabreTools.Data.Models.SGA
|
||||
}
|
||||
|
||||
/// <see href="https://github.com/RavuAlHemio/hllib/blob/master/HLLib/SGAFile.h"/>
|
||||
public abstract class Folder<T> : Folder
|
||||
public abstract class Folder<T> : Folder where T : notnull
|
||||
{
|
||||
public T? FolderStartIndex { get; set; }
|
||||
public T FolderStartIndex { get; set; }
|
||||
|
||||
public T? FolderEndIndex { get; set; }
|
||||
public T FolderEndIndex { get; set; }
|
||||
|
||||
public T? FileStartIndex { get; set; }
|
||||
public T FileStartIndex { get; set; }
|
||||
|
||||
public T? FileEndIndex { get; set; }
|
||||
public T FileEndIndex { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ namespace SabreTools.Data.Models.SGA
|
||||
/// <see href="https://github.com/RavuAlHemio/hllib/blob/master/HLLib/SGAFile.h"/>
|
||||
public abstract class Header
|
||||
{
|
||||
public string? Signature { get; set; }
|
||||
public string Signature { get; set; }
|
||||
|
||||
public ushort MajorVersion { get; set; }
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace SabreTools.Data.Models.SGA
|
||||
{
|
||||
public byte[] FileMD5 { get; set; } = new byte[0x10];
|
||||
|
||||
public string? Name { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
public byte[] HeaderMD5 { get; set; } = new byte[0x10];
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ namespace SabreTools.Data.Models.SGA
|
||||
/// <see href="https://github.com/RavuAlHemio/hllib/blob/master/HLLib/SGAFile.h"/>
|
||||
public sealed class Header6 : Header
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
public uint HeaderLength { get; set; }
|
||||
|
||||
|
||||
@@ -3,22 +3,22 @@ namespace SabreTools.Data.Models.SGA
|
||||
/// <see href="https://github.com/RavuAlHemio/hllib/blob/master/HLLib/SGAFile.h"/>
|
||||
public abstract class Section
|
||||
{
|
||||
public string? Alias { get; set; }
|
||||
public string Alias { get; set; }
|
||||
|
||||
public string? Name { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
/// <see href="https://github.com/RavuAlHemio/hllib/blob/master/HLLib/SGAFile.h"/>
|
||||
public abstract class Section<T> : Section
|
||||
public abstract class Section<T> : Section where T : notnull
|
||||
{
|
||||
public T? FolderStartIndex { get; set; }
|
||||
public T FolderStartIndex { get; set; }
|
||||
|
||||
public T? FolderEndIndex { get; set; }
|
||||
public T FolderEndIndex { get; set; }
|
||||
|
||||
public T? FileStartIndex { get; set; }
|
||||
public T FileStartIndex { get; set; }
|
||||
|
||||
public T? FileEndIndex { get; set; }
|
||||
public T FileEndIndex { get; set; }
|
||||
|
||||
public T? FolderRootIndex { get; set; }
|
||||
public T FolderRootIndex { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,17 +26,10 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// TODO: Should we print the string table?
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, Header? header)
|
||||
private static void Print(StringBuilder builder, Header header)
|
||||
{
|
||||
builder.AppendLine(" Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (header == null)
|
||||
{
|
||||
builder.AppendLine(" No header");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
builder.AppendLine(header.Signature, " Signature");
|
||||
builder.AppendLine(header.MajorVersion, " Major version");
|
||||
builder.AppendLine(header.MinorVersion, " Minor version");
|
||||
@@ -62,17 +55,10 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, Directory? directory)
|
||||
private static void Print(StringBuilder builder, Directory directory)
|
||||
{
|
||||
builder.AppendLine(" Directory Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (directory == null)
|
||||
{
|
||||
builder.AppendLine(" No directory");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (directory)
|
||||
{
|
||||
case Directory4 directory4:
|
||||
@@ -111,17 +97,10 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, DirectoryHeader4? header)
|
||||
private static void Print(StringBuilder builder, DirectoryHeader4 header)
|
||||
{
|
||||
builder.AppendLine(" Directory Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (header == null)
|
||||
{
|
||||
builder.AppendLine(" No directory header");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
builder.AppendLine(header.SectionOffset, " Section offset");
|
||||
builder.AppendLine(header.SectionCount, " Section count");
|
||||
builder.AppendLine(header.FolderOffset, " Folder offset");
|
||||
@@ -133,17 +112,10 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, DirectoryHeader5? header)
|
||||
private static void Print(StringBuilder builder, DirectoryHeader5 header)
|
||||
{
|
||||
builder.AppendLine(" Directory Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (header == null)
|
||||
{
|
||||
builder.AppendLine(" No directory header");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
builder.AppendLine(header.SectionOffset, " Section offset");
|
||||
builder.AppendLine(header.SectionCount, " Section count");
|
||||
builder.AppendLine(header.FolderOffset, " Folder offset");
|
||||
@@ -155,17 +127,10 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, DirectoryHeader7? header)
|
||||
private static void Print(StringBuilder builder, DirectoryHeader7 header)
|
||||
{
|
||||
builder.AppendLine(" Directory Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (header == null)
|
||||
{
|
||||
builder.AppendLine(" No directory header");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
builder.AppendLine(header.SectionOffset, " Section offset");
|
||||
builder.AppendLine(header.SectionCount, " Section count");
|
||||
builder.AppendLine(header.FolderOffset, " Folder offset");
|
||||
@@ -179,11 +144,11 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, Section4[]? sections)
|
||||
private static void Print(StringBuilder builder, Section4[] sections)
|
||||
{
|
||||
builder.AppendLine(" Sections Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (sections == null || sections.Length == 0)
|
||||
if (sections.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No sections");
|
||||
builder.AppendLine();
|
||||
@@ -207,11 +172,11 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, Section5[]? sections)
|
||||
private static void Print(StringBuilder builder, Section5[] sections)
|
||||
{
|
||||
builder.AppendLine(" Sections Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (sections == null || sections.Length == 0)
|
||||
if (sections.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No sections");
|
||||
builder.AppendLine();
|
||||
@@ -235,11 +200,11 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, Folder4[]? folders)
|
||||
private static void Print(StringBuilder builder, Folder4[] folders)
|
||||
{
|
||||
builder.AppendLine(" Folders Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (folders == null || folders.Length == 0)
|
||||
if (folders.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No folders");
|
||||
builder.AppendLine();
|
||||
@@ -262,11 +227,11 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, Folder5[]? folders)
|
||||
private static void Print(StringBuilder builder, Folder5[] folders)
|
||||
{
|
||||
builder.AppendLine(" Folders Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (folders == null || folders.Length == 0)
|
||||
if (folders.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No folders");
|
||||
builder.AppendLine();
|
||||
@@ -289,11 +254,11 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, File4[]? files)
|
||||
private static void Print(StringBuilder builder, File4[] files)
|
||||
{
|
||||
builder.AppendLine(" Files Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (files == null || files.Length == 0)
|
||||
if (files.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No files");
|
||||
builder.AppendLine();
|
||||
@@ -318,11 +283,11 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, File6[]? files)
|
||||
private static void Print(StringBuilder builder, File6[] files)
|
||||
{
|
||||
builder.AppendLine(" Files Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (files == null || files.Length == 0)
|
||||
if (files.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No files");
|
||||
builder.AppendLine();
|
||||
@@ -348,11 +313,11 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, File7[]? files)
|
||||
private static void Print(StringBuilder builder, File7[] files)
|
||||
{
|
||||
builder.AppendLine(" Files Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (files == null || files.Length == 0)
|
||||
if (files.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No files");
|
||||
builder.AppendLine();
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// <summary>
|
||||
/// Directory data
|
||||
/// </summary>
|
||||
public Data.Models.SGA.Directory? Directory => Model.Directory;
|
||||
public Data.Models.SGA.Directory Directory => Model.Directory;
|
||||
|
||||
/// <summary>
|
||||
/// Number of files in the directory
|
||||
@@ -29,10 +29,10 @@ namespace SabreTools.Serialization.Wrappers
|
||||
{
|
||||
return Directory switch
|
||||
{
|
||||
Directory4 d4 => d4.Files?.Length ?? 0,
|
||||
Directory5 d5 => d5.Files?.Length ?? 0,
|
||||
Directory6 d6 => d6.Files?.Length ?? 0,
|
||||
Directory7 d7 => d7.Files?.Length ?? 0,
|
||||
Directory4 d4 => d4.Files.Length,
|
||||
Directory5 d5 => d5.Files.Length,
|
||||
Directory6 d6 => d6.Files.Length,
|
||||
Directory7 d7 => d7.Files.Length,
|
||||
_ => 0,
|
||||
};
|
||||
}
|
||||
@@ -220,10 +220,10 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Get the folder
|
||||
Folder? folder = Directory switch
|
||||
{
|
||||
Directory4 d4 => Array.Find(d4.Folders ?? [], f => f != null && index >= f.FileStartIndex && index <= f.FileEndIndex),
|
||||
Directory5 d5 => Array.Find(d5.Folders ?? [], f => f != null && index >= f.FileStartIndex && index <= f.FileEndIndex),
|
||||
Directory6 d6 => Array.Find(d6.Folders ?? [], f => f != null && index >= f.FileStartIndex && index <= f.FileEndIndex),
|
||||
Directory7 d7 => Array.Find(d7.Folders ?? [], f => f != null && index >= f.FileStartIndex && index <= f.FileEndIndex),
|
||||
Directory4 d4 => Array.Find(d4.Folders, f => f != null && index >= f.FileStartIndex && index <= f.FileEndIndex),
|
||||
Directory5 d5 => Array.Find(d5.Folders, f => f != null && index >= f.FileStartIndex && index <= f.FileEndIndex),
|
||||
Directory6 d6 => Array.Find(d6.Folders, f => f != null && index >= f.FileStartIndex && index <= f.FileEndIndex),
|
||||
Directory7 d7 => Array.Find(d7.Folders, f => f != null && index >= f.FileStartIndex && index <= f.FileEndIndex),
|
||||
_ => default,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user