diff --git a/TheDialgaTeam.FossilFighters.Assets/Header/DmgHeader.cs b/TheDialgaTeam.FossilFighters.Assets/Header/DmgHeader.cs index ea5f4db..cb13a96 100644 --- a/TheDialgaTeam.FossilFighters.Assets/Header/DmgHeader.cs +++ b/TheDialgaTeam.FossilFighters.Assets/Header/DmgHeader.cs @@ -20,13 +20,13 @@ namespace TheDialgaTeam.FossilFighters.Assets.Header; -[JsonSerializable(typeof(DmgHeader))] +public readonly record struct DmgTextInfo(int TextId, string Text); + +[JsonSerializable(typeof(DmgHeader), GenerationMode = JsonSourceGenerationMode.Serialization)] public sealed partial class DmgHeaderContext : JsonSerializerContext { } -public readonly record struct DmgTextInfo(int TextId, string Text); - [PublicAPI] public sealed class DmgHeader { @@ -34,6 +34,11 @@ public sealed class DmgHeader public DmgTextInfo[] Texts { get; init; } + public DmgHeader(DmgTextInfo[] texts) + { + Texts = texts; + } + public static DmgHeader GetHeaderFromStream(Stream stream) { using var reader = new BinaryReader(stream, Encoding.UTF8, true); @@ -42,7 +47,7 @@ public static DmgHeader GetHeaderFromStream(Stream stream) var textCount = reader.ReadUInt32(); var texts = new DmgTextInfo[textCount]; - + stream.Seek(reader.ReadUInt32(), SeekOrigin.Begin); var textOffsets = new uint[textCount]; @@ -51,26 +56,25 @@ public static DmgHeader GetHeaderFromStream(Stream stream) { textOffsets[i] = reader.ReadUInt32(); } - + for (var i = 0; i < textCount; i++) { stream.Seek(textOffsets[i], SeekOrigin.Begin); var textBuilder = new StringBuilder(); - int id1, id2 = 0; char nextChar; - id1 = reader.ReadInt32(); - id2 = reader.ReadInt32(); - + var id = reader.ReadInt32(); + _ = reader.ReadInt32(); + while ((nextChar = reader.ReadChar()) != '\0') { textBuilder.Append(nextChar); } - texts[i] = new DmgTextInfo(id1, textBuilder.ToString()); + texts[i] = new DmgTextInfo(id, textBuilder.ToString()); } - return new DmgHeader { Texts = texts }; + return new DmgHeader(texts); } } \ No newline at end of file diff --git a/TheDialgaTeam.FossilFighters.Tool.Cli/TheDialgaTeam.FossilFighters.Tool.Cli.csproj b/TheDialgaTeam.FossilFighters.Tool.Cli/TheDialgaTeam.FossilFighters.Tool.Cli.csproj index 8a55f29..d5238dd 100644 --- a/TheDialgaTeam.FossilFighters.Tool.Cli/TheDialgaTeam.FossilFighters.Tool.Cli.csproj +++ b/TheDialgaTeam.FossilFighters.Tool.Cli/TheDialgaTeam.FossilFighters.Tool.Cli.csproj @@ -9,7 +9,6 @@ enable true - true true 1.7.0 diff --git a/TheDialgaTeam.FossilFighters.Tool.Gui/TheDialgaTeam.FossilFighters.Tool.Gui.csproj b/TheDialgaTeam.FossilFighters.Tool.Gui/TheDialgaTeam.FossilFighters.Tool.Gui.csproj index 79c9cc1..3565e85 100644 --- a/TheDialgaTeam.FossilFighters.Tool.Gui/TheDialgaTeam.FossilFighters.Tool.Gui.csproj +++ b/TheDialgaTeam.FossilFighters.Tool.Gui/TheDialgaTeam.FossilFighters.Tool.Gui.csproj @@ -11,7 +11,6 @@ true true - true false 2.0.0